[INFER] Fix busted jstests.
authorBrian Hackett <bhackett1024@gmail.com>
Tue, 19 Jul 2011 07:21:33 -0700
changeset 76049 993716952d8681f43cfb4358177657586f80be82
parent 76048 7f471e15146eb0c507f2cfbbb72fa2051d42be18
child 76050 dd84f621ca258b452d0df583b036efa7e47c87cb
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
milestone8.0a1
[INFER] Fix busted jstests.
js/src/jsanalyze.cpp
js/src/jsinfer.cpp
js/src/jsopcode.cpp
js/src/methodjit/Compiler.cpp
js/src/methodjit/StubCalls.cpp
--- a/js/src/jsanalyze.cpp
+++ b/js/src/jsanalyze.cpp
@@ -1924,16 +1924,18 @@ CrossScriptSSA::foldValue(const CrossSSA
     return cv;
 }
 
 #ifdef DEBUG
 
 void
 ScriptAnalysis::printSSA(JSContext *cx)
 {
+    AutoEnterAnalysis enter(cx);
+
     printf("\n");
 
     for (unsigned offset = 0; offset < script->length; offset++) {
         Bytecode *code = maybeCode(offset);
         if (!code)
             continue;
 
         jsbytecode *pc = script->code + offset;
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -3146,16 +3146,23 @@ ScriptAnalysis::analyzeTypesBytecode(JSC
             types.setIntermediate();
             InferSpew(ISpewOps, "typeSet: %sT%p%s phi #%u:%05u:%u",
                       InferSpewColor(&types), &types, InferSpewColorReset(),
                       script->id(), offset, newv->slot);
             newv++;
         }
     }
 
+    /*
+     * Treat decomposed ops as no-ops, we will analyze the decomposed version
+     * instead. (We do, however, need to look at introduced phi nodes).
+     */
+    if (js_CodeSpec[*pc].format & JOF_DECOMPOSE)
+        return true;
+
     for (unsigned i = 0; i < defCount; i++) {
         pushed[i].setIntermediate();
         InferSpew(ISpewOps, "typeSet: %sT%p%s pushed%u #%u:%05u",
                   InferSpewColor(&pushed[i]), &pushed[i], InferSpewColorReset(),
                   i, script->id(), offset);
     }
 
     /* Add type constraints for the various opcodes. */
@@ -3957,21 +3964,19 @@ ScriptAnalysis::analyzeTypes(JSContext *
 
     unsigned offset = 0;
     while (offset < script->length) {
         Bytecode *code = maybeCode(offset);
 
         jsbytecode *pc = script->code + offset;
         UntrapOpcode untrap(cx, script, pc);
 
-        if (code && !(js_CodeSpec[*pc].format & JOF_DECOMPOSE)) {
-            if (!analyzeTypesBytecode(cx, offset, state)) {
-                cx->compartment->types.setPendingNukeTypes(cx);
-                return;
-            }
+        if (code && !analyzeTypesBytecode(cx, offset, state)) {
+            cx->compartment->types.setPendingNukeTypes(cx);
+            return;
         }
 
         offset += GetBytecodeLength(pc);
     }
 
     for (unsigned i = 0; i < state.phiNodes.length(); i++) {
         SSAPhiNode *node = state.phiNodes[i];
         for (unsigned j = 0; j < node->length; j++) {
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -4443,16 +4443,18 @@ Decompile(SprintStack *ss, jsbytecode *p
                 break;
 
               case JSOP_TRAP:
                 saveop = op = JS_GetTrapOpcode(cx, jp->script, pc);
                 *pc = op;
                 cs = &js_CodeSpec[op];
                 len = cs->length;
                 DECOMPILE_CODE(pc, len);
+                if (js_CodeSpec[*pc].format & JOF_DECOMPOSE)
+                    len += GetDecomposeLength(pc, js_CodeSpec[*pc].length);
                 *pc = JSOP_TRAP;
                 todo = -2;
                 break;
 
               case JSOP_HOLE:
                 todo = SprintPut(&ss->sprinter, "", 0);
                 break;
 
@@ -4788,18 +4790,18 @@ Decompile(SprintStack *ss, jsbytecode *p
         }
 
         if (cs->format & JOF_CALLOP) {
             todo = Sprint(&ss->sprinter, "");
             if (todo < 0 || !PushOff(ss, todo, saveop))
                 return NULL;
         }
 
-        if (cs->format & JOF_DECOMPOSE)
-            pc += GetDecomposeLength(pc, cs->length);
+        if (js_CodeSpec[*pc].format & JOF_DECOMPOSE)
+            pc += GetDecomposeLength(pc, js_CodeSpec[*pc].length);
 
         pc += len;
     }
 
 /*
  * Undefine local macros.
  */
 #undef inXML
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -1517,22 +1517,18 @@ mjit::Compiler::generateMethod()
 
         SPEW_OPCODE();
         JS_ASSERT(frame.stackDepth() == opinfo->stackDepth);
 
         // If this is an exception entry point, then jsl_InternalThrow has set
         // VMFrame::fp to the correct fp for the entry point. We need to copy
         // that value here to FpReg so that FpReg also has the correct sp.
         // Otherwise, we would simply be using a stale FpReg value.
-        // Additionally, we check the interrupt flag to allow interrupting
-        // deeply nested exception handling.
-        if (op == JSOP_ENTERBLOCK && analysis->getCode(PC).exceptionEntry) {
+        if (op == JSOP_ENTERBLOCK && analysis->getCode(PC).exceptionEntry)
             masm.loadPtr(FrameAddress(VMFrame::offsetOfFp), JSFrameReg);
-            interruptCheckHelper();
-        }
 
         if (trap) {
             prepareStubCall(Uses(0));
             masm.move(Imm32(trap), Registers::ArgReg1);
             Call cl = emitStubCall(JS_FUNC_TO_DATA_PTR(void *, stubs::Trap), NULL);
             InternalCallSite site(masm.callReturnOffset(cl), a->inlineIndex, PC,
                                   REJOIN_TRAP, false);
             addCallSite(site);
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -2499,16 +2499,21 @@ stubs::InvariantFailure(VMFrame &f, void
 
     /* Return the same value (if any) as the call triggering the invariant failure. */
     return rval;
 }
 
 void JS_FASTCALL
 stubs::Exception(VMFrame &f)
 {
+    // Check the interrupt flag to allow interrupting deeply nested exception
+    // handling.
+    if (JS_THREAD_DATA(f.cx)->interruptFlags && !js_HandleExecutionInterrupt(f.cx))
+        THROW();
+
     f.regs.sp[0] = f.cx->getPendingException();
     f.cx->clearPendingException();
 }
 
 template <bool Clamped>
 int32 JS_FASTCALL
 stubs::ConvertToTypedInt(JSContext *cx, Value *vp)
 {