Skip to content

Commit

Permalink
Bug 1344315 - Suppress protected data checks when handing off runtime…
Browse files Browse the repository at this point in the history
…s between cooperative threads, r=jandem.
  • Loading branch information
bhackett1024 committed Mar 8, 2017
1 parent 76e31e6 commit 6cbc15a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions js/src/jit-test/tests/basic/bug1344315.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if (helperThreadCount() === 0)
quit();
evalInCooperativeThread('cooperativeYield(); var dbg = new Debugger();');
7 changes: 7 additions & 0 deletions js/src/vm/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,13 @@ JSRuntime::destroyRuntime()
static void
CheckCanChangeActiveContext(JSRuntime* rt)
{
// The runtime might not currently have an active context, in which case
// the accesses below to ActiveThreadData data would not normally be
// allowed. Suppress protected data checks so these accesses will be
// tolerated --- if the active context is null then we're about to set it
// to the current thread.
AutoNoteSingleThreadedRegion anstr;

MOZ_RELEASE_ASSERT(!rt->activeContextChangeProhibited());
MOZ_RELEASE_ASSERT(!rt->activeContext() || rt->gc.canChangeActiveContext(rt->activeContext()));

Expand Down
4 changes: 2 additions & 2 deletions js/src/vm/Runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,11 @@ struct JSRuntime : public js::MallocProvider<JSRuntime>
js::ActiveThreadData<js::Vector<js::CooperatingContext, 4, js::SystemAllocPolicy>> cooperatingContexts_;

// Count of AutoProhibitActiveContextChange instances on the active context.
mozilla::Atomic<size_t> activeContextChangeProhibited_;
js::ActiveThreadData<size_t> activeContextChangeProhibited_;

// Count of beginSingleThreadedExecution() calls that have occurred with no
// matching endSingleThreadedExecution().
mozilla::Atomic<size_t> singleThreadedExecutionRequired_;
js::ActiveThreadData<size_t> singleThreadedExecutionRequired_;

// Whether some thread has called beginSingleThreadedExecution() and we are
// in the associated callback (which may execute JS on other threads).
Expand Down

0 comments on commit 6cbc15a

Please sign in to comment.