Backed out changeset 1d50d21da50d (bug 1507721) for spidermonkey bustages on dynamic-import-oom.js.
authorCosmin Sabou <csabou@mozilla.com>
Fri, 16 Nov 2018 22:53:36 +0200
changeset 446837 dad98317fee0ff692f30d6f0c845a9241f0d5de4
parent 446836 988fd6689153a86f6f4410c1d1fe46eaff036afb
child 446838 1b441356e3379ee83c3d564c5a9d8702debfb56b
push id35052
push userapavel@mozilla.com
push dateSat, 17 Nov 2018 11:25:40 +0000
treeherdermozilla-central@efc1da42132b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1507721
milestone65.0a1
backs out1d50d21da50d91de52719decd7bf3e942a9ac89f
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
Backed out changeset 1d50d21da50d (bug 1507721) for spidermonkey bustages on dynamic-import-oom.js.
js/public/Utility.h
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -137,34 +137,32 @@ class FailureSimulator
     enum class Kind : uint8_t { Nothing, OOM, StackOOM, Interrupt };
 
   private:
     Kind kind_ = Kind::Nothing;
     uint32_t targetThread_ = 0;
     uint64_t maxChecks_ = UINT64_MAX;
     uint64_t counter_ = 0;
     bool failAlways_ = true;
-    bool inUnsafeRegion_ = false;
 
   public:
     uint64_t maxChecks() const {
         return maxChecks_;
     }
+    void setMaxChecks(uint64_t value) {
+        maxChecks_ = value;
+    }
     uint64_t counter() const {
         return counter_;
     }
-    void setInUnsafeRegion(bool b) {
-        MOZ_ASSERT(inUnsafeRegion_ != b);
-        inUnsafeRegion_ = b;
-    }
     uint32_t targetThread() const {
         return targetThread_;
     }
     bool isThreadSimulatingAny() const {
-        return targetThread_ && targetThread_ == js::oom::GetThreadType() && !inUnsafeRegion_;
+        return targetThread_ && targetThread_ == js::oom::GetThreadType();
     }
     bool isThreadSimulating(Kind kind) const {
         return kind_ == kind && isThreadSimulatingAny();
     }
     bool isSimulatedFailure(Kind kind) const {
         if (!isThreadSimulating(kind)) {
             return false;
         }
@@ -316,36 +314,45 @@ struct MOZ_RAII JS_PUBLIC_DATA(AutoEnter
     using AnnotateOOMAllocationSizeCallback = void(*)(size_t);
     static AnnotateOOMAllocationSizeCallback annotateOOMSizeCallback;
     static void setAnnotateOOMAllocationSizeCallback(AnnotateOOMAllocationSizeCallback callback) {
         annotateOOMSizeCallback = callback;
     }
 
 #if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
     AutoEnterOOMUnsafeRegion()
-      : oomEnabled_(oom::simulator.isThreadSimulatingAny())
+      : oomEnabled_(oom::simulator.isThreadSimulatingAny() &&
+                    oom::simulator.maxChecks() != UINT64_MAX),
+        oomAfter_(0)
     {
         if (oomEnabled_) {
             MOZ_ALWAYS_TRUE(owner_.compareExchange(nullptr, this));
-            oom::simulator.setInUnsafeRegion(true);
+            oomAfter_ = (int64_t(oom::simulator.maxChecks()) -
+                         int64_t(oom::simulator.counter()));
+            oom::simulator.setMaxChecks(UINT64_MAX);
         }
     }
 
     ~AutoEnterOOMUnsafeRegion() {
         if (oomEnabled_) {
-            oom::simulator.setInUnsafeRegion(false);
+            MOZ_ASSERT(oom::simulator.maxChecks() == UINT64_MAX);
+            int64_t maxChecks = int64_t(oom::simulator.counter()) + oomAfter_;
+            MOZ_ASSERT(maxChecks >= 0,
+                       "alloc count + oom limit exceeds range, your oom limit is probably too large");
+            oom::simulator.setMaxChecks(maxChecks);
             MOZ_ALWAYS_TRUE(owner_.compareExchange(this, nullptr));
         }
     }
 
   private:
     // Used to catch concurrent use from other threads.
     static mozilla::Atomic<AutoEnterOOMUnsafeRegion*> owner_;
 
     bool oomEnabled_;
+    int64_t oomAfter_;
 #endif
 };
 
 } /* namespace js */
 
 // Malloc allocation.
 
 namespace js {