2 ms·
Because they need runtime support from the engine, e.g. you need engine support in order to intercept calls like: obj[prop] = 'foo' where prop is user input
by pxndx 8y ago
Because they need runtime support from the engine, e.g. you need engine support in order to intercept calls like:
obj[prop] = 'foo'
where prop is user input or similar. You could technically compile them away if you replaced all property set/gets with code like
set(obj, prop, "foo")
get(obj, prop)
with a babel step, but the performance impact of this (both in runtime and compile-time) would be enormous.
- chrisseaton 8y agoI don't mean Babel source-to-source compilation. I mean the native compilation done at runtime. The JIT.
- pxndx 8y agoThere's some work being done on optimising Proxies, but the current implementation is just slow (and also varies by engine), but yes, they can probably be optimised further. EDIT: there are various blog posts around talking about optimisation: https://v8.dev/blog/optimizing-proxies https://v8.dev/blog/optimizing-proxies