Bug 1277174 - Forbid nursery allocations within AutoAssertEmptyNursery. r=jonco, a=lizzard
authorSteve Fink <sfink@mozilla.com>
Fri, 03 Jun 2016 13:09:11 -0700
changeset 339725 cc3136982962e8a6b95a1e11ded669b521023299
parent 339724 d716ca3a2025c636ad704b8613cbcebc4a438192
child 339726 7cb944f2d37f09ddfcfcecbfd8cb89486b7039a3
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco, lizzard
bugs1277174
milestone49.0a2
Bug 1277174 - Forbid nursery allocations within AutoAssertEmptyNursery. r=jonco, a=lizzard MozReview-Commit-ID: BY3ZQt9ax6a
js/src/jsgc.cpp
js/src/jsgc.h
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -7630,16 +7630,18 @@ void
 AutoAssertHeapBusy::checkCondition(JSRuntime *rt)
 {
     this->rt = rt;
     MOZ_ASSERT(rt->isHeapBusy());
 }
 
 void
 AutoAssertEmptyNursery::checkCondition(JSRuntime *rt) {
+    if (!noAlloc)
+        noAlloc.emplace(rt);
     this->rt = rt;
     MOZ_ASSERT(rt->gc.nursery.isEmpty());
 }
 
 AutoEmptyNursery::AutoEmptyNursery(JSRuntime *rt)
   : AutoAssertEmptyNursery()
 {
     MOZ_ASSERT(!rt->mainThread.suppressGC);
--- a/js/src/jsgc.h
+++ b/js/src/jsgc.h
@@ -1380,30 +1380,32 @@ class MOZ_RAII AutoAssertHeapBusy {
  * busy (which is not necessarily linked, but turns out to be true in practice
  * for all users and simplifies the usage of these classes.)
  */
 class MOZ_RAII AutoAssertEmptyNursery
 {
   protected:
     JSRuntime* rt;
 
+    mozilla::Maybe<AutoAssertNoNurseryAlloc> noAlloc;
+
     // Check that the nursery is empty.
     void checkCondition(JSRuntime *rt);
 
     // For subclasses that need to empty the nursery in their constructors.
     AutoAssertEmptyNursery() : rt(nullptr) {
     }
 
   public:
-    explicit AutoAssertEmptyNursery(JSRuntime* rt) {
+    explicit AutoAssertEmptyNursery(JSRuntime* rt) : rt(nullptr) {
         checkCondition(rt);
     }
 
-    ~AutoAssertEmptyNursery() {
-        checkCondition(rt);
+    AutoAssertEmptyNursery(const AutoAssertEmptyNursery& other) : AutoAssertEmptyNursery(other.rt)
+    {
     }
 };
 
 /*
  * Evict the nursery upon construction. Serves as a token indicating that the
  * nursery is empty. (See AutoAssertEmptyNursery, above.)
  *
  * Note that this is very improper subclass of AutoAssertHeapBusy, in that the