Closed Bug 621205 Opened 13 years ago Closed 13 years ago

add something single-threaded and shared between compartments ("zones")

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 649537

People

(Reporter: luke, Unassigned)

Details

The issue has come up several times that we want to have some data structure shared by compartments, and we could *almost* use the JSThreadData, but we can't because sometimes compartments can and do hop between threads and thus have no constant associativity with a single JSThreadData.  This is discussed more in bug 587288 comments 8 - 12.  It just came up again in bug 621032 in the context of moving the mathCache out of JSThreadData.  Although there are good enough alternate solutions atm, I get the feeling that the absence of such a 'zone' (or a re-purposed JSThreadData) will keep coming back to bug us.

For the moment I'm just filing to collect related concerns.
Another place this could help is bug 611589.
As long as we would allow to move a single compartment between threads using zone would not be different from using JSThredData as the jited code would not be able to embed the pointer directly and would need to do some level of indirection.

Currently such indirection requires two extra loads of going through cx->thread->. It hurts. On the other hand if we consider merging JSContext and JSThread so JSContext would be used purely as holder of thread-local data then we would have only single indirection.

As for lockless atoms a solution could be to replace an ordinary hashtable with similar data structure but that allows to have a shared immutable part.
(In reply to comment #2)
> As long as we would allow to move a single compartment between threads using
> zone would not be different from using JSThredData as the jited code would not
> be able to embed the pointer directly and would need to do some level of
> indirection.

I think you have missed the definition of zone, as described, e.g., in bug 587277 comment 11: the (few) compartments that do actually want to bounce between threads would have their own zone that "followed" them.  (OTOH, all the compartments that stayed on the FF main thread could all share a zone.)  Regardless, zones would, by construction, avoid the indirections you speak of.
Summary: add something single-threaded and shared between compartments → add something single-threaded and shared between compartments ("zones")
Hey j/k, JSRuntime is becoming single-threaded!
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.