Bug 852472 - Fix stack check to handle interrupts too. r=djvj
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 19 Mar 2013 16:30:41 +0100
changeset 127428 ff681c5eadafe2d0e2aabe093e80585501f1eaef
parent 127427 2db2d953efb69e6406d1665a5140eb0aa3462a7b
child 127429 bbf7ea6ef2e44b8d97c5f015f106209147576f55
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdjvj
bugs852472
milestone22.0a1
Bug 852472 - Fix stack check to handle interrupts too. r=djvj
js/src/ion/BaselineCompiler.cpp
js/src/ion/BaselineIC.cpp
js/src/ion/BaselineIC.h
js/src/jit-test/tests/basic/timeout-check.js
--- a/js/src/ion/BaselineCompiler.cpp
+++ b/js/src/ion/BaselineCompiler.cpp
@@ -334,29 +334,33 @@ BaselineCompiler::initScopeChain()
             if (!callVM(StrictEvalPrologueInfo))
                 return false;
         }
     }
 
     return true;
 }
 
+typedef bool (*ReportOverRecursedFn)(JSContext *);
+static const VMFunction CheckOverRecursedInfo =
+    FunctionInfo<ReportOverRecursedFn>(CheckOverRecursed);
+
 bool
 BaselineCompiler::emitStackCheck()
 {
-    Label skipIC;
+    Label skipCall;
     uintptr_t *limitAddr = &cx->runtime->mainThread.ionStackLimit;
     masm.loadPtr(AbsoluteAddress(limitAddr), R0.scratchReg());
-    masm.branchPtr(Assembler::AboveOrEqual, BaselineStackReg, R0.scratchReg(), &skipIC);
-
-    ICStackCheck_Fallback::Compiler stubCompiler(cx);
-    if (!emitNonOpIC(stubCompiler.getStub(&stubSpace_)))
+    masm.branchPtr(Assembler::AboveOrEqual, BaselineStackReg, R0.scratchReg(), &skipCall);
+
+    prepareVMCall();
+    if (!callVM(CheckOverRecursedInfo))
         return false;
 
-    masm.bind(&skipIC);
+    masm.bind(&skipCall);
     return true;
 }
 
 typedef bool (*InterruptCheckFn)(JSContext *);
 static const VMFunction InterruptCheckInfo = FunctionInfo<InterruptCheckFn>(InterruptCheck);
 
 bool
 BaselineCompiler::emitInterruptCheck()
--- a/js/src/ion/BaselineIC.cpp
+++ b/js/src/ion/BaselineIC.cpp
@@ -543,45 +543,16 @@ ICStubCompiler::enterStubFrame(MacroAsse
 void
 ICStubCompiler::leaveStubFrame(MacroAssembler &masm, bool calledIntoIon)
 {
     JS_ASSERT(entersStubFrame_);
     EmitLeaveStubFrame(masm, calledIntoIon);
 }
 
 //
-// StackCheck_Fallback
-//
-
-static bool
-DoStackCheckFallback(JSContext *cx, ICStackCheck_Fallback *stub)
-{
-    FallbackICSpew(cx, stub, "StackCheck");
-    JS_CHECK_RECURSION(cx, return false);
-    return true;
-}
-
-typedef bool (*DoStackCheckFallbackFn)(JSContext *, ICStackCheck_Fallback *);
-static const VMFunction DoStackCheckFallbackInfo =
-    FunctionInfo<DoStackCheckFallbackFn>(DoStackCheckFallback);
-
-bool
-ICStackCheck_Fallback::Compiler::generateStubCode(MacroAssembler &masm)
-{
-    JS_ASSERT(R0 == JSReturnOperand);
-
-    // Restore the tail call register.
-    EmitRestoreTailCallReg(masm);
-
-    masm.push(BaselineStubReg);
-
-    return tailCallVM(DoStackCheckFallbackInfo, masm);
-}
-
-//
 // UseCount_Fallback
 //
 static bool
 IsTopFrameConstructing(JSContext *cx)
 {
     IonFrameIterator iter(cx);
     JS_ASSERT(iter.type() == IonFrame_Exit);
 
--- a/js/src/ion/BaselineIC.h
+++ b/js/src/ion/BaselineIC.h
@@ -264,18 +264,16 @@ class ICEntry
 
     inline ICStub **addressOfFirstStub() {
         return &firstStub_;
     }
 };
 
 // List of baseline IC stub kinds.
 #define IC_STUB_KIND_LIST(_)    \
-    _(StackCheck_Fallback)      \
-                                \
     _(UseCount_Fallback)        \
                                 \
     _(TypeMonitor_Fallback)     \
     _(TypeMonitor_SingleObject) \
     _(TypeMonitor_TypeObject)   \
     _(TypeMonitor_PrimitiveSet) \
                                 \
     _(TypeUpdate_Fallback)      \
@@ -1045,50 +1043,16 @@ class ICMultiStubCompiler : public ICStu
     virtual int32_t getKey() const {
         return static_cast<int32_t>(kind) | (static_cast<int32_t>(op) << 16);
     }
 
     ICMultiStubCompiler(JSContext *cx, ICStub::Kind kind, JSOp op)
       : ICStubCompiler(cx, kind), op(op) {}
 };
 
-// StackCheck_Fallback
-
-// A StackCheck IC chain has only the fallback stub.
-class ICStackCheck_Fallback : public ICFallbackStub
-{
-    friend class ICStubSpace;
-
-    ICStackCheck_Fallback(IonCode *stubCode)
-      : ICFallbackStub(ICStub::StackCheck_Fallback, stubCode)
-    { }
-
-  public:
-    static inline ICStackCheck_Fallback *New(ICStubSpace *space, IonCode *code) {
-        if (!code)
-            return NULL;
-        return space->allocate<ICStackCheck_Fallback>(code);
-    }
-
-    // Compiler for this stub kind.
-    class Compiler : public ICStubCompiler {
-      protected:
-        bool generateStubCode(MacroAssembler &masm);
-
-      public:
-        Compiler(JSContext *cx)
-          : ICStubCompiler(cx, ICStub::StackCheck_Fallback)
-        { }
-
-        ICStackCheck_Fallback *getStub(ICStubSpace *space) {
-            return ICStackCheck_Fallback::New(space, getStubCode());
-        }
-    };
-};
-
 // UseCount_Fallback
 
 // A UseCount IC chain has only the fallback stub.
 class ICUseCount_Fallback : public ICFallbackStub
 {
     friend class ICStubSpace;
 
     ICUseCount_Fallback(IonCode *stubCode)
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/timeout-check.js
@@ -0,0 +1,14 @@
+// |jit-test| exitstatus: 6
+function f(x) {
+    if (x === 0)
+	return;
+    f(x - 1);
+    f(x - 1);
+    f(x - 1);
+    f(x - 1);
+    f(x - 1);
+    f(x - 1);
+}
+timeout(0.1);
+f(100);
+assertEq(0, 1);