Bug 991336 - Improve checking around CompileInfo sweep indexes, r=jandem.
authorBrian Hackett <bhackett1024@gmail.com>
Fri, 11 Apr 2014 17:25:34 -0600
changeset 196736 f74e5c06388342709b586a6a3616c56014c5bfbd
parent 196735 c2ab932f4d41f4bea2c20f6cb84806a55eae65a1
child 196737 33f2921dce72c2f398ee448adaa85f3cefa9ca68
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs991336
milestone31.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 991336 - Improve checking around CompileInfo sweep indexes, r=jandem.
js/src/jsinfer.cpp
js/src/jsinfer.h
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -4359,17 +4359,17 @@ TypeZone::sweep(FreeOp *fop, bool releas
     }
 
     if (compilerOutputs) {
         size_t sweepIndex = 0;
         for (size_t i = 0; i < compilerOutputs->length(); i++) {
             CompilerOutput output = (*compilerOutputs)[i];
             if (output.isValid()) {
                 JS_ASSERT(sweepIndex == output.sweepIndex());
-                output.setSweepIndex(0);
+                output.invalidateSweepIndex();
                 (*compilerOutputs)[sweepIndex++] = output;
             }
         }
         JS_ASSERT(sweepIndex == newCompilerOutputCount);
         JS_ALWAYS_TRUE(compilerOutputs->resize(newCompilerOutputCount));
     }
 
     {
--- a/js/src/jsinfer.h
+++ b/js/src/jsinfer.h
@@ -1426,22 +1426,26 @@ class CompilerOutput
     // Whether this compilation is about to be invalidated.
     bool pendingInvalidation_ : 1;
 
     // During sweeping, the list of compiler outputs is compacted and invalidated
     // outputs are removed. This gives the new index for a valid compiler output.
     uint32_t sweepIndex_ : 29;
 
   public:
+    static const uint32_t INVALID_SWEEP_INDEX = (1 << 29) - 1;
+
     CompilerOutput()
-      : script_(nullptr), mode_(SequentialExecution), pendingInvalidation_(false)
+      : script_(nullptr), mode_(SequentialExecution),
+        pendingInvalidation_(false), sweepIndex_(INVALID_SWEEP_INDEX)
     {}
 
     CompilerOutput(JSScript *script, ExecutionMode mode)
-      : script_(script), mode_(mode), pendingInvalidation_(false)
+      : script_(script), mode_(mode),
+        pendingInvalidation_(false), sweepIndex_(INVALID_SWEEP_INDEX)
     {}
 
     JSScript *script() const { return script_; }
     inline ExecutionMode mode() const { return mode_; }
 
     inline jit::IonScript *ion() const;
 
     bool isValid() const {
@@ -1454,21 +1458,25 @@ class CompilerOutput
     void setPendingInvalidation() {
         pendingInvalidation_ = true;
     }
     bool pendingInvalidation() {
         return pendingInvalidation_;
     }
 
     void setSweepIndex(uint32_t index) {
-        if (index >= 1 << 29)
+        if (index >= INVALID_SWEEP_INDEX)
             MOZ_CRASH();
         sweepIndex_ = index;
     }
+    void invalidateSweepIndex() {
+        sweepIndex_ = INVALID_SWEEP_INDEX;
+    }
     uint32_t sweepIndex() {
+        JS_ASSERT(sweepIndex_ != INVALID_SWEEP_INDEX);
         return sweepIndex_;
     }
 };
 
 class RecompileInfo
 {
     uint32_t outputIndex;