I still have some concerns about our approach for adapting to moving GC. From 
the meeting notes, I see that there are some open concerns about maintaining 
proper handle usage outside the JS engine (and I'm not sure how easy it's going 
to be inside the engine for that matter) and more worrying even, about knowing 
if we've actually gotten it right, given all the cold paths.

Today I was also thinking about compartments, which is a much simpler API, but 
where we are still chasing out compartment bugs, and where JSAPI users are 
still often doing it wrong.

The last consideration is that I always like doing things the "dumb way" if 
possible, and I still don't think I've gotten an answer as to whether or not we 
can do this the dumb way. In my mind, the dumb way goes something like this:

- Take the V8 handle API. We know how it works, and we know it's been used 
successfully. (Plus bonus points for aiming at API compat someday, but that's 
not a primary consideration for what I'm talking about now.)

- Find the pinch points in the engine where we create objects, and make them 
create handles and return the handles instead. Steve pointed out to me that 
it's not quite as easy as that, because we need to cover places where we just 
read gcthing pointers out of the heap. Maybe we can set up all the heap 
pointers to be stored by classes that don't implicitly convert to a raw pointer 
to cover that part.

- Fix all the compiler errors from the previous step by sticking handle types 
where needed. Inspect functions as this is done and add internal handle scopes 
as needed.

- Add a few handle scopes to the shell.

At this point we should have a JS shell that works with moving GC, no? It's 
possible this is all that's required. The biggest risk I see is that perf would 
be bad because of too many handles created internally where not needed. I'm not 
exactly sure how that would play out but I would imagine we'd try to find some 
simple patterns and refactor the code a bit to make it fairly clear and 
maintainable.

Maybe I'm missing something, but it seems like this would work, that using the 
types and compiler checks would obviate most bugs, and it would be a large bulk 
of work but not require anything heroically complex.

Would this work?

Dave
_______________________________________________
dev-tech-js-engine-internals mailing list
dev-tech-js-engine-internals@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to