Bug 1303399 part 3 - Remove resume points from the basic block list when we OOM. r=h4writer
authorNicolas B. Pierron <nicolas.b.pierron@mozilla.com>
Fri, 28 Oct 2016 12:45:32 +0000
changeset 320002 726ec9c83018397c0617eb25f71dde6e383b5ec3
parent 320001 47e4fb57325d0766abbe7dd6260d339cb1e8f20f
child 320003 355c7ec8b68e965787e18517eeef2a693434992a
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersh4writer
bugs1303399
milestone52.0a1
Bug 1303399 part 3 - Remove resume points from the basic block list when we OOM. r=h4writer
js/src/jit/FixedList.h
js/src/jit/IonBuilder.cpp
js/src/jit/MIR.cpp
--- a/js/src/jit/FixedList.h
+++ b/js/src/jit/FixedList.h
@@ -28,25 +28,28 @@ class FixedList
 
   public:
     FixedList()
       : list_(nullptr), length_(0)
     { }
 
     // Dynamic memory allocation requires the ability to report failure.
     MOZ_MUST_USE bool init(TempAllocator& alloc, size_t length) {
-        length_ = length;
         if (length == 0)
             return true;
 
         size_t bytes;
         if (MOZ_UNLIKELY(!CalculateAllocSize<T>(length, &bytes)))
             return false;
         list_ = (T*)alloc.allocate(bytes);
-        return list_ != nullptr;
+        if (!list_)
+            return false;
+
+        length_ = length;
+        return true;
     }
 
     size_t empty() const {
         return length_ == 0;
     }
 
     size_t length() const {
         return length_;
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -8060,18 +8060,20 @@ IonBuilder::newTest(MDefinition* ins, MB
 // register/stack assignments for every live value.
 bool
 IonBuilder::resume(MInstruction* ins, jsbytecode* pc, MResumePoint::Mode mode)
 {
     MOZ_ASSERT(ins->isEffectful() || !ins->isMovable());
 
     MResumePoint* resumePoint = MResumePoint::New(alloc(), ins->block(), pc,
                                                   mode);
-    if (!resumePoint)
-        return false;
+    if (!resumePoint) {
+        abortReason_ = AbortReason_Alloc;
+        return false;
+    }
     ins->setResumePoint(resumePoint);
     return true;
 }
 
 bool
 IonBuilder::resumeAt(MInstruction* ins, jsbytecode* pc)
 {
     return resume(ins, pc, MResumePoint::ResumeAt);
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -3967,50 +3967,56 @@ MUrsh::NewAsmJS(TempAllocator& alloc, MD
     return ins;
 }
 
 MResumePoint*
 MResumePoint::New(TempAllocator& alloc, MBasicBlock* block, jsbytecode* pc,
                   Mode mode)
 {
     MResumePoint* resume = new(alloc) MResumePoint(block, pc, mode);
-    if (!resume->init(alloc))
+    if (!resume->init(alloc)) {
+        block->discardPreAllocatedResumePoint(resume);
         return nullptr;
+    }
     resume->inherit(block);
     return resume;
 }
 
 MResumePoint*
 MResumePoint::New(TempAllocator& alloc, MBasicBlock* block, MResumePoint* model,
                   const MDefinitionVector& operands)
 {
     MResumePoint* resume = new(alloc) MResumePoint(block, model->pc(), model->mode());
 
     // Allocate the same number of operands as the original resume point, and
     // copy operands from the operands vector and not the not from the current
     // block stack.
-    if (!resume->operands_.init(alloc, model->numAllocatedOperands()))
+    if (!resume->operands_.init(alloc, model->numAllocatedOperands())) {
+        block->discardPreAllocatedResumePoint(resume);
         return nullptr;
+    }
 
     // Copy the operands.
     for (size_t i = 0; i < operands.length(); i++)
         resume->initOperand(i, operands[i]);
 
     return resume;
 }
 
 MResumePoint*
 MResumePoint::Copy(TempAllocator& alloc, MResumePoint* src)
 {
     MResumePoint* resume = new(alloc) MResumePoint(src->block(), src->pc(),
                                                    src->mode());
     // Copy the operands from the original resume point, and not from the
     // current block stack.
-    if (!resume->operands_.init(alloc, src->numAllocatedOperands()))
+    if (!resume->operands_.init(alloc, src->numAllocatedOperands())) {
+        src->block()->discardPreAllocatedResumePoint(resume);
         return nullptr;
+    }
 
     // Copy the operands.
     for (size_t i = 0; i < resume->numOperands(); i++)
         resume->initOperand(i, src->getOperand(i));
     return resume;
 }
 
 MResumePoint::MResumePoint(MBasicBlock* block, jsbytecode* pc, Mode mode)