Diff
Modified: branches/jsCStack/Source/_javascript_Core/ChangeLog (160745 => 160746)
--- branches/jsCStack/Source/_javascript_Core/ChangeLog 2013-12-18 03:38:14 UTC (rev 160745)
+++ branches/jsCStack/Source/_javascript_Core/ChangeLog 2013-12-18 03:45:57 UTC (rev 160746)
@@ -1,3 +1,22 @@
+2013-12-17 Michael Saboff <[email protected]>
+
+ CStack Branch: Fix varargs calls to work on C stack
+ https://bugs.webkit.org/show_bug.cgi?id=125903
+
+ Reviewed by Filip Pizlo.
+
+ Fixed up the stack pointer after the sizeAndAllocFrameForVarargs() has been called in both the
+ LLInt and baseline JIT code. Adjusted the callee frame calculations in sizeAndAllocFrameForVarargs()
+ and compileLoadVarargs() to create aligned callee frames.
+
+ * interpreter/Interpreter.cpp:
+ (JSC::sizeAndAllocFrameForVarargs):
+ * jit/JIT.cpp:
+ (JSC::JIT::privateCompile):
+ * jit/JITCall.cpp:
+ (JSC::JIT::compileLoadVarargs):
+ * llint/LowLevelInterpreter.asm:
+
2013-12-17 Mark Lam <[email protected]>
frameRegisterCount() should include maxFrameExtentForSlowPathCall.
Modified: branches/jsCStack/Source/_javascript_Core/interpreter/Interpreter.cpp (160745 => 160746)
--- branches/jsCStack/Source/_javascript_Core/interpreter/Interpreter.cpp 2013-12-18 03:38:14 UTC (rev 160745)
+++ branches/jsCStack/Source/_javascript_Core/interpreter/Interpreter.cpp 2013-12-18 03:45:57 UTC (rev 160746)
@@ -65,6 +65,7 @@
#include "RegExpPrototype.h"
#include "Register.h"
#include "SamplingTool.h"
+#include "StackAlignment.h"
#include "StackVisitor.h"
#include "StrictEvalActivation.h"
#include "StrongInlines.h"
@@ -74,6 +75,7 @@
#include <limits.h>
#include <stdio.h>
#include <wtf/StackStats.h>
+#include <wtf/StdLibExtras.h>
#include <wtf/StringPrintStream.h>
#include <wtf/Threading.h>
#include <wtf/WTFThreadData.h>
@@ -156,7 +158,8 @@
{
if (!arguments) { // f.apply(x, arguments), with arguments unmodified.
unsigned argumentCountIncludingThis = callFrame->argumentCountIncludingThis();
- CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister - argumentCountIncludingThis - JSStack::CallFrameHeaderSize - 1);
+ unsigned paddedCalleeFrameOffset = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), -firstFreeRegister + argumentCountIncludingThis + JSStack::CallFrameHeaderSize + 1);
+ CallFrame* newCallFrame = CallFrame::create(callFrame->registers() - paddedCalleeFrameOffset);
if (argumentCountIncludingThis > Arguments::MaxArguments + 1 || !stack->grow(newCallFrame->registers())) {
callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
return 0;
@@ -165,7 +168,9 @@
}
if (arguments.isUndefinedOrNull()) {
- CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister - 1 - JSStack::CallFrameHeaderSize - 1);
+ unsigned argumentCountIncludingThis = 1;
+ unsigned paddedCalleeFrameOffset = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), -firstFreeRegister + argumentCountIncludingThis + JSStack::CallFrameHeaderSize + 1);
+ CallFrame* newCallFrame = CallFrame::create(callFrame->registers() - paddedCalleeFrameOffset);
if (!stack->grow(newCallFrame->registers())) {
callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
return 0;
@@ -181,7 +186,8 @@
if (asObject(arguments)->classInfo() == Arguments::info()) {
Arguments* argsObject = asArguments(arguments);
unsigned argCount = argsObject->length(callFrame);
- CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister - CallFrame::offsetFor(argCount + 1));
+ unsigned paddedCalleeFrameOffset = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), -firstFreeRegister + CallFrame::offsetFor(argCount + 1));
+ CallFrame* newCallFrame = CallFrame::create(callFrame->registers() - paddedCalleeFrameOffset);
if (argCount > Arguments::MaxArguments || !stack->grow(newCallFrame->registers())) {
callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
return 0;
@@ -192,7 +198,8 @@
if (isJSArray(arguments)) {
JSArray* array = asArray(arguments);
unsigned argCount = array->length();
- CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister - CallFrame::offsetFor(argCount + 1));
+ unsigned paddedCalleeFrameOffset = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), -firstFreeRegister + CallFrame::offsetFor(argCount + 1));
+ CallFrame* newCallFrame = CallFrame::create(callFrame->registers() - paddedCalleeFrameOffset);
if (argCount > Arguments::MaxArguments || !stack->grow(newCallFrame->registers())) {
callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
return 0;
@@ -202,7 +209,8 @@
JSObject* argObject = asObject(arguments);
unsigned argCount = argObject->get(callFrame, callFrame->propertyNames().length).toUInt32(callFrame);
- CallFrame* newCallFrame = CallFrame::create(callFrame->registers() + firstFreeRegister - CallFrame::offsetFor(argCount + 1));
+ unsigned paddedCalleeFrameOffset = WTF::roundUpToMultipleOf(stackAlignmentRegisters(), -firstFreeRegister + CallFrame::offsetFor(argCount + 1));
+ CallFrame* newCallFrame = CallFrame::create(callFrame->registers() - paddedCalleeFrameOffset);
if (argCount > Arguments::MaxArguments || !stack->grow(newCallFrame->registers())) {
callFrame->vm().throwException(callFrame, createStackOverflowError(callFrame));
return 0;
Modified: branches/jsCStack/Source/_javascript_Core/jit/JIT.cpp (160745 => 160746)
--- branches/jsCStack/Source/_javascript_Core/jit/JIT.cpp 2013-12-18 03:38:14 UTC (rev 160745)
+++ branches/jsCStack/Source/_javascript_Core/jit/JIT.cpp 2013-12-18 03:45:57 UTC (rev 160746)
@@ -547,7 +547,7 @@
Label functionBody = label();
checkStackPointerAlignment();
- addPtr(TrustedImm32(-frameRegisterCountFor(m_codeBlock) * sizeof(Register)), callFrameRegister, stackPointerRegister);
+ addPtr(TrustedImm32(-frameRegisterCountFor(m_codeBlock) * sizeof(Register) - maxFrameExtentForSlowPathCall), callFrameRegister, stackPointerRegister);
checkStackPointerAlignment();
privateCompileMainPass();
Modified: branches/jsCStack/Source/_javascript_Core/jit/JITCall.cpp (160745 => 160746)
--- branches/jsCStack/Source/_javascript_Core/jit/JITCall.cpp 2013-12-18 03:38:14 UTC (rev 160745)
+++ branches/jsCStack/Source/_javascript_Core/jit/JITCall.cpp 2013-12-18 03:45:57 UTC (rev 160746)
@@ -39,6 +39,7 @@
#include "RepatchBuffer.h"
#include "ResultType.h"
#include "SamplingTool.h"
+#include "StackAlignment.h"
#include "ThunkGenerators.h"
#include <wtf/StringPrintStream.h>
@@ -71,10 +72,14 @@
emitGetFromCallFrameHeader32(JSStack::ArgumentCount, regT0);
slowCase.append(branch32(Above, regT0, TrustedImm32(Arguments::MaxArguments + 1)));
// regT0: argumentCountIncludingThis
+ move(regT0, regT1);
+ add64(TrustedImm32(-firstFreeRegister + JSStack::CallFrameHeaderSize), regT1);
+ // regT1 now has the required frame size in Register units
+ // Round regT1 to next multiple of stackAlignmentRegisters()
+ add64(TrustedImm32(stackAlignmentRegisters() - 1), regT1);
+ and64(TrustedImm32(~(stackAlignmentRegisters() - 1)), regT1);
- move(regT0, regT1);
neg64(regT1);
- add64(TrustedImm32(firstFreeRegister - JSStack::CallFrameHeaderSize), regT1);
lshift64(TrustedImm32(3), regT1);
addPtr(callFrameRegister, regT1);
// regT1: newCallFrame
@@ -106,6 +111,7 @@
emitGetVirtualRegister(arguments, regT1);
callOperation(operationSizeAndAllocFrameForVarargs, regT1, firstFreeRegister);
+ move(returnValueGPR, stackPointerRegister);
emitGetVirtualRegister(thisValue, regT1);
emitGetVirtualRegister(arguments, regT2);
callOperation(operationLoadVarargs, returnValueGPR, regT1, regT2);
Modified: branches/jsCStack/Source/_javascript_Core/llint/LowLevelInterpreter.asm (160745 => 160746)
--- branches/jsCStack/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2013-12-18 03:38:14 UTC (rev 160745)
+++ branches/jsCStack/Source/_javascript_Core/llint/LowLevelInterpreter.asm 2013-12-18 03:45:57 UTC (rev 160746)
@@ -798,6 +798,10 @@
traceExecution()
callSlowPath(_llint_slow_path_size_and_alloc_frame_for_varargs)
branchIfException(_llint_throw_from_slow_path_trampoline)
+ loadp CodeBlock[cfr], t0
+ loadp CodeBlock::m_vm[t0], t0
+ loadp VM::newCallFrameReturnValue[t0], t0
+ move t0, sp
slowPathForCall(_llint_slow_path_call_varargs)