Is only one JSContext allowed per thread in JS 76?
Miles <[email protected]> Fri, 26 Jun 2020 00:38:03 -0700 (PDT)
| Newsgroups | gmane.comp.mozilla.devel.jseng |
|---|---|
| Message-ID | <[email protected]> |
Hi, A quick question if I may... Am I correct in thinking that only one JSContext is allowed per thread in JS 76 (even if it is the main thread)? I'm assuming that this must be the case as in js::NewContext pretty much the first thing it checks is MOZ_RELEASE_ASSERT(!TlsContext.get()); and this asserts on a debug build if I try to create a second context. In the older releases you used to be able to have a single JSRuntime but multiple JSContexts on a single thread and we made use of that. Each 'script' had its own Context but they were all running concurrently on a single thread. My (no doubt incorrect) understanding was that back then Spidermonkey could be built 'threadsafe' so that was OK. I thought that threadsafe builds were the default in newer releases though. Only being able to have a single Context per thread seems to be a backward step to me and it's going to be a massive problem for our embedding. What was the rationale behind requiring it and do I have any alternatives other than making each Context a separate thread? Many thanks Miles