Bug 1130226 - Part 1: Rename gcIfNeeded to gcIfRequested; r=sfink
authorTerrence Cole <terrence@mozilla.com>
Thu, 05 Feb 2015 17:41:35 -0800
changeset 241802 ac3e4d79297c71c1378855bfa362940acb602147
parent 241801 18240dad751f9e2302acacf5eb6a06f006ca0453
child 241803 02b800e34f0f8b914c1be27d32bfeac4566fcc0c
push id619
push usercliu@mozilla.com
push dateMon, 09 Feb 2015 21:57:21 +0000
reviewerssfink
bugs1130226
milestone38.0a1
Bug 1130226 - Part 1: Rename gcIfNeeded to gcIfRequested; r=sfink
js/src/gc/GCRuntime.h
js/src/jscntxt.h
js/src/jsgc.cpp
js/src/jsgcinlines.h
js/src/vm/Interpreter.cpp
js/src/vm/Runtime.cpp
--- a/js/src/gc/GCRuntime.h
+++ b/js/src/gc/GCRuntime.h
@@ -597,17 +597,17 @@ class GCRuntime
         gcstats::AutoPhase ap(stats, gcstats::PHASE_MINOR_GC);
         minorGCImpl(reason, nullptr);
     }
     void minorGC(JSContext *cx, JS::gcreason::Reason reason);
     void evictNursery(JS::gcreason::Reason reason = JS::gcreason::EVICT_NURSERY) {
         gcstats::AutoPhase ap(stats, gcstats::PHASE_EVICT_NURSERY);
         minorGCImpl(reason, nullptr);
     }
-    bool gcIfNeeded(JSContext *cx = nullptr);
+    bool gcIfRequested(JSContext *cx = nullptr);
     void gc(JSGCInvocationKind gckind, JS::gcreason::Reason reason);
     void startGC(JSGCInvocationKind gckind, JS::gcreason::Reason reason, int64_t millis = 0);
     void gcSlice(JS::gcreason::Reason reason, int64_t millis = 0);
     void finishGC(JS::gcreason::Reason reason);
     void startDebugGC(JSGCInvocationKind gckind, SliceBudget &budget);
     void debugGCSlice(SliceBudget &budget);
 
     void runDebugGC();
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -462,20 +462,16 @@ struct JSContext : public js::ExclusiveC
     inline js::Nursery &nursery() {
         return runtime_->gc.nursery;
     }
 
     void minorGC(JS::gcreason::Reason reason) {
         runtime_->gc.minorGC(this, reason);
     }
 
-    void gcIfNeeded() {
-        runtime_->gc.gcIfNeeded(this);
-    }
-
   public:
     bool isExceptionPending() {
         return throwing;
     }
 
     MOZ_WARN_UNUSED_RESULT
     bool getPendingException(JS::MutableHandleValue rval);
 
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -3208,17 +3208,17 @@ GCRuntime::maybeGC(Zone *zone)
 #ifdef JS_GC_ZEAL
     if (zealMode == ZealAllocValue || zealMode == ZealPokeValue) {
         JS::PrepareForFullGC(rt);
         gc(GC_NORMAL, JS::gcreason::MAYBEGC);
         return true;
     }
 #endif
 
-    if (gcIfNeeded())
+    if (gcIfRequested())
         return true;
 
     if (zone->usage.gcBytes() > 1024 * 1024 &&
         zone->threshold.isCloseToAllocTrigger(zone->usage, schedulingState.inHighFrequencyGCMode()) &&
         !isIncrementalGCInProgress() &&
         !isBackgroundSweeping())
     {
         PrepareZoneForGC(zone);
@@ -6413,17 +6413,17 @@ GCRuntime::enableGenerationalGC()
     --generationalDisabled;
     if (generationalDisabled == 0) {
         nursery.enable();
         storeBuffer.enable();
     }
 }
 
 bool
-GCRuntime::gcIfNeeded(JSContext *cx /* = nullptr */)
+GCRuntime::gcIfRequested(JSContext *cx /* = nullptr */)
 {
     // This method returns whether a major GC was performed.
 
     if (minorGCRequested()) {
         if (cx)
             minorGC(cx, minorGCTriggerReason);
         else
             minorGC(minorGCTriggerReason);
--- a/js/src/jsgcinlines.h
+++ b/js/src/jsgcinlines.h
@@ -445,17 +445,17 @@ CheckAllocatorState(ExclusiveContext *cx
 #ifdef JS_GC_ZEAL
         if (rt->gc.needZealousGC())
             rt->gc.runDebugGC();
 #endif
 
         if (rt->hasPendingInterrupt()) {
             // Invoking the interrupt callback can fail and we can't usefully
             // handle that here. Just check in case we need to collect instead.
-            ncx->gcIfNeeded();
+            rt->gc.gcIfRequested();
         }
     }
 
     return true;
 }
 
 template <typename T>
 static inline void
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -436,37 +436,37 @@ js::RunScript(JSContext *cx, RunState &s
     if (state.isInvoke()) {
         InvokeState &invoke = *state.asInvoke();
         TypeMonitorCall(cx, invoke.args(), invoke.constructing());
     }
 
     return Interpret(cx, state);
 }
 
-struct AutoGCIfNeeded
+struct AutoGCIfRequested
 {
-    JSContext *cx_;
-    explicit AutoGCIfNeeded(JSContext *cx) : cx_(cx) {}
-    ~AutoGCIfNeeded() { cx_->gcIfNeeded(); }
+    JSRuntime *runtime;
+    explicit AutoGCIfRequested(JSRuntime *rt) : runtime(rt) {}
+    ~AutoGCIfRequested() { runtime->gc.gcIfRequested(); }
 };
 
 /*
  * Find a function reference and its 'this' value implicit first parameter
  * under argc arguments on cx's stack, and call the function.  Push missing
  * required arguments, allocate declared local variables, and pop everything
  * when done.  Then push the return value.
  */
 bool
 js::Invoke(JSContext *cx, CallArgs args, MaybeConstruct construct)
 {
     MOZ_ASSERT(args.length() <= ARGS_LENGTH_MAX);
     MOZ_ASSERT(!cx->zone()->types.activeAnalysis);
 
     /* Perform GC if necessary on exit from the function. */
-    AutoGCIfNeeded gcIfNeeded(cx);
+    AutoGCIfRequested gcIfRequested(cx->runtime());
 
     /* MaybeConstruct is a subset of InitialFrameFlags */
     InitialFrameFlags initial = (InitialFrameFlags) construct;
 
     if (args.calleev().isPrimitive())
         return ReportIsNotFunction(cx, args.calleev(), args.length() + 1, construct);
 
     const Class *clasp = args.callee().getClass();
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -520,17 +520,17 @@ JSRuntime::addSizeOfIncludingThis(mozill
     gc.storeBuffer.addSizeOfExcludingThis(mallocSizeOf, &rtSizes->gc);
 }
 
 static bool
 InvokeInterruptCallback(JSContext *cx)
 {
     MOZ_ASSERT(cx->runtime()->requestDepth >= 1);
 
-    cx->gcIfNeeded();
+    cx->runtime()->gc.gcIfRequested();
 
     // A worker thread may have requested an interrupt after finishing an Ion
     // compilation.
     jit::AttachFinishedCompilations(cx);
 
     // Important: Additional callbacks can occur inside the callback handler
     // if it re-enters the JS engine. The embedding must ensure that the
     // callback is disconnected before attempting such re-entry.