Title: [160835] branches/jsCStack/Source/_javascript_Core
Revision
160835
Author
[email protected]
Date
2013-12-19 09:22:19 -0800 (Thu, 19 Dec 2013)

Log Message

Clarified stack maintainence code
https://bugs.webkit.org/show_bug.cgi?id=125979

Reviewed by Phil Pizlo.

Our idiom is:
    * frameRegisterCount() is the distance between BP and SP
    * stackPointerOffset() is frameRegisterCount() converted to a stack offset
    * Stack checks don't need to check the stack used by C helper functions,
    since our reserved host zone will cover that.

* assembler/MaxFrameExtentForSlowPathCall.h: Reverted some pieces of
<http://trac.webkit.org/changeset/160745>. We don't consider our
callee's saved PC and BP a part of our stack frame because they lie
beneath our SP.

* bytecode/CodeBlock.cpp:
* bytecode/CodeBlock.h:
(JSC::CodeBlock::stackPointerOffset): New helper function. Lots of
callers were duplicating this, so I made a helper function.

* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::addCall):
(JSC::DFG::ByteCodeParser::parseBlock): Fixed a bug in the calculation
of m_parameterSlots. Within our stack frame, we don't reserve space for
our callee's saved PC and BP, so we don't need to add them to
m_parameterSlots.

* dfg/DFGGraph.cpp:
* dfg/DFGGraph.h:
(JSC::DFG::Graph::stackPointerOffset): New helper function. Lots of
callers were duplicating this, so I made a helper function.

* dfg/DFGJITCompiler.cpp:
(JSC::DFG::JITCompiler::compile):
(JSC::DFG::JITCompiler::compileFunction):
* dfg/DFGOSRExitCompilerCommon.cpp:
(JSC::DFG::adjustAndJumpToTarget):
* ftl/FTLLowerDFGToLLVM.cpp:
(JSC::FTL::LowerDFGToLLVM::compileCallOrConstruct):
* interpreter/CallFrame.cpp:
(JSC::CallFrame::topOfFrameInternal): Use the new helper function, so
everybody calculates SP the same way. This removes the two idiosyncratic
places that reserved extra space for our callee's CallerFrameAndPCSize.

* interpreter/JSStack.h:
* interpreter/JSStackInlines.h:
(JSC::JSStack::entryCheck):
(JSC::JSStack::pushFrame):
(JSC::JSStack::grow): Changed the interface here to accept a top-of-stack
pointer instead of a past-the-end pointer. The engine no longer computes
a past-the-end pointer, so this is more convenient.

* jit/JIT.cpp:
(JSC::JIT::privateCompile):
(JSC::JIT::stackPointerOffsetFor): Use the helper function, fixing a bug
where, incorrectly, we subtracted out maxFrameExtentForSlowPathCall.

* jit/JIT.h:
* jit/JITCall.cpp:
(JSC::JIT::compileOpCall):
(JSC::JIT::compileOpCallSlowCase):
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_catch):
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::emit_op_catch):
* jit/JITOperations.cpp: Use the helper function, so everybody does this
calculation the same way.

* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions): Reverted some pieces of
<http://trac.webkit.org/changeset/160745>, as above.

* llint/LLIntEntrypoint.cpp:
* llint/LLIntEntrypoint.h:
(JSC::LLInt::stackPointerOffsetFor): Helper function, as above.

* llint/LowLevelInterpreter.asm: Reverted some pieces of
<http://trac.webkit.org/changeset/160745>, as above.

Modified Paths

Diff

Modified: branches/jsCStack/Source/_javascript_Core/ChangeLog (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/ChangeLog	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/ChangeLog	2013-12-19 17:22:19 UTC (rev 160835)
@@ -1,3 +1,85 @@
+2013-12-18  Geoffrey Garen  <[email protected]>
+
+        Clarified stack maintainence code
+        https://bugs.webkit.org/show_bug.cgi?id=125979
+
+        Reviewed by Phil Pizlo.
+
+        Our idiom is:
+            * frameRegisterCount() is the distance between BP and SP
+            * stackPointerOffset() is frameRegisterCount() converted to a stack offset
+            * Stack checks don't need to check the stack used by C helper functions,
+            since our reserved host zone will cover that.
+
+        * assembler/MaxFrameExtentForSlowPathCall.h: Reverted some pieces of
+        <http://trac.webkit.org/changeset/160745>. We don't consider our
+        callee's saved PC and BP a part of our stack frame because they lie
+        beneath our SP.
+
+        * bytecode/CodeBlock.cpp:
+        * bytecode/CodeBlock.h:
+        (JSC::CodeBlock::stackPointerOffset): New helper function. Lots of
+        callers were duplicating this, so I made a helper function.
+
+        * dfg/DFGByteCodeParser.cpp:
+        (JSC::DFG::ByteCodeParser::addCall):
+        (JSC::DFG::ByteCodeParser::parseBlock): Fixed a bug in the calculation
+        of m_parameterSlots. Within our stack frame, we don't reserve space for
+        our callee's saved PC and BP, so we don't need to add them to
+        m_parameterSlots.
+
+        * dfg/DFGGraph.cpp:
+        * dfg/DFGGraph.h:
+        (JSC::DFG::Graph::stackPointerOffset): New helper function. Lots of
+        callers were duplicating this, so I made a helper function.
+
+        * dfg/DFGJITCompiler.cpp:
+        (JSC::DFG::JITCompiler::compile):
+        (JSC::DFG::JITCompiler::compileFunction):
+        * dfg/DFGOSRExitCompilerCommon.cpp:
+        (JSC::DFG::adjustAndJumpToTarget):
+        * ftl/FTLLowerDFGToLLVM.cpp:
+        (JSC::FTL::LowerDFGToLLVM::compileCallOrConstruct):
+        * interpreter/CallFrame.cpp:
+        (JSC::CallFrame::topOfFrameInternal): Use the new helper function, so
+        everybody calculates SP the same way. This removes the two idiosyncratic
+        places that reserved extra space for our callee's CallerFrameAndPCSize.
+
+        * interpreter/JSStack.h:
+        * interpreter/JSStackInlines.h:
+        (JSC::JSStack::entryCheck):
+        (JSC::JSStack::pushFrame):
+        (JSC::JSStack::grow): Changed the interface here to accept a top-of-stack
+        pointer instead of a past-the-end pointer. The engine no longer computes
+        a past-the-end pointer, so this is more convenient.
+
+        * jit/JIT.cpp:
+        (JSC::JIT::privateCompile):
+        (JSC::JIT::stackPointerOffsetFor): Use the helper function, fixing a bug
+        where, incorrectly, we subtracted out maxFrameExtentForSlowPathCall.
+
+        * jit/JIT.h:
+        * jit/JITCall.cpp:
+        (JSC::JIT::compileOpCall):
+        (JSC::JIT::compileOpCallSlowCase):
+        * jit/JITOpcodes.cpp:
+        (JSC::JIT::emit_op_catch):
+        * jit/JITOpcodes32_64.cpp:
+        (JSC::JIT::emit_op_catch):
+        * jit/JITOperations.cpp: Use the helper function, so everybody does this
+        calculation the same way.
+
+        * llint/LLIntData.cpp:
+        (JSC::LLInt::Data::performAssertions): Reverted some pieces of
+        <http://trac.webkit.org/changeset/160745>, as above.
+
+        * llint/LLIntEntrypoint.cpp:
+        * llint/LLIntEntrypoint.h:
+        (JSC::LLInt::stackPointerOffsetFor): Helper function, as above.
+
+        * llint/LowLevelInterpreter.asm: Reverted some pieces of
+        <http://trac.webkit.org/changeset/160745>, as above.
+
 2013-12-19  Michael Saboff  <[email protected]>
 
         CStack Branch: Remove "AndAlloc" from sizeAndAllocFrameForVarargs and friends

Modified: branches/jsCStack/Source/_javascript_Core/assembler/MaxFrameExtentForSlowPathCall.h (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/assembler/MaxFrameExtentForSlowPathCall.h	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/assembler/MaxFrameExtentForSlowPathCall.h	2013-12-19 17:22:19 UTC (rev 160835)
@@ -35,43 +35,36 @@
 // that can be used for outgoing args when calling a slow path C function
 // from JS code.
 
-// We also need to add space to account for CallerFrameAndPCSize (2 pointers)
-// and pad the sum up to a multiple of stackAlignmentBytes().
-
 #if ENABLE(LLINT_C_LOOP)
 static const size_t maxFrameExtentForSlowPathCall = 0;
 
 #elif CPU(X86_64) && OS(WINDOWS)
-// 4 args in registers, but stack space needs to be allocated for all args,
-// plus 16 bytes for CallerFrameAndPCSize.
-static const size_t maxFrameExtentForSlowPathCall = 64;
+// 4 args in registers, but stack space needs to be allocated for all args.
+static const size_t maxFrameExtentForSlowPathCall = 48;
 
 #elif CPU(X86_64)
-// All args in registers, plus 16 bytes for CallerFrameAndPCSize.
-static const size_t maxFrameExtentForSlowPathCall = 16;
+// All args in registers.
+static const size_t maxFrameExtentForSlowPathCall = 0;
 
 #elif CPU(X86)
-// 6 args on stack (24 bytes) plus 8 bytes for CallerFrameAndPCSize.
+// 6 args on stack (24 bytes) + 8 bytes to align the stack.
 static const size_t maxFrameExtentForSlowPathCall = 32;
 
 #elif CPU(ARM64)
-// All args in registers, plus 16 bytes for CallerFrameAndPCSize.
-static const size_t maxFrameExtentForSlowPathCall = 16;
+// All args in registers.
+static const size_t maxFrameExtentForSlowPathCall = 0;
 
 #elif CPU(ARM)
-// First four args in registers, remaining 4 args on stack,
-// plus 8 byte for CallerFrameAndPCSize and 8 bytes padding.
-static const size_t maxFrameExtentForSlowPathCall = 32;
+// First four args in registers, remaining 4 args on stack.
+static const size_t maxFrameExtentForSlowPathCall = 16;
 
 #elif CPU(SH4)
-// First four args in registers, remaining 4 args on stack,
-// plus 8 byte for CallerFrameAndPCSize and 8 bytes padding.
-static const size_t maxFrameExtentForSlowPathCall = 32;
+// First four args in registers, remaining 4 args on stack.
+static const size_t maxFrameExtentForSlowPathCall = 16;
 
 #elif CPU(MIPS)
-// Though args are in registers, there need to be space on the stack for all args,
-// plus 8 bytes CallerFrameAndPCSize and 8 bytes padding.
-static const size_t maxFrameExtentForSlowPathCall = 48;
+// Though args are in registers, there need to be space on the stack for all args.
+static const size_t maxFrameExtentForSlowPathCall = 32;
 
 #else
 #error "Unsupported CPU: need value for maxFrameExtentForSlowPathCall"

Modified: branches/jsCStack/Source/_javascript_Core/bytecode/CodeBlock.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/bytecode/CodeBlock.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/bytecode/CodeBlock.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -3382,6 +3382,11 @@
     }
 }
 
+int CodeBlock::stackPointerOffset()
+{
+    return virtualRegisterForLocal(frameRegisterCount() - 1).offset();
+}
+
 size_t CodeBlock::predictedMachineCodeSize()
 {
     // This will be called from CodeBlock::CodeBlock before either m_vm or the

Modified: branches/jsCStack/Source/_javascript_Core/bytecode/CodeBlock.h (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/bytecode/CodeBlock.h	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/bytecode/CodeBlock.h	2013-12-19 17:22:19 UTC (rev 160835)
@@ -901,6 +901,7 @@
 #endif
     
     unsigned frameRegisterCount();
+    int stackPointerOffset();
 
     // FIXME: Make these remaining members private.
 

Modified: branches/jsCStack/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/dfg/DFGByteCodeParser.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -802,8 +802,9 @@
         
         addVarArgChild(get(VirtualRegister(currentInstruction[2].u.operand)));
         int argCount = currentInstruction[3].u.operand;
-        if (JSStack::ThisArgument + (unsigned)argCount > m_parameterSlots)
-            m_parameterSlots = JSStack::ThisArgument + argCount;
+        size_t parameterSlots = JSStack::CallFrameHeaderSize - JSStack::CallerFrameAndPCSize + argCount;
+        if (parameterSlots > m_parameterSlots)
+            m_parameterSlots = parameterSlots;
 
         int registerOffset = -currentInstruction[4].u.operand;
         int dummyThisArgument = op == Call ? 0 : 1;
@@ -1016,9 +1017,10 @@
     // The number of locals (vars + temporaries) used in the function.
     unsigned m_numLocals;
     // The number of slots (in units of sizeof(Register)) that we need to
-    // preallocate for calls emanating from this frame. This includes the
-    // size of the CallFrame, only if this is not a leaf function.  (I.e.
-    // this is 0 if and only if this function is a leaf.)
+    // preallocate for arguments to outgoing calls from this frame. This
+    // number includes the CallFrame slots that we initialize for the callee
+    // (but not the callee-initialized CallerFrame and ReturnPC slots).
+    // This number is 0 if and only if this function is a leaf.
     unsigned m_parameterSlots;
     // The number of var args passed to the next var arg node.
     unsigned m_numPassedVarArgs;
@@ -2996,10 +2998,11 @@
             SpeculatedType prediction = getPrediction();
             
             addToGraph(CheckArgumentsNotCreated);
-            
+
             unsigned argCount = inlineCallFrame()->arguments.size();
-            if (JSStack::ThisArgument + argCount > m_parameterSlots)
-                m_parameterSlots = JSStack::ThisArgument + argCount;
+            size_t parameterSlots = JSStack::CallFrameHeaderSize - JSStack::CallerFrameAndPCSize + argCount;
+            if (parameterSlots > m_parameterSlots)
+                m_parameterSlots = parameterSlots;
             
             addVarArgChild(get(VirtualRegister(currentInstruction[2].u.operand))); // callee
             addVarArgChild(get(VirtualRegister(currentInstruction[3].u.operand))); // this

Modified: branches/jsCStack/Source/_javascript_Core/dfg/DFGGraph.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/dfg/DFGGraph.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/dfg/DFGGraph.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -710,6 +710,11 @@
     return result;
 }
 
+unsigned Graph::stackPointerOffset()
+{
+    return virtualRegisterForLocal(frameRegisterCount() - 1).offset();
+}
+
 unsigned Graph::requiredRegisterCountForExit()
 {
     unsigned count = JIT::frameRegisterCountFor(m_profiledBlock);

Modified: branches/jsCStack/Source/_javascript_Core/dfg/DFGGraph.h (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/dfg/DFGGraph.h	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/dfg/DFGGraph.h	2013-12-19 17:22:19 UTC (rev 160835)
@@ -788,6 +788,7 @@
     bool isLiveInBytecode(VirtualRegister, CodeOrigin);
     
     unsigned frameRegisterCount();
+    unsigned stackPointerOffset();
     unsigned requiredRegisterCountForExit();
     unsigned requiredRegisterCountForExecutionAndExit();
     

Modified: branches/jsCStack/Source/_javascript_Core/dfg/DFGJITCompiler.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/dfg/DFGJITCompiler.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/dfg/DFGJITCompiler.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -277,7 +277,7 @@
     compileEntry();
     m_speculative = adoptPtr(new SpeculativeJIT(*this));
     checkStackPointerAlignment();
-    addPtr(TrustedImm32(-(m_graph.frameRegisterCount() - JSStack::CallerFrameAndPCSize) * sizeof(Register)), GPRInfo::callFrameRegister, stackPointerRegister);
+    addPtr(TrustedImm32(m_graph.stackPointerOffset() * sizeof(Register)), GPRInfo::callFrameRegister, stackPointerRegister);
     checkStackPointerAlignment();
     compileBody();
     setEndOfMainPath();
@@ -334,7 +334,7 @@
     checkStackPointerAlignment();
 
     // Move the stack pointer down to accommodate locals
-    addPtr(TrustedImm32(-(m_graph.frameRegisterCount() - JSStack::CallerFrameAndPCSize) * sizeof(Register)), GPRInfo::callFrameRegister, stackPointerRegister);
+    addPtr(TrustedImm32(m_graph.stackPointerOffset() * sizeof(Register)), GPRInfo::callFrameRegister, stackPointerRegister);
     checkStackPointerAlignment();
 
     // === Function body code generation ===

Modified: branches/jsCStack/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/dfg/DFGOSRExitCompilerCommon.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -175,7 +175,7 @@
     
     void* jumpTarget = baselineCodeBlock->jitCode()->executableAddressAtOffset(mapping->m_machineCodeOffset);
 
-    jit.addPtr(AssemblyHelpers::TrustedImm32(-JIT::frameRegisterCountFor(baselineCodeBlock) * sizeof(Register)), GPRInfo::callFrameRegister, AssemblyHelpers::stackPointerRegister);
+    jit.addPtr(AssemblyHelpers::TrustedImm32(JIT::stackPointerOffsetFor(baselineCodeBlock) * sizeof(Register)), GPRInfo::callFrameRegister, AssemblyHelpers::stackPointerRegister);
 
     jit.move(AssemblyHelpers::TrustedImmPtr(jumpTarget), GPRInfo::regT2);
     jit.jump(GPRInfo::regT2);

Modified: branches/jsCStack/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/ftl/FTLLowerDFGToLLVM.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -2449,7 +2449,7 @@
         
         LValue calleeFrame = m_out.add(
             m_callFrame,
-            m_out.constIntPtr(sizeof(Register) * virtualRegisterForLocal(m_graph.frameRegisterCount()).offset()));
+            m_out.constIntPtr(m_graph.stackPointerOffset() * sizeof(Register));
         
         m_out.store32(
             m_out.constInt32(numPassedArgs + dummyThisArgument),

Modified: branches/jsCStack/Source/_javascript_Core/interpreter/CallFrame.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/interpreter/CallFrame.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/interpreter/CallFrame.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -120,7 +120,7 @@
 {
     CodeBlock* codeBlock = this->codeBlock();
     ASSERT(codeBlock);
-    return registers() + virtualRegisterForLocal(codeBlock->frameRegisterCount() - 1).offset();
+    return registers() + codeBlock->stackPointerOffset();
 }
 
 JSGlobalObject* CallFrame::vmEntryGlobalObject()

Modified: branches/jsCStack/Source/_javascript_Core/interpreter/JSStack.h (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/interpreter/JSStack.h	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/interpreter/JSStack.h	2013-12-19 17:22:19 UTC (rev 160835)
@@ -92,7 +92,7 @@
 
         size_t size() const { return highAddress() - lowAddress(); }
 
-        bool grow(Register*);
+        bool grow(Register* topOfStack);
         
         static size_t committedByteCount();
         static void initializeThreading();

Modified: branches/jsCStack/Source/_javascript_Core/interpreter/JSStackInlines.h (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/interpreter/JSStackInlines.h	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/interpreter/JSStackInlines.h	2013-12-19 17:22:19 UTC (rev 160835)
@@ -69,12 +69,12 @@
     newCallFrameSlot -= JSStack::FenceSize;
 #endif
 
-    Register* newEnd = newCallFrameSlot;
+    Register* topOfStack = newCallFrameSlot;
     if (!!codeBlock)
-        newEnd += virtualRegisterForLocal(codeBlock->frameRegisterCount()).offset();
+        topOfStack += codeBlock->stackPointerOffset();
 
     // Ensure that we have the needed stack capacity to push the new frame:
-    if (!grow(newEnd))
+    if (!grow(topOfStack))
         return false;
 
     return true;
@@ -99,12 +99,12 @@
     newCallFrameSlot -= JSStack::FenceSize;
 #endif
 
-    Register* newEnd = newCallFrameSlot;
+    Register* topOfStack = newCallFrameSlot;
     if (!!codeBlock)
-        newEnd += virtualRegisterForLocal(codeBlock->frameRegisterCount()).offset();
+        topOfStack += codeBlock->stackPointerOffset();
 
     // Ensure that we have the needed stack capacity to push the new frame:
-    if (!grow(newEnd))
+    if (!grow(topOfStack))
         return 0;
 
     // Compute the address of the new VM sentinel frame for this invocation:
@@ -173,8 +173,9 @@
         releaseExcessCapacity();
 }
 
-inline bool JSStack::grow(Register* newEnd)
+inline bool JSStack::grow(Register* topOfStack)
 {
+    Register* newEnd = topOfStack - 1;
     if (newEnd >= m_end)
         return true;
     return growSlowCase(newEnd);

Modified: branches/jsCStack/Source/_javascript_Core/jit/JIT.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/jit/JIT.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/jit/JIT.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -541,14 +541,14 @@
         }
 #endif
 
-        addPtr(TrustedImm32(virtualRegisterForLocal(frameRegisterCountFor(m_codeBlock) - 1).offsetInBytes()), callFrameRegister, regT1);
+        addPtr(TrustedImm32(stackPointerOffsetFor(m_codeBlock) * sizeof(Register)), callFrameRegister, regT1);
         stackCheck = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), regT1);
     }
 
     Label functionBody = label();
 
     checkStackPointerAlignment();
-    addPtr(TrustedImm32(-frameRegisterCountFor(m_codeBlock) * sizeof(Register) - maxFrameExtentForSlowPathCall), callFrameRegister, stackPointerRegister);
+    addPtr(TrustedImm32(stackPointerOffsetFor(m_codeBlock) * sizeof(Register)), callFrameRegister, stackPointerRegister);
     checkStackPointerAlignment();
 
     privateCompileMainPass();
@@ -788,6 +788,11 @@
     return registerCount;
 }
 
+int JIT::stackPointerOffsetFor(CodeBlock* codeBlock)
+{
+    return virtualRegisterForLocal(frameRegisterCountFor(codeBlock) - 1).offset();
+}
+
 } // namespace JSC
 
 #endif // ENABLE(JIT)

Modified: branches/jsCStack/Source/_javascript_Core/jit/JIT.h (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/jit/JIT.h	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/jit/JIT.h	2013-12-19 17:22:19 UTC (rev 160835)
@@ -245,6 +245,7 @@
         static void linkSlowCall(CodeBlock* callerCodeBlock, CallLinkInfo*);
         
         static unsigned frameRegisterCountFor(CodeBlock*);
+        static int stackPointerOffsetFor(CodeBlock*);
 
     private:
         JIT(VM*, CodeBlock* = 0);

Modified: branches/jsCStack/Source/_javascript_Core/jit/JITCall.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/jit/JITCall.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/jit/JITCall.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -208,7 +208,7 @@
 
     m_callStructureStubCompilationInfo[callLinkInfoIndex].hotPathOther = emitNakedCall();
 
-    addPtr(TrustedImm32(-frameRegisterCountFor(m_codeBlock) * sizeof(Register)), callFrameRegister, stackPointerRegister);
+    addPtr(TrustedImm32(stackPointerOffsetFor(m_codeBlock) * sizeof(Register)), callFrameRegister, stackPointerRegister);
     checkStackPointerAlignment();
 
     sampleCodeBlock(m_codeBlock);
@@ -229,7 +229,7 @@
 
     m_callStructureStubCompilationInfo[callLinkInfoIndex].callReturnLocation = emitNakedCall(opcodeID == op_construct ? m_vm->getCTIStub(linkConstructThunkGenerator).code() : m_vm->getCTIStub(linkCallThunkGenerator).code());
 
-    addPtr(TrustedImm32(-frameRegisterCountFor(m_codeBlock) * sizeof(Register)), callFrameRegister, stackPointerRegister);
+    addPtr(TrustedImm32(stackPointerOffsetFor(m_codeBlock) * sizeof(Register)), callFrameRegister, stackPointerRegister);
     checkStackPointerAlignment();
 
     sampleCodeBlock(m_codeBlock);

Modified: branches/jsCStack/Source/_javascript_Core/jit/JITOpcodes.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/jit/JITOpcodes.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/jit/JITOpcodes.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -637,8 +637,7 @@
     move(TrustedImmPtr(m_vm), regT3);
     load64(Address(regT3, VM::callFrameForThrowOffset()), callFrameRegister);
 
-    int offset = virtualRegisterForLocal(frameRegisterCountFor(codeBlock()) - 1).offsetInBytes();
-    addPtr(TrustedImm32(offset), callFrameRegister, stackPointerRegister);
+    addPtr(TrustedImm32(stackPointerOffsetFor(codeBlock()) * sizeof(Register)), callFrameRegister, stackPointerRegister);
 
     load64(Address(regT3, VM::exceptionOffset()), regT0);
     store64(TrustedImm64(JSValue::encode(JSValue())), Address(regT3, VM::exceptionOffset()));

Modified: branches/jsCStack/Source/_javascript_Core/jit/JITOpcodes32_64.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/jit/JITOpcodes32_64.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/jit/JITOpcodes32_64.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -924,8 +924,7 @@
     // operationThrow returns the callFrame for the handler.
     load32(Address(regT3, VM::callFrameForThrowOffset()), callFrameRegister);
 
-    int offset = virtualRegisterForLocal(frameRegisterCountFor(codeBlock()) - 1).offsetInBytes();
-    addPtr(TrustedImm32(offset), callFrameRegister, stackPointerRegister);
+    addPtr(TrustedImm32(stackPointerOffsetFor(codeBlock()) * sizeof(Register)), callFrameRegister, stackPointerRegister);
 
     // Now store the exception returned by operationThrow.
     load32(Address(regT3, VM::exceptionOffset() + OBJECT_OFFSETOF(JSValue, u.asBits.payload)), regT0);

Modified: branches/jsCStack/Source/_javascript_Core/jit/JITOperations.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/jit/JITOperations.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/jit/JITOperations.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -82,7 +82,7 @@
 
     JSStack& stack = vm->interpreter->stack();
 
-    if (UNLIKELY(!stack.grow(&exec->registers()[virtualRegisterForLocal(codeBlock->frameRegisterCount()).offset()])))
+    if (UNLIKELY(!stack.grow(&exec->registers()[codeBlock->stackPointerOffset()])))
         vm->throwException(callerFrame, createStackOverflowError(callerFrame));
 }
 

Modified: branches/jsCStack/Source/_javascript_Core/llint/LLIntData.cpp (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/llint/LLIntData.cpp	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/llint/LLIntData.cpp	2013-12-19 17:22:19 UTC (rev 160835)
@@ -125,16 +125,12 @@
     ASSERT(ValueUndefined == (TagBitTypeOther | TagBitUndefined));
     ASSERT(ValueNull == TagBitTypeOther);
 #endif
-#if ENABLE(LLINT_C_LOOP)
+#if CPU(X86_64) || CPU(ARM64) || ENABLE(LLINT_C_LOOP)
     ASSERT(maxFrameExtentForSlowPathCall == 0);
-#elif CPU(X86_64) && OS(WINDOWS)
-    ASSERT(maxFrameExtentForSlowPathCall == 64);
-#elif CPU(X86_64) || CPU(ARM64)
+#elif CPU(ARM) || CPU(SH4)
     ASSERT(maxFrameExtentForSlowPathCall == 16);
-#elif CPU(X86) || CPU(ARM) || CPU(SH4)
+#elif CPU(X86) || CPU(MIPS)
     ASSERT(maxFrameExtentForSlowPathCall == 32);
-#elif CPU(MIPS)
-    ASSERT(maxFrameExtentForSlowPathCall == 48);
 #endif
     ASSERT(StringType == 5);
     ASSERT(ObjectType == 17);

Modified: branches/jsCStack/Source/_javascript_Core/llint/LowLevelInterpreter.asm (160834 => 160835)


--- branches/jsCStack/Source/_javascript_Core/llint/LowLevelInterpreter.asm	2013-12-19 17:11:35 UTC (rev 160834)
+++ branches/jsCStack/Source/_javascript_Core/llint/LowLevelInterpreter.asm	2013-12-19 17:22:19 UTC (rev 160835)
@@ -73,14 +73,12 @@
 const LowestTag = DeletedValueTag
 end
 
-if C_LOOP
+if X86_64 or ARM64 or C_LOOP
 const maxFrameExtentForSlowPathCall = 0
-elsif X86_64 or ARM64
+elsif ARM or ARMv7_TRADITIONAL or ARMv7 or SH4
 const maxFrameExtentForSlowPathCall = 16
-elsif X86 or ARM or ARMv7_TRADITIONAL or ARMv7 or SH4
+elsif X86 or MIPS
 const maxFrameExtentForSlowPathCall = 32
-elsif MIPS
-const maxFrameExtentForSlowPathCall = 48
 end
 
 # Watchpoint states
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to