Bug 1084651 - Part 3: Tighten up the bounds of SliceBudget to work as a budget should. r=wmccloskey
☠☠ backed out by bb67cf33bad8 ☠ ☠
authorEmanuel Hoogeveen <emanuel.hoogeveen@gmail.com>
Tue, 04 Nov 2014 07:34:00 +0100
changeset 238875 b34ff39fc966b410365bde97be83f5669099c875
parent 238874 ebdebc9251be6e51419036f8580e7df511077a78
child 238876 94197c33cf824dbd9e6a15a49cb8dd105c646f42
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswmccloskey
bugs1084651
milestone36.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 1084651 - Part 3: Tighten up the bounds of SliceBudget to work as a budget should. r=wmccloskey
js/public/SliceBudget.h
js/src/jsgc.cpp
--- a/js/public/SliceBudget.h
+++ b/js/public/SliceBudget.h
@@ -33,17 +33,17 @@ struct JS_PUBLIC_API(WorkBudget)
  */
 struct JS_PUBLIC_API(SliceBudget)
 {
     int64_t deadline; /* in microseconds */
     intptr_t counter;
 
     static const intptr_t CounterReset = 1000;
 
-    static const int64_t Unlimited = 0;
+    static const int64_t Unlimited = -1;
 
     /* Use to create an unlimited budget. */
     SliceBudget();
 
     /* Instantiate as SliceBudget(TimeBudget(n)). */
     explicit SliceBudget(TimeBudget time);
 
     /* Instantiate as SliceBudget(WorkBudget(n)). */
@@ -54,17 +54,17 @@ struct JS_PUBLIC_API(SliceBudget)
         counter = unlimitedStartCounter;
     }
 
     void step(intptr_t amt = 1) {
         counter -= amt;
     }
 
     bool isOverBudget() {
-        if (counter >= 0)
+        if (counter > 0)
             return false;
         return checkOverBudget();
     }
 
     bool isUnlimited() {
         return deadline == unlimitedDeadline;
     }
 
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -1452,17 +1452,17 @@ js::gc::FinishPersistentRootedChains(JSR
 void
 GCRuntime::setParameter(JSGCParamKey key, uint32_t value)
 {
     switch (key) {
       case JSGC_MAX_MALLOC_BYTES:
         setMaxMallocBytes(value);
         break;
       case JSGC_SLICE_TIME_BUDGET:
-        sliceBudget = value;
+        sliceBudget = value ? value : SliceBudget::Unlimited;
         break;
       case JSGC_MARK_STACK_LIMIT:
         setMarkStackLimit(value);
         break;
       case JSGC_DECOMMIT_THRESHOLD:
         decommitThreshold = value * 1024 * 1024;
         break;
       case JSGC_MODE:
@@ -2932,34 +2932,39 @@ GCRuntime::refillFreeListInGC(Zone *zone
 
 SliceBudget::SliceBudget()
 {
     reset();
 }
 
 SliceBudget::SliceBudget(TimeBudget time)
 {
-    if (time.budget == Unlimited) {
+    if (time.budget < 0) {
         reset();
     } else {
+        // Note: TimeBudget(0) is equivalent to WorkBudget(CounterReset).
         deadline = PRMJ_Now() + time.budget * PRMJ_USEC_PER_MSEC;
         counter = CounterReset;
     }
 }
 
 SliceBudget::SliceBudget(WorkBudget work)
 {
-    deadline = 0;
-    counter = work.budget;
+    if (work.budget < 0) {
+        reset();
+    } else {
+        deadline = 0;
+        counter = work.budget;
+    }
 }
 
 bool
 SliceBudget::checkOverBudget()
 {
-    bool over = PRMJ_Now() > deadline;
+    bool over = PRMJ_Now() >= deadline;
     if (!over)
         counter = CounterReset;
     return over;
 }
 
 void
 js::MarkCompartmentActive(InterpreterFrame *fp)
 {