Commit 54f68eac authored by whesse@chromium.org's avatar whesse@chromium.org

Stop pushing arguments onto the stack in CompareStub until just before calling runtime.

This is a fixed version of change 5097, which had the problem that LoadFloatOperands tried to load the arguments from the stack.
Review URL: http://codereview.chromium.org/3040010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5103 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f32e2b70
...@@ -11839,12 +11839,6 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -11839,12 +11839,6 @@ void CompareStub::Generate(MacroAssembler* masm) {
__ bind(&slow); __ bind(&slow);
} }
// Push arguments below the return address.
__ pop(ecx);
__ push(eax);
__ push(edx);
__ push(ecx);
// Generate the number comparison code. // Generate the number comparison code.
if (include_number_compare_) { if (include_number_compare_) {
Label non_number_comparison; Label non_number_comparison;
...@@ -11864,33 +11858,32 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -11864,33 +11858,32 @@ void CompareStub::Generate(MacroAssembler* masm) {
__ cmov(above, eax, Operand(ecx)); __ cmov(above, eax, Operand(ecx));
__ mov(ecx, Immediate(Smi::FromInt(-1))); __ mov(ecx, Immediate(Smi::FromInt(-1)));
__ cmov(below, eax, Operand(ecx)); __ cmov(below, eax, Operand(ecx));
__ ret(2 * kPointerSize); __ ret(0);
} else { } else {
FloatingPointHelper::CheckFloatOperands( FloatingPointHelper::CheckFloatOperands(
masm, &non_number_comparison, ebx); masm, &non_number_comparison, ebx);
FloatingPointHelper::LoadFloatOperands(masm, ecx); FloatingPointHelper::LoadFloatOperand(masm, eax);
FloatingPointHelper::LoadFloatOperand(masm, edx);
__ FCmp(); __ FCmp();
// Don't base result on EFLAGS when a NaN is involved. // Don't base result on EFLAGS when a NaN is involved.
__ j(parity_even, &unordered, not_taken); __ j(parity_even, &unordered, not_taken);
Label below_label, above_label; Label below_label, above_label;
// Return a result of -1, 0, or 1, based on EFLAGS. In all cases remove // Return a result of -1, 0, or 1, based on EFLAGS.
// two arguments from the stack as they have been pushed in preparation
// of a possible runtime call.
__ j(below, &below_label, not_taken); __ j(below, &below_label, not_taken);
__ j(above, &above_label, not_taken); __ j(above, &above_label, not_taken);
__ xor_(eax, Operand(eax)); __ xor_(eax, Operand(eax));
__ ret(2 * kPointerSize); __ ret(0);
__ bind(&below_label); __ bind(&below_label);
__ mov(eax, Immediate(Smi::FromInt(-1))); __ mov(eax, Immediate(Smi::FromInt(-1)));
__ ret(2 * kPointerSize); __ ret(0);
__ bind(&above_label); __ bind(&above_label);
__ mov(eax, Immediate(Smi::FromInt(1))); __ mov(eax, Immediate(Smi::FromInt(1)));
__ ret(2 * kPointerSize); __ ret(0);
} }
// If one of the numbers was NaN, then the result is always false. // If one of the numbers was NaN, then the result is always false.
...@@ -11902,7 +11895,7 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -11902,7 +11895,7 @@ void CompareStub::Generate(MacroAssembler* masm) {
} else { } else {
__ mov(eax, Immediate(Smi::FromInt(-1))); __ mov(eax, Immediate(Smi::FromInt(-1)));
} }
__ ret(2 * kPointerSize); // eax, edx were pushed __ ret(0);
// The number comparison code did not provide a valid result. // The number comparison code did not provide a valid result.
__ bind(&non_number_comparison); __ bind(&non_number_comparison);
...@@ -11917,7 +11910,7 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -11917,7 +11910,7 @@ void CompareStub::Generate(MacroAssembler* masm) {
// We've already checked for object identity, so if both operands // We've already checked for object identity, so if both operands
// are symbols they aren't equal. Register eax already holds a // are symbols they aren't equal. Register eax already holds a
// non-zero value, which indicates not equal, so just return. // non-zero value, which indicates not equal, so just return.
__ ret(2 * kPointerSize); __ ret(0);
} }
__ bind(&check_for_strings); __ bind(&check_for_strings);
...@@ -11970,14 +11963,12 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -11970,14 +11963,12 @@ void CompareStub::Generate(MacroAssembler* masm) {
__ bind(&return_unequal); __ bind(&return_unequal);
// Return non-equal by returning the non-zero object pointer in eax, // Return non-equal by returning the non-zero object pointer in eax,
// or return equal if we fell through to here. // or return equal if we fell through to here.
__ ret(2 * kPointerSize); // rax, rdx were pushed __ ret(0); // rax, rdx were pushed
__ bind(&not_both_objects); __ bind(&not_both_objects);
} }
// must swap argument order // Push arguments below the return address.
__ pop(ecx); __ pop(ecx);
__ pop(edx);
__ pop(eax);
__ push(edx); __ push(edx);
__ push(eax); __ push(eax);
...@@ -13554,19 +13545,19 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, ...@@ -13554,19 +13545,19 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
ASSERT_EQ(0, EQUAL); ASSERT_EQ(0, EQUAL);
ASSERT_EQ(0, kSmiTag); ASSERT_EQ(0, kSmiTag);
__ Set(eax, Immediate(Smi::FromInt(EQUAL))); __ Set(eax, Immediate(Smi::FromInt(EQUAL)));
__ ret(2 * kPointerSize); __ ret(0);
__ bind(&result_not_equal); __ bind(&result_not_equal);
__ j(greater, &result_greater); __ j(greater, &result_greater);
// Result is LESS. // Result is LESS.
__ Set(eax, Immediate(Smi::FromInt(LESS))); __ Set(eax, Immediate(Smi::FromInt(LESS)));
__ ret(2 * kPointerSize); __ ret(0);
// Result is GREATER. // Result is GREATER.
__ bind(&result_greater); __ bind(&result_greater);
__ Set(eax, Immediate(Smi::FromInt(GREATER))); __ Set(eax, Immediate(Smi::FromInt(GREATER)));
__ ret(2 * kPointerSize); __ ret(0);
} }
...@@ -13596,6 +13587,10 @@ void StringCompareStub::Generate(MacroAssembler* masm) { ...@@ -13596,6 +13587,10 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
__ JumpIfNotBothSequentialAsciiStrings(edx, eax, ecx, ebx, &runtime); __ JumpIfNotBothSequentialAsciiStrings(edx, eax, ecx, ebx, &runtime);
// Compare flat ascii strings. // Compare flat ascii strings.
// Drop arguments from the stack.
__ pop(ecx);
__ add(Operand(esp), Immediate(2 * kPointerSize));
__ push(ecx);
GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx, edi); GenerateCompareFlatAsciiStrings(masm, edx, eax, ecx, ebx, edi);
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
......
...@@ -10288,12 +10288,6 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -10288,12 +10288,6 @@ void CompareStub::Generate(MacroAssembler* masm) {
__ bind(&slow); __ bind(&slow);
} }
// Push arguments below the return address to prepare jump to builtin.
__ pop(rcx);
__ push(rax);
__ push(rdx);
__ push(rcx);
// Generate the number comparison code. // Generate the number comparison code.
if (include_number_compare_) { if (include_number_compare_) {
Label non_number_comparison; Label non_number_comparison;
...@@ -10309,7 +10303,7 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -10309,7 +10303,7 @@ void CompareStub::Generate(MacroAssembler* masm) {
__ setcc(above, rax); __ setcc(above, rax);
__ setcc(below, rcx); __ setcc(below, rcx);
__ subq(rax, rcx); __ subq(rax, rcx);
__ ret(2 * kPointerSize); // rax, rdx were pushed __ ret(0);
// If one of the numbers was NaN, then the result is always false. // If one of the numbers was NaN, then the result is always false.
// The cc is never not-equal. // The cc is never not-equal.
...@@ -10320,7 +10314,7 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -10320,7 +10314,7 @@ void CompareStub::Generate(MacroAssembler* masm) {
} else { } else {
__ Set(rax, -1); __ Set(rax, -1);
} }
__ ret(2 * kPointerSize); // rax, rdx were pushed __ ret(0);
// The number comparison code did not provide a valid result. // The number comparison code did not provide a valid result.
__ bind(&non_number_comparison); __ bind(&non_number_comparison);
...@@ -10335,7 +10329,7 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -10335,7 +10329,7 @@ void CompareStub::Generate(MacroAssembler* masm) {
// We've already checked for object identity, so if both operands // We've already checked for object identity, so if both operands
// are symbols they aren't equal. Register eax (not rax) already holds a // are symbols they aren't equal. Register eax (not rax) already holds a
// non-zero value, which indicates not equal, so just return. // non-zero value, which indicates not equal, so just return.
__ ret(2 * kPointerSize); __ ret(0);
} }
__ bind(&check_for_strings); __ bind(&check_for_strings);
...@@ -10386,14 +10380,12 @@ void CompareStub::Generate(MacroAssembler* masm) { ...@@ -10386,14 +10380,12 @@ void CompareStub::Generate(MacroAssembler* masm) {
__ bind(&return_unequal); __ bind(&return_unequal);
// Return non-equal by returning the non-zero object pointer in eax, // Return non-equal by returning the non-zero object pointer in eax,
// or return equal if we fell through to here. // or return equal if we fell through to here.
__ ret(2 * kPointerSize); // rax, rdx were pushed __ ret(0);
__ bind(&not_both_objects); __ bind(&not_both_objects);
} }
// must swap argument order // Push arguments below the return address to prepare jump to builtin.
__ pop(rcx); __ pop(rcx);
__ pop(rdx);
__ pop(rax);
__ push(rdx); __ push(rdx);
__ push(rax); __ push(rax);
...@@ -11970,7 +11962,7 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, ...@@ -11970,7 +11962,7 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
// Result is EQUAL. // Result is EQUAL.
__ Move(rax, Smi::FromInt(EQUAL)); __ Move(rax, Smi::FromInt(EQUAL));
__ ret(2 * kPointerSize); __ ret(0);
Label result_greater; Label result_greater;
__ bind(&result_not_equal); __ bind(&result_not_equal);
...@@ -11979,12 +11971,12 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm, ...@@ -11979,12 +11971,12 @@ void StringCompareStub::GenerateCompareFlatAsciiStrings(MacroAssembler* masm,
// Result is LESS. // Result is LESS.
__ Move(rax, Smi::FromInt(LESS)); __ Move(rax, Smi::FromInt(LESS));
__ ret(2 * kPointerSize); __ ret(0);
// Result is GREATER. // Result is GREATER.
__ bind(&result_greater); __ bind(&result_greater);
__ Move(rax, Smi::FromInt(GREATER)); __ Move(rax, Smi::FromInt(GREATER));
__ ret(2 * kPointerSize); __ ret(0);
} }
...@@ -12014,6 +12006,10 @@ void StringCompareStub::Generate(MacroAssembler* masm) { ...@@ -12014,6 +12006,10 @@ void StringCompareStub::Generate(MacroAssembler* masm) {
// Inline comparison of ascii strings. // Inline comparison of ascii strings.
__ IncrementCounter(&Counters::string_compare_native, 1); __ IncrementCounter(&Counters::string_compare_native, 1);
// Drop arguments from the stack
__ pop(rcx);
__ addq(rsp, Immediate(2 * kPointerSize));
__ push(rcx);
GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8); GenerateCompareFlatAsciiStrings(masm, rdx, rax, rcx, rbx, rdi, r8);
// Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
......
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