Bug 1486125 - Remove JSContext::noGCOrAllocationCheck and its helper methods. r=jonco
authorDiego Pino Garcia <dpino@igalia.com>
Mon, 03 Sep 2018 03:20:00 +0300
changeset 434677 5e99f6ed6c2fb16ee861a5534d14dcde2e4a2573
parent 434676 f7d509458e63f9cc004ed8d7c702a23a9e752b1a
child 434678 77566fd9183f35f373a6225f638c5e71ecfc0923
push id34573
push userbtara@mozilla.com
push dateTue, 04 Sep 2018 23:24:58 +0000
treeherdermozilla-central@5b55659fa99f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1486125
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1486125 - Remove JSContext::noGCOrAllocationCheck and its helper methods. r=jonco
js/src/gc/Allocator.cpp
js/src/gc/GC.cpp
js/src/vm/BytecodeUtil.cpp
js/src/vm/JSContext.cpp
js/src/vm/JSContext.h
--- a/js/src/gc/Allocator.cpp
+++ b/js/src/gc/Allocator.cpp
@@ -286,17 +286,16 @@ GCRuntime::checkAllocatorState(JSContext
                   kind == AllocKind::FAT_INLINE_ATOM ||
                   kind == AllocKind::SYMBOL ||
                   kind == AllocKind::JITCODE ||
                   kind == AllocKind::SCOPE);
     MOZ_ASSERT_IF(!cx->zone()->isAtomsZone(),
                   kind != AllocKind::ATOM &&
                   kind != AllocKind::FAT_INLINE_ATOM);
     MOZ_ASSERT(!JS::RuntimeHeapIsBusy());
-    MOZ_ASSERT(cx->isAllocAllowed());
 #endif
 
     // Crash if we perform a GC action when it is not safe.
     if (allowGC && !cx->suppressGC)
         cx->verifyIsSafeToGC();
 
     // For testing out of memory conditions
     if (js::oom::ShouldFailWithOOM()) {
--- a/js/src/gc/GC.cpp
+++ b/js/src/gc/GC.cpp
@@ -7684,18 +7684,16 @@ GCRuntime::maybeDoCycleCollection()
 
 void
 GCRuntime::checkCanCallAPI()
 {
     MOZ_RELEASE_ASSERT(CurrentThreadCanAccessRuntime(rt));
 
     /* If we attempt to invoke the GC while we are running in the GC, assert. */
     MOZ_RELEASE_ASSERT(!JS::RuntimeHeapIsBusy());
-
-    MOZ_ASSERT(rt->mainContextFromOwnThread()->isAllocAllowed());
 }
 
 bool
 GCRuntime::checkIfGCAllowedInCurrentState(JS::gcreason::Reason reason)
 {
     if (rt->mainContextFromOwnThread()->suppressGC)
         return false;
 
--- a/js/src/vm/BytecodeUtil.cpp
+++ b/js/src/vm/BytecodeUtil.cpp
@@ -1145,21 +1145,17 @@ ToDisassemblySource(JSContext* cx, Handl
         if (!copy) {
             ReportOutOfMemory(cx);
             return false;
         }
         bytes->initBytes(std::move(copy));
         return true;
     }
 
-    if (JS::RuntimeHeapIsBusy()
-#ifdef DEBUG
-        || !cx->isAllocAllowed()
-#endif
-        ) {
+    if (JS::RuntimeHeapIsBusy()) {
         UniqueChars source = JS_smprintf("<value>");
         if (!source) {
             ReportOutOfMemory(cx);
             return false;
         }
         bytes->initBytes(std::move(source));
         return true;
     }
--- a/js/src/vm/JSContext.cpp
+++ b/js/src/vm/JSContext.cpp
@@ -1288,17 +1288,16 @@ JSContext::JSContext(JSRuntime* runtime,
     suppressGC(0),
 #ifdef DEBUG
     ionCompiling(false),
     ionCompilingSafeForMinorGC(false),
     performingGC(false),
     gcSweeping(false),
     gcHelperStateThread(false),
     isTouchingGrayThings(false),
-    noGCOrAllocationCheck(0),
     noNurseryAllocationCheck(0),
     disableStrictProxyCheckingCount(0),
 #endif
 #if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
     runningOOMTest(false),
 #endif
     enableAccessValidation(false),
     inUnsafeRegion(0),
--- a/js/src/vm/JSContext.h
+++ b/js/src/vm/JSContext.h
@@ -539,34 +539,26 @@ struct JSContext : public JS::RootingCon
 
     // Whether this thread is performing work in the background for a runtime's
     // GCHelperState.
     js::ThreadData<bool> gcHelperStateThread;
 
     // Whether this thread is currently manipulating possibly-gray GC things.
     js::ThreadData<size_t> isTouchingGrayThings;
 
-    js::ThreadData<size_t> noGCOrAllocationCheck;
     js::ThreadData<size_t> noNurseryAllocationCheck;
 
     /*
      * If this is 0, all cross-compartment proxies must be registered in the
      * wrapper map. This checking must be disabled temporarily while creating
      * new wrappers. When non-zero, this records the recursion depth of wrapper
      * creation.
      */
     js::ThreadData<uintptr_t> disableStrictProxyCheckingCount;
 
-    bool isAllocAllowed() { return noGCOrAllocationCheck == 0; }
-    void disallowAlloc() { ++noGCOrAllocationCheck; }
-    void allowAlloc() {
-        MOZ_ASSERT(!isAllocAllowed());
-        --noGCOrAllocationCheck;
-    }
-
     bool isNurseryAllocAllowed() { return noNurseryAllocationCheck == 0; }
     void disallowNurseryAlloc() { ++noNurseryAllocationCheck; }
     void allowNurseryAlloc() {
         MOZ_ASSERT(!isNurseryAllocAllowed());
         --noNurseryAllocationCheck;
     }
 
     bool isStrictProxyCheckingEnabled() { return disableStrictProxyCheckingCount == 0; }