Sharing a JavaScript implementation across realms

Filip Pizlo fpizlo at apple.com
Tue Jan 13 10:45:07 PST 2015


We have been trying to improve sharing in JSC for a while now. We can share bytecode between realms, but this is mostly about reducing parse time rather than space saving - the bytecode has to be "linked" before a realm uses it, which involves making a copy of most of the data structures. 

I don't think that full sharing is impossible in the current language. Turning off the link step - or eliminating the need for a full copy - is almost doable, but would have some cost for variable resolution performance in the early iterations of a function. I've been toying with sharing JIT code at the lowest JIT tier, which would have similar trade offs. 

Something that JSC does have going for it if we had a larger library footprint is that we interpret bytecode for the first 100 or so executions of any function. Even when we have to splat a copy of the bytecode, it still takes less memory than machine code at any level of optimization. 

So, I'm curious what issues you were specifically concerned about.

-Filip

> On Jan 13, 2015, at 4:21 AM, Anne van Kesteren <annevk at annevk.nl> wrote:
> 
> A big challenge with self-hosting is memory consumption. A JavaScript
> implementation is tied to a realm and therefore each realm will have
> its own implementation. Contrast this with a C++ implementation of the
> same feature that can be shared across many realms. The C++
> implementation is much more efficient.
> 
> If we want to get further with turning the web platform into a giant
> JavaScript library, we need to tackle this somehow.
> 
> Has anyone been thinking about how to do this and what changes it
> would require from JavaScript proper? We're now at the point where we
> can implement platform objects in terms of JavaScript, but JavaScript
> loses out due to lack of efficiency.
> 
> 
> PS: Alternative explanation available here:
> https://annevankesteren.nl/2015/01/javascript-web-platform
> 
> 
> -- 
> https://annevankesteren.nl/
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list