Skip to content
Permalink
Browse files
JIT Engines use the wrong stack limit for stack checks
https://bugs.webkit.org/show_bug.cgi?id=129314

Reviewed by Filip Pizlo.

Change the Baseline and DFG code to use VM::m_stackLimit for stack limit checks.

* dfg/DFGJITCompiler.cpp:
(JSC::DFG::JITCompiler::compileFunction):
* jit/JIT.cpp:
(JSC::JIT::privateCompile):
* jit/JITCall.cpp:
(JSC::JIT::compileLoadVarargs):
* jit/JITCall32_64.cpp:
(JSC::JIT::compileLoadVarargs):
* runtime/VM.h:
(JSC::VM::addressOfStackLimit):


Canonical link: https://commits.webkit.org/147360@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164653 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
msaboff committed Feb 25, 2014
1 parent 50e17a4 commit abaf4c39d7ddda0169bcd870bb0e3ea5220eef88
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
@@ -1,3 +1,23 @@
2014-02-25 Michael Saboff <msaboff@apple.com>

JIT Engines use the wrong stack limit for stack checks
https://bugs.webkit.org/show_bug.cgi?id=129314

Reviewed by Filip Pizlo.

Change the Baseline and DFG code to use VM::m_stackLimit for stack limit checks.

* dfg/DFGJITCompiler.cpp:
(JSC::DFG::JITCompiler::compileFunction):
* jit/JIT.cpp:
(JSC::JIT::privateCompile):
* jit/JITCall.cpp:
(JSC::JIT::compileLoadVarargs):
* jit/JITCall32_64.cpp:
(JSC::JIT::compileLoadVarargs):
* runtime/VM.h:
(JSC::VM::addressOfStackLimit):

2014-02-25 Filip Pizlo <fpizlo@apple.com>

Unreviewed, roll out http://trac.webkit.org/changeset/164493.
@@ -336,7 +336,7 @@ void JITCompiler::compileFunction()
Label fromArityCheck(this);
// Plant a check that sufficient space is available in the JSStack.
addPtr(TrustedImm32(virtualRegisterForLocal(m_graph.requiredRegisterCountForExecutionAndExit() - 1).offset() * sizeof(Register)), GPRInfo::callFrameRegister, GPRInfo::regT1);
Jump stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), GPRInfo::regT1);
Jump stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOfStackLimit()), GPRInfo::regT1);

// Move the stack pointer down to accommodate locals
addPtr(TrustedImm32(m_graph.stackPointerOffset() * sizeof(Register)), GPRInfo::callFrameRegister, stackPointerRegister);
@@ -519,7 +519,7 @@ CompilationResult JIT::privateCompile(JITCompilationEffort effort)
}

addPtr(TrustedImm32(stackPointerOffsetFor(m_codeBlock) * sizeof(Register)), callFrameRegister, regT1);
stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), regT1);
stackOverflow = branchPtr(Above, AbsoluteAddress(m_vm->addressOfStackLimit()), regT1);
}

addPtr(TrustedImm32(stackPointerOffsetFor(m_codeBlock) * sizeof(Register)), callFrameRegister, stackPointerRegister);
@@ -87,7 +87,7 @@ void JIT::compileLoadVarargs(Instruction* instruction)
addPtr(callFrameRegister, regT1);
// regT1: newCallFrame

slowCase.append(branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), regT1));
slowCase.append(branchPtr(Above, AbsoluteAddress(m_vm->addressOfStackLimit()), regT1));

// Initialize ArgumentCount.
store32(regT0, Address(regT1, JSStack::ArgumentCount * static_cast<int>(sizeof(Register)) + OBJECT_OFFSETOF(EncodedValueDescriptor, asBits.payload)));
@@ -160,7 +160,7 @@ void JIT::compileLoadVarargs(Instruction* instruction)
addPtr(callFrameRegister, regT3);
// regT3: newCallFrame

slowCase.append(branchPtr(Above, AbsoluteAddress(m_vm->addressOfJSStackLimit()), regT3));
slowCase.append(branchPtr(Above, AbsoluteAddress(m_vm->addressOfStackLimit()), regT3));

// Initialize ArgumentCount.
store32(regT2, payloadFor(JSStack::ArgumentCount, regT3));
@@ -389,12 +389,12 @@ namespace JSC {
void** addressOfFTLStackLimit() { return &m_ftlStackLimit; }
#endif

void** addressOfJSStackLimit() { return &m_jsStackLimit; }
#if ENABLE(LLINT_C_LOOP)
void* jsStackLimit() { return m_jsStackLimit; }
void setJSStackLimit(void* limit) { m_jsStackLimit = limit; }
#endif
void* stackLimit() { return m_stackLimit; }
void** addressOfStackLimit() { return &m_stackLimit; }

bool isSafeToRecurse(size_t neededStackInBytes = 0) const
{

0 comments on commit abaf4c3

Please sign in to comment.