Bug 948023 - Refactor ReconstructStackDepth to handle OOMs. r=jandem, a=lsblakk
authorChristian Holler <choller@mozilla.com>
Tue, 10 Dec 2013 12:27:21 +0100
changeset 174303 c6eb37cebcd9e985507cda1ef33eefab1156fa61
parent 174302 8f29c6506b23f71107507619038ad9dd39a17662
child 174304 143420a8de2c77d5f789e56ecdfbf03a6d3634e2
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem, lsblakk
bugs948023
milestone28.0a2
Bug 948023 - Refactor ReconstructStackDepth to handle OOMs. r=jandem, a=lsblakk
js/src/jit/BaselineBailouts.cpp
js/src/jit/shared/CodeGenerator-shared.cpp
js/src/jsopcode.cpp
js/src/jsopcode.h
--- a/js/src/jit/BaselineBailouts.cpp
+++ b/js/src/jit/BaselineBailouts.cpp
@@ -791,17 +791,21 @@ InitFromBailout(JSContext *cx, HandleScr
     }
 
     uint32_t pcOff = script->pcToOffset(pc);
     bool isCall = IsCallPC(pc);
     BaselineScript *baselineScript = script->baselineScript();
 
 #ifdef DEBUG
     uint32_t expectedDepth;
-    if (ReconstructStackDepth(cx, script, resumeAfter ? GetNextPc(pc) : pc, &expectedDepth)) {
+    bool reachablePC;
+    if (!ReconstructStackDepth(cx, script, resumeAfter ? GetNextPc(pc) : pc, &expectedDepth, &reachablePC))
+        return false;
+
+    if (reachablePC) {
         if (op != JSOP_FUNAPPLY || !iter.moreFrames() || resumeAfter) {
             if (op == JSOP_FUNCALL) {
                 // For fun.call(this, ...); the reconstructStackDepth will
                 // include the this. When inlining that is not included.
                 // So the exprStackSlots will be one less.
                 JS_ASSERT(expectedDepth - exprStackSlots <= 1);
             } else if (iter.moreFrames() && (IsGetPropPC(pc) || IsSetPropPC(pc))) {
                 // Accessors coming out of ion are inlined via a complete
--- a/js/src/jit/shared/CodeGenerator-shared.cpp
+++ b/js/src/jit/shared/CodeGenerator-shared.cpp
@@ -275,17 +275,21 @@ CodeGeneratorShared::encode(LSnapshot *s
         // bailouts.
         DebugOnly<jsbytecode *> bailPC = pc;
         if (mir->mode() == MResumePoint::ResumeAfter)
           bailPC = GetNextPc(pc);
 
 #ifdef DEBUG
         if (GetIonContext()->cx) {
             uint32_t stackDepth;
-            if (ReconstructStackDepth(GetIonContext()->cx, script, bailPC, &stackDepth)) {
+            bool reachablePC;
+            if (!ReconstructStackDepth(GetIonContext()->cx, script, bailPC, &stackDepth, &reachablePC))
+                return false;
+
+            if (reachablePC) {
                 if (JSOp(*bailPC) == JSOP_FUNCALL) {
                     // For fun.call(this, ...); the reconstructStackDepth will
                     // include the this. When inlining that is not included.
                     // So the exprStackSlots will be one less.
                     JS_ASSERT(stackDepth - exprStack <= 1);
                 } else if (JSOp(*bailPC) != JSOP_FUNAPPLY &&
                            !IsGetPropPC(bailPC) && !IsSetPropPC(bailPC))
                 {
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -692,26 +692,26 @@ BytecodeParser::parse()
     }
 
     return true;
 }
 
 #ifdef DEBUG
 
 bool
-js::ReconstructStackDepth(JSContext *cx, JSScript *script, jsbytecode *pc, uint32_t *depth)
+js::ReconstructStackDepth(JSContext *cx, JSScript *script, jsbytecode *pc, uint32_t *depth, bool *reachablePC)
 {
     BytecodeParser parser(cx, script);
     if (!parser.parse())
         return false;
 
-    if (!parser.isReachable(pc))
-        return false;
+    *reachablePC = parser.isReachable(pc);
 
-    *depth = parser.stackDepthAtPC(pc);
+    if (*reachablePC)
+        *depth = parser.stackDepthAtPC(pc);
 
     return true;
 }
 
 /*
  * If pc != nullptr, include a prefix indicating whether the PC is at the
  * current line. If showAll is true, include the source note type and the
  * entry stack depth.
--- a/js/src/jsopcode.h
+++ b/js/src/jsopcode.h
@@ -353,17 +353,17 @@ StackDefs(JSScript *script, jsbytecode *
 
 #ifdef DEBUG
 /*
  * Given bytecode address pc in script's main program code, compute the operand
  * stack depth just before (JSOp) *pc executes.  If *pc is not reachable, return
  * false.
  */
 extern bool
-ReconstructStackDepth(JSContext *cx, JSScript *script, jsbytecode *pc, uint32_t *depth);
+ReconstructStackDepth(JSContext *cx, JSScript *script, jsbytecode *pc, uint32_t *depth, bool *reachablePC);
 #endif
 
 }  /* namespace js */
 
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif