3 ms·
It's not possible to pre-compile away the dynamic part of a Proxy's behavior. For instance, if you were to receive a random string over some network call and s
by fro0116 8y ago
It's not possible to pre-compile away the dynamic part of a Proxy's behavior.
For instance, if you were to receive a random string over some network call and set that on a proxified object, how would you pre-compile the Proxy away such that its runtime behavior is preserved when accessing what could be any arbitrary string?
You'd need infinite space to represent the space of all possible string inputs in order to optimize that away at compile time, which is obviously not feasible.
- chrisseaton 8y agoI know you can't AOT compile it away, that seems obvious, but what's the limitation that means you can't JIT compile it away? Like any other JS optimisation such as inline caching?
- fro0116 8y agoJIT isn't really compiling the runtime performance penalty of the Proxy "away" though. JIT compilation still involves a runtime performance penalty of the JIT compilation step itself, that has to be traded off against the runtime performance penalty of just running the Proxy logic without any runtime compilation step. That's a nuanced tradeoff that has to be weighed on a case by case basis by various heuristics, and can reduce the runtime cost of proxies when applied to the right cases (and at the same time, could increase runtime cost if applied to the wrong ones: think overly aggressive inlining and its effects on memory usage), but either way it doesn't result in the Proxy abstraction becoming "compiled away" into something that has 0 runtime cost.
- deleted 8y ago[deleted]