Error found in test262 on ARM: BinaryOpStub could call out to a built-in and...

Error found in test262 on ARM: BinaryOpStub could call out to a built-in and push parameters without an enclosing frame. This corrupted stackwalking.

BUG=
R=ulan@chromium.org

Review URL: https://codereview.chromium.org/14813029

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14665 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 5889699e
......@@ -2162,8 +2162,12 @@ void BinaryOpStub::GenerateSmiStub(MacroAssembler* masm) {
GenerateTypeTransition(masm);
__ bind(&call_runtime);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
}
__ Ret();
}
......@@ -2188,7 +2192,8 @@ void BinaryOpStub::GenerateBothStringStub(MacroAssembler* masm) {
__ CompareObjectType(right, r2, r2, FIRST_NONSTRING_TYPE);
__ b(ge, &call_runtime);
StringAddStub string_add_stub(NO_STRING_CHECK_IN_STUB);
StringAddStub string_add_stub((StringAddFlags)
(ERECT_FRAME | NO_STRING_CHECK_IN_STUB));
GenerateRegisterArgsPush(masm);
__ TailCallStub(&string_add_stub);
......@@ -2459,8 +2464,12 @@ void BinaryOpStub::GenerateInt32Stub(MacroAssembler* masm) {
}
__ bind(&call_runtime);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
}
__ Ret();
}
......@@ -2507,8 +2516,12 @@ void BinaryOpStub::GenerateNumberStub(MacroAssembler* masm) {
GenerateTypeTransition(masm);
__ bind(&call_runtime);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
}
__ Ret();
}
......@@ -2531,8 +2544,12 @@ void BinaryOpStub::GenerateGeneric(MacroAssembler* masm) {
}
__ bind(&call_runtime);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
}
__ Ret();
}
......@@ -2548,7 +2565,8 @@ void BinaryOpStub::GenerateAddStrings(MacroAssembler* masm) {
__ CompareObjectType(left, r2, r2, FIRST_NONSTRING_TYPE);
__ b(ge, &left_not_string);
StringAddStub string_add_left_stub(NO_STRING_CHECK_LEFT_IN_STUB);
StringAddStub string_add_left_stub((StringAddFlags)
(ERECT_FRAME | NO_STRING_CHECK_LEFT_IN_STUB));
GenerateRegisterArgsPush(masm);
__ TailCallStub(&string_add_left_stub);
......@@ -2558,7 +2576,8 @@ void BinaryOpStub::GenerateAddStrings(MacroAssembler* masm) {
__ CompareObjectType(right, r2, r2, FIRST_NONSTRING_TYPE);
__ b(ge, &call_runtime);
StringAddStub string_add_right_stub(NO_STRING_CHECK_RIGHT_IN_STUB);
StringAddStub string_add_right_stub((StringAddFlags)
(ERECT_FRAME | NO_STRING_CHECK_RIGHT_IN_STUB));
GenerateRegisterArgsPush(masm);
__ TailCallStub(&string_add_right_stub);
......@@ -5822,7 +5841,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
__ ldr(r1, MemOperand(sp, 0 * kPointerSize)); // Second argument.
// Make sure that both arguments are strings if not known in advance.
if (flags_ == NO_STRING_ADD_FLAGS) {
if ((flags_ & NO_STRING_ADD_FLAGS) != 0) {
__ JumpIfEitherSmi(r0, r1, &call_runtime);
// Load instance types.
__ ldr(r4, FieldMemOperand(r0, HeapObject::kMapOffset));
......@@ -6114,15 +6133,49 @@ void StringAddStub::Generate(MacroAssembler* masm) {
// Just jump to runtime to add the two strings.
__ bind(&call_runtime);
__ TailCallRuntime(Runtime::kStringAdd, 2, 1);
if ((flags_ & ERECT_FRAME) != 0) {
GenerateRegisterArgsPop(masm);
// Build a frame
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
__ CallRuntime(Runtime::kStringAdd, 2);
}
__ Ret();
} else {
__ TailCallRuntime(Runtime::kStringAdd, 2, 1);
}
if (call_builtin.is_linked()) {
__ bind(&call_builtin);
__ InvokeBuiltin(builtin_id, JUMP_FUNCTION);
if ((flags_ & ERECT_FRAME) != 0) {
GenerateRegisterArgsPop(masm);
// Build a frame
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
__ InvokeBuiltin(builtin_id, CALL_FUNCTION);
}
__ Ret();
} else {
__ InvokeBuiltin(builtin_id, JUMP_FUNCTION);
}
}
}
void StringAddStub::GenerateRegisterArgsPush(MacroAssembler* masm) {
__ push(r0);
__ push(r1);
}
void StringAddStub::GenerateRegisterArgsPop(MacroAssembler* masm) {
__ pop(r1);
__ pop(r0);
}
void StringAddStub::GenerateConvertArgument(MacroAssembler* masm,
int stack_offset,
Register arg,
......
......@@ -211,11 +211,13 @@ class StringHelper : public AllStatic {
// Flag that indicates how to generate code for the stub StringAddStub.
enum StringAddFlags {
NO_STRING_ADD_FLAGS = 0,
NO_STRING_ADD_FLAGS = 1 << 0,
// Omit left string check in stub (left is definitely a string).
NO_STRING_CHECK_LEFT_IN_STUB = 1 << 0,
NO_STRING_CHECK_LEFT_IN_STUB = 1 << 1,
// Omit right string check in stub (right is definitely a string).
NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 1,
NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 2,
// Stub needs a frame before calling the runtime
ERECT_FRAME = 1 << 3,
// Omit both string checks in stub.
NO_STRING_CHECK_IN_STUB =
NO_STRING_CHECK_LEFT_IN_STUB | NO_STRING_CHECK_RIGHT_IN_STUB
......@@ -241,6 +243,9 @@ class StringAddStub: public PlatformCodeStub {
Register scratch4,
Label* slow);
void GenerateRegisterArgsPush(MacroAssembler* masm);
void GenerateRegisterArgsPop(MacroAssembler* masm);
const StringAddFlags flags_;
};
......
......@@ -412,7 +412,7 @@ void ArmDebugger::Debug() {
HeapObject* obj = reinterpret_cast<HeapObject*>(*cur);
int value = *cur;
Heap* current_heap = v8::internal::Isolate::Current()->heap();
if (current_heap->Contains(obj) || ((value & 1) == 0)) {
if (((value & 1) == 0) || current_heap->Contains(obj)) {
PrintF(" (");
if ((value & 1) == 0) {
PrintF("smi %d", value / 2);
......
......@@ -232,37 +232,37 @@ void BinaryOpStub::Generate(MacroAssembler* masm) {
void BinaryOpStub::GenerateCallRuntime(MacroAssembler* masm) {
switch (op_) {
case Token::ADD:
__ InvokeBuiltin(Builtins::ADD, JUMP_FUNCTION);
__ InvokeBuiltin(Builtins::ADD, CALL_FUNCTION);
break;
case Token::SUB:
__ InvokeBuiltin(Builtins::SUB, JUMP_FUNCTION);
__ InvokeBuiltin(Builtins::SUB, CALL_FUNCTION);
break;
case Token::MUL:
__ InvokeBuiltin(Builtins::MUL, JUMP_FUNCTION);
__ InvokeBuiltin(Builtins::MUL, CALL_FUNCTION);
break;
case Token::DIV:
__ InvokeBuiltin(Builtins::DIV, JUMP_FUNCTION);
__ InvokeBuiltin(Builtins::DIV, CALL_FUNCTION);
break;
case Token::MOD:
__ InvokeBuiltin(Builtins::MOD, JUMP_FUNCTION);
__ InvokeBuiltin(Builtins::MOD, CALL_FUNCTION);
break;
case Token::BIT_OR:
__ InvokeBuiltin(Builtins::BIT_OR, JUMP_FUNCTION);
__ InvokeBuiltin(Builtins::BIT_OR, CALL_FUNCTION);
break;
case Token::BIT_AND:
__ InvokeBuiltin(Builtins::BIT_AND, JUMP_FUNCTION);
__ InvokeBuiltin(Builtins::BIT_AND, CALL_FUNCTION);
break;
case Token::BIT_XOR:
__ InvokeBuiltin(Builtins::BIT_XOR, JUMP_FUNCTION);
__ InvokeBuiltin(Builtins::BIT_XOR, CALL_FUNCTION);
break;
case Token::SAR:
__ InvokeBuiltin(Builtins::SAR, JUMP_FUNCTION);
__ InvokeBuiltin(Builtins::SAR, CALL_FUNCTION);
break;
case Token::SHR:
__ InvokeBuiltin(Builtins::SHR, JUMP_FUNCTION);
__ InvokeBuiltin(Builtins::SHR, CALL_FUNCTION);
break;
case Token::SHL:
__ InvokeBuiltin(Builtins::SHL, JUMP_FUNCTION);
__ InvokeBuiltin(Builtins::SHL, CALL_FUNCTION);
break;
default:
UNREACHABLE();
......
......@@ -1227,6 +1227,14 @@ void BinaryOpStub::GenerateTypeTransitionWithSavedArgs(MacroAssembler* masm) {
}
static void BinaryOpStub_GenerateRegisterArgsPop(MacroAssembler* masm) {
__ pop(ecx);
__ pop(eax);
__ pop(edx);
__ push(ecx);
}
static void BinaryOpStub_GenerateSmiCode(
MacroAssembler* masm,
Label* slow,
......@@ -1662,7 +1670,6 @@ void BinaryOpStub::GenerateSmiStub(MacroAssembler* masm) {
case Token::SUB:
case Token::MUL:
case Token::DIV:
GenerateRegisterArgsPush(masm);
break;
case Token::MOD:
case Token::BIT_OR:
......@@ -1671,11 +1678,19 @@ void BinaryOpStub::GenerateSmiStub(MacroAssembler* masm) {
case Token::SAR:
case Token::SHL:
case Token::SHR:
BinaryOpStub_GenerateRegisterArgsPop(masm);
break;
default:
UNREACHABLE();
}
GenerateCallRuntime(masm);
{
FrameScope scope(masm, StackFrame::INTERNAL);
__ push(edx);
__ push(eax);
GenerateCallRuntime(masm);
}
__ ret(0);
}
......@@ -1700,7 +1715,8 @@ void BinaryOpStub::GenerateBothStringStub(MacroAssembler* masm) {
__ CmpObjectType(right, FIRST_NONSTRING_TYPE, ecx);
__ j(above_equal, &call_runtime, Label::kNear);
StringAddStub string_add_stub(NO_STRING_CHECK_IN_STUB);
StringAddStub string_add_stub((StringAddFlags)
(ERECT_FRAME | NO_STRING_CHECK_IN_STUB));
GenerateRegisterArgsPush(masm);
__ TailCallStub(&string_add_stub);
......@@ -1892,7 +1908,6 @@ void BinaryOpStub::GenerateInt32Stub(MacroAssembler* masm) {
case Token::SUB:
case Token::MUL:
case Token::DIV:
GenerateRegisterArgsPush(masm);
break;
case Token::MOD:
return; // Handled above.
......@@ -1902,11 +1917,19 @@ void BinaryOpStub::GenerateInt32Stub(MacroAssembler* masm) {
case Token::SAR:
case Token::SHL:
case Token::SHR:
BinaryOpStub_GenerateRegisterArgsPop(masm);
break;
default:
UNREACHABLE();
}
GenerateCallRuntime(masm);
{
FrameScope scope(masm, StackFrame::INTERNAL);
__ push(edx);
__ push(eax);
GenerateCallRuntime(masm);
}
__ ret(0);
}
......@@ -2109,7 +2132,6 @@ void BinaryOpStub::GenerateNumberStub(MacroAssembler* masm) {
case Token::MUL:
case Token::DIV:
case Token::MOD:
GenerateRegisterArgsPush(masm);
break;
case Token::BIT_OR:
case Token::BIT_AND:
......@@ -2117,11 +2139,19 @@ void BinaryOpStub::GenerateNumberStub(MacroAssembler* masm) {
case Token::SAR:
case Token::SHL:
case Token::SHR:
BinaryOpStub_GenerateRegisterArgsPop(masm);
break;
default:
UNREACHABLE();
}
GenerateCallRuntime(masm);
{
FrameScope scope(masm, StackFrame::INTERNAL);
__ push(edx);
__ push(eax);
GenerateCallRuntime(masm);
}
__ ret(0);
}
......@@ -2287,7 +2317,6 @@ void BinaryOpStub::GenerateGeneric(MacroAssembler* masm) {
case Token::SUB:
case Token::MUL:
case Token::DIV:
GenerateRegisterArgsPush(masm);
break;
case Token::MOD:
case Token::BIT_OR:
......@@ -2296,11 +2325,19 @@ void BinaryOpStub::GenerateGeneric(MacroAssembler* masm) {
case Token::SAR:
case Token::SHL:
case Token::SHR:
BinaryOpStub_GenerateRegisterArgsPop(masm);
break;
default:
UNREACHABLE();
}
GenerateCallRuntime(masm);
{
FrameScope scope(masm, StackFrame::INTERNAL);
__ push(edx);
__ push(eax);
GenerateCallRuntime(masm);
}
__ ret(0);
}
......@@ -2317,7 +2354,8 @@ void BinaryOpStub::GenerateAddStrings(MacroAssembler* masm) {
__ CmpObjectType(left, FIRST_NONSTRING_TYPE, ecx);
__ j(above_equal, &left_not_string, Label::kNear);
StringAddStub string_add_left_stub(NO_STRING_CHECK_LEFT_IN_STUB);
StringAddStub string_add_left_stub((StringAddFlags)
(ERECT_FRAME | NO_STRING_CHECK_LEFT_IN_STUB));
GenerateRegisterArgsPush(masm);
__ TailCallStub(&string_add_left_stub);
......@@ -2327,7 +2365,8 @@ void BinaryOpStub::GenerateAddStrings(MacroAssembler* masm) {
__ CmpObjectType(right, FIRST_NONSTRING_TYPE, ecx);
__ j(above_equal, &call_runtime, Label::kNear);
StringAddStub string_add_right_stub(NO_STRING_CHECK_RIGHT_IN_STUB);
StringAddStub string_add_right_stub((StringAddFlags)
(ERECT_FRAME | NO_STRING_CHECK_RIGHT_IN_STUB));
GenerateRegisterArgsPush(masm);
__ TailCallStub(&string_add_right_stub);
......@@ -5737,7 +5776,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
__ mov(edx, Operand(esp, 1 * kPointerSize)); // Second argument.
// Make sure that both arguments are strings if not known in advance.
if (flags_ == NO_STRING_ADD_FLAGS) {
if ((flags_ & NO_STRING_ADD_FLAGS) != 0) {
__ JumpIfSmi(eax, &call_runtime);
__ CmpObjectType(eax, FIRST_NONSTRING_TYPE, ebx);
__ j(above_equal, &call_runtime);
......@@ -6045,15 +6084,52 @@ void StringAddStub::Generate(MacroAssembler* masm) {
__ Drop(2);
// Just jump to runtime to add the two strings.
__ bind(&call_runtime);
__ TailCallRuntime(Runtime::kStringAdd, 2, 1);
if ((flags_ & ERECT_FRAME) != 0) {
GenerateRegisterArgsPop(masm, ecx);
// Build a frame
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
__ CallRuntime(Runtime::kStringAdd, 2);
}
__ ret(0);
} else {
__ TailCallRuntime(Runtime::kStringAdd, 2, 1);
}
if (call_builtin.is_linked()) {
__ bind(&call_builtin);
__ InvokeBuiltin(builtin_id, JUMP_FUNCTION);
if ((flags_ & ERECT_FRAME) != 0) {
GenerateRegisterArgsPop(masm, ecx);
// Build a frame
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
__ InvokeBuiltin(builtin_id, CALL_FUNCTION);
}
__ ret(0);
} else {
__ InvokeBuiltin(builtin_id, JUMP_FUNCTION);
}
}
}
void StringAddStub::GenerateRegisterArgsPush(MacroAssembler* masm) {
__ push(eax);
__ push(edx);
}
void StringAddStub::GenerateRegisterArgsPop(MacroAssembler* masm,
Register temp) {
__ pop(temp);
__ pop(edx);
__ pop(eax);
__ push(temp);
}
void StringAddStub::GenerateConvertArgument(MacroAssembler* masm,
int stack_offset,
Register arg,
......
......@@ -218,13 +218,14 @@ class StringHelper : public AllStatic {
};
// Flag that indicates how to generate code for the stub StringAddStub.
enum StringAddFlags {
NO_STRING_ADD_FLAGS = 0,
NO_STRING_ADD_FLAGS = 1 << 0,
// Omit left string check in stub (left is definitely a string).
NO_STRING_CHECK_LEFT_IN_STUB = 1 << 0,
NO_STRING_CHECK_LEFT_IN_STUB = 1 << 1,
// Omit right string check in stub (right is definitely a string).
NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 1,
NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 2,
// Stub needs a frame before calling the runtime
ERECT_FRAME = 1 << 3,
// Omit both string checks in stub.
NO_STRING_CHECK_IN_STUB =
NO_STRING_CHECK_LEFT_IN_STUB | NO_STRING_CHECK_RIGHT_IN_STUB
......@@ -249,6 +250,9 @@ class StringAddStub: public PlatformCodeStub {
Register scratch3,
Label* slow);
void GenerateRegisterArgsPush(MacroAssembler* masm);
void GenerateRegisterArgsPop(MacroAssembler* masm, Register temp);
const StringAddFlags flags_;
};
......
......@@ -1272,6 +1272,17 @@ static void BinaryOpStub_GenerateFloatingPointCode(MacroAssembler* masm,
}
static void BinaryOpStub_GenerateRegisterArgsPushUnderReturn(
MacroAssembler* masm) {
// Push arguments, but ensure they are under the return address
// for a tail call.
__ pop(rcx);
__ push(rdx);
__ push(rax);
__ push(rcx);
}
void BinaryOpStub::GenerateAddStrings(MacroAssembler* masm) {
ASSERT(op_ == Token::ADD);
Label left_not_string, call_runtime;
......@@ -1284,8 +1295,9 @@ void BinaryOpStub::GenerateAddStrings(MacroAssembler* masm) {
__ JumpIfSmi(left, &left_not_string, Label::kNear);
__ CmpObjectType(left, FIRST_NONSTRING_TYPE, rcx);
__ j(above_equal, &left_not_string, Label::kNear);
StringAddStub string_add_left_stub(NO_STRING_CHECK_LEFT_IN_STUB);
GenerateRegisterArgsPush(masm);
StringAddStub string_add_left_stub((StringAddFlags)
(ERECT_FRAME | NO_STRING_CHECK_LEFT_IN_STUB));
BinaryOpStub_GenerateRegisterArgsPushUnderReturn(masm);
__ TailCallStub(&string_add_left_stub);
// Left operand is not a string, test right.
......@@ -1294,8 +1306,9 @@ void BinaryOpStub::GenerateAddStrings(MacroAssembler* masm) {
__ CmpObjectType(right, FIRST_NONSTRING_TYPE, rcx);
__ j(above_equal, &call_runtime, Label::kNear);
StringAddStub string_add_right_stub(NO_STRING_CHECK_RIGHT_IN_STUB);
GenerateRegisterArgsPush(masm);
StringAddStub string_add_right_stub((StringAddFlags)
(ERECT_FRAME | NO_STRING_CHECK_RIGHT_IN_STUB));
BinaryOpStub_GenerateRegisterArgsPushUnderReturn(masm);
__ TailCallStub(&string_add_right_stub);
// Neither argument is a string.
......@@ -1322,8 +1335,12 @@ void BinaryOpStub::GenerateSmiStub(MacroAssembler* masm) {
if (call_runtime.is_linked()) {
__ bind(&call_runtime);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
}
__ Ret();
}
}
......@@ -1356,8 +1373,9 @@ void BinaryOpStub::GenerateBothStringStub(MacroAssembler* masm) {
__ CmpObjectType(right, FIRST_NONSTRING_TYPE, rcx);
__ j(above_equal, &call_runtime);
StringAddStub string_add_stub(NO_STRING_CHECK_IN_STUB);
GenerateRegisterArgsPush(masm);
StringAddStub string_add_stub((StringAddFlags)
(ERECT_FRAME | NO_STRING_CHECK_IN_STUB));
BinaryOpStub_GenerateRegisterArgsPushUnderReturn(masm);
__ TailCallStub(&string_add_stub);
__ bind(&call_runtime);
......@@ -1442,8 +1460,12 @@ void BinaryOpStub::GenerateNumberStub(MacroAssembler* masm) {
GenerateTypeTransition(masm);
__ bind(&gc_required);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
}
__ Ret();
}
......@@ -1462,8 +1484,12 @@ void BinaryOpStub::GenerateGeneric(MacroAssembler* masm) {
}
__ bind(&call_runtime);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
GenerateCallRuntime(masm);
}
__ Ret();
}
......@@ -1507,10 +1533,8 @@ static void BinaryOpStub_GenerateHeapResultAllocation(MacroAssembler* masm,
void BinaryOpStub::GenerateRegisterArgsPush(MacroAssembler* masm) {
__ pop(rcx);
__ push(rdx);
__ push(rax);
__ push(rcx);
}
......@@ -4791,7 +4815,7 @@ void StringAddStub::Generate(MacroAssembler* masm) {
__ movq(rdx, Operand(rsp, 1 * kPointerSize)); // Second argument (right).
// Make sure that both arguments are strings if not known in advance.
if (flags_ == NO_STRING_ADD_FLAGS) {
if ((flags_ & NO_STRING_ADD_FLAGS) != 0) {
__ JumpIfSmi(rax, &call_runtime);
__ CmpObjectType(rax, FIRST_NONSTRING_TYPE, r8);
__ j(above_equal, &call_runtime);
......@@ -5068,15 +5092,53 @@ void StringAddStub::Generate(MacroAssembler* masm) {
// Just jump to runtime to add the two strings.
__ bind(&call_runtime);
__ TailCallRuntime(Runtime::kStringAdd, 2, 1);
if ((flags_ & ERECT_FRAME) != 0) {
GenerateRegisterArgsPop(masm, rcx);
// Build a frame
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
__ CallRuntime(Runtime::kStringAdd, 2);
}
__ Ret();
} else {
__ TailCallRuntime(Runtime::kStringAdd, 2, 1);
}
if (call_builtin.is_linked()) {
__ bind(&call_builtin);
__ InvokeBuiltin(builtin_id, JUMP_FUNCTION);
if ((flags_ & ERECT_FRAME) != 0) {
GenerateRegisterArgsPop(masm, rcx);
// Build a frame
{
FrameScope scope(masm, StackFrame::INTERNAL);
GenerateRegisterArgsPush(masm);
__ InvokeBuiltin(builtin_id, CALL_FUNCTION);
}
__ Ret();
} else {
__ InvokeBuiltin(builtin_id, JUMP_FUNCTION);
}
}
}
void StringAddStub::GenerateRegisterArgsPush(MacroAssembler* masm) {
__ push(rax);
__ push(rdx);
}
void StringAddStub::GenerateRegisterArgsPop(MacroAssembler* masm,
Register temp) {
__ pop(temp);
__ pop(rdx);
__ pop(rax);
__ push(temp);
}
void StringAddStub::GenerateConvertArgument(MacroAssembler* masm,
int stack_offset,
Register arg,
......
......@@ -207,11 +207,13 @@ class StringHelper : public AllStatic {
// Flag that indicates how to generate code for the stub StringAddStub.
enum StringAddFlags {
NO_STRING_ADD_FLAGS = 0,
NO_STRING_ADD_FLAGS = 1 << 0,
// Omit left string check in stub (left is definitely a string).
NO_STRING_CHECK_LEFT_IN_STUB = 1 << 0,
NO_STRING_CHECK_LEFT_IN_STUB = 1 << 1,
// Omit right string check in stub (right is definitely a string).
NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 1,
NO_STRING_CHECK_RIGHT_IN_STUB = 1 << 2,
// Stub needs a frame before calling the runtime
ERECT_FRAME = 1 << 3,
// Omit both string checks in stub.
NO_STRING_CHECK_IN_STUB =
NO_STRING_CHECK_LEFT_IN_STUB | NO_STRING_CHECK_RIGHT_IN_STUB
......@@ -236,6 +238,9 @@ class StringAddStub: public PlatformCodeStub {
Register scratch3,
Label* slow);
void GenerateRegisterArgsPush(MacroAssembler* masm);
void GenerateRegisterArgsPop(MacroAssembler* masm, Register temp);
const StringAddFlags flags_;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment