Bug 1466118 part 7 - Avoid a TLS lookup for each compartment check. r=jonco
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 21 Aug 2018 12:58:58 +0200
changeset 488143 1a263d3e088e0cc47b111185579d0d8699b8d190
parent 488142 ff5cb8442b5d452de5677dbacf9bec9df0bf5a83
child 488144 64a85b3753acab5c776f732553139878fdcda1cb
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1466118
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 1466118 part 7 - Avoid a TLS lookup for each compartment check. r=jonco
js/src/jspubtd.h
js/src/vm/JSContext-inl.h
--- a/js/src/jspubtd.h
+++ b/js/src/jspubtd.h
@@ -139,20 +139,25 @@ RuntimeHeapIsMajorCollecting()
 
 static inline bool
 RuntimeHeapIsMinorCollecting()
 {
     return RuntimeHeapState() == HeapState::MinorCollecting;
 }
 
 static inline bool
+RuntimeHeapIsCollecting(HeapState state)
+{
+    return state == HeapState::MajorCollecting || state == HeapState::MinorCollecting;
+}
+
+static inline bool
 RuntimeHeapIsCollecting()
 {
-    HeapState state = RuntimeHeapState();
-    return state == HeapState::MajorCollecting || state == HeapState::MinorCollecting;
+    return RuntimeHeapIsCollecting(RuntimeHeapState());
 }
 
 static inline bool
 RuntimeHeapIsCycleCollecting()
 {
     return RuntimeHeapState() == HeapState::CycleCollecting;
 }
 
--- a/js/src/vm/JSContext-inl.h
+++ b/js/src/vm/JSContext-inl.h
@@ -177,17 +177,17 @@ class ContextChecks
 
 } // namespace js
 
 template <class T1> inline void
 JSContext::checkImpl(int argIndex, const T1& t1)
 {
     // Don't perform these checks when called from a finalizer. The checking
     // depends on other objects not having been swept yet.
-    if (JS::RuntimeHeapIsCollecting())
+    if (JS::RuntimeHeapIsCollecting(runtime()->heapState()))
         return;
     js::ContextChecks(this).check(t1, argIndex);
 }
 
 template <class Head, class... Tail> inline void
 JSContext::checkImpl(int argIndex, const Head& head, const Tail&... tail)
 {
     checkImpl(argIndex, head);