Re: Sharing a JavaScript implementation across realms

2015-01-14 Thread Filip Pizlo
I can provide some insight on this from JSC’s innards. A realm ain’t free but it is lightweight enough that we don’t really sweat creating them. It’s an object with some prototypes hanging off of it, most of which can be reified lazily if you’re paranoid about their overhead. They incur some

Re: Sharing a JavaScript implementation across realms

2015-01-14 Thread Anne van Kesteren
On Wed, Jan 14, 2015 at 1:28 AM, Brendan Eich bren...@mozilla.org wrote: Before we go tl;dr on this topic, how about some data to back up the asserted problem size? Filip gently raised the question. How much memory does a realm cost in top open source engines? Fair question, empirical and (I

RE: Sharing a JavaScript implementation across realms

2015-01-13 Thread Gary Guo
I don't think there is any difference in self-hosting JavaScript or JS-engine in C++. For example, use the example case `Array.prototype.map`, in C++, we could code a native function and create a corresponding object for each realm (note that the only shared part is the native function). In

Re: Sharing a JavaScript implementation across realms

2015-01-13 Thread Mark S. Miller
On Tue, Jan 13, 2015 at 4:21 AM, Anne van Kesteren ann...@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

Re: Sharing a JavaScript implementation across realms

2015-01-13 Thread David Bruant
Le 13/01/2015 13:21, Anne van Kesteren a écrit : 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

Re: Sharing a JavaScript implementation across realms

2015-01-13 Thread Brendan Eich
Before we go tl;dr on this topic, how about some data to back up the asserted problem size? Filip gently raised the question. How much memory does a realm cost in top open source engines? Fair question, empirical and (I think) not hard to answer. Burdened malloc/GC heap full cost, not net

Sharing a JavaScript implementation across realms

2015-01-13 Thread Anne van Kesteren
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

Re: Sharing a JavaScript implementation across realms

2015-01-13 Thread Filip Pizlo
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