Bug 1084651 - Part 3: Tighten up the bounds of SliceBudget to work as a budget should. r=wmccloskey
☠☠ backed out by 3ad6929d9571 ☠ ☠
authorEmanuel Hoogeveen <emanuel.hoogeveen@gmail.com>
Tue, 04 Nov 2014 07:34:00 +0100
changeset 214094 78102b62a4a0d7be4bed363ba8a5f5ea3938d2d9
parent 214093 06387a2343a07c20c5d257b0391290fdf2e5133e
child 214095 d36f6dbbf92524b670df77a75a3427441c097dbc
push id27771
push userryanvm@gmail.com
push dateWed, 05 Nov 2014 19:04:24 +0000
treeherdermozilla-central@305b4fecce99 [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)
 {