Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(657)

Unified Diff: test/cctest/test-macro-assembler-x64.cc

Issue 2885018: X64: Added register holding Smi::FromInt(1). (Closed)
Patch Set: Addressed review comments Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/x64/register-allocator-x64-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-macro-assembler-x64.cc
diff --git a/test/cctest/test-macro-assembler-x64.cc b/test/cctest/test-macro-assembler-x64.cc
index dd974986114ee328685b2ee511918324d9aa1e30..3d2b91b544ebf7dd0bbc65d8217d1b688463e29d 100755
--- a/test/cctest/test-macro-assembler-x64.cc
+++ b/test/cctest/test-macro-assembler-x64.cc
@@ -57,10 +57,9 @@ using v8::internal::rsp;
using v8::internal::r8;
using v8::internal::r9;
using v8::internal::r11;
-using v8::internal::r12; // Remember: r12..r15 are callee save!
+using v8::internal::r12;
using v8::internal::r13;
using v8::internal::r14;
-using v8::internal::r15;
using v8::internal::times_pointer_size;
using v8::internal::FUNCTION_CAST;
using v8::internal::CodeDesc;
@@ -92,6 +91,24 @@ typedef int (*F0)();
#define __ masm->
+
+static void EntryCode(MacroAssembler* masm) {
+ // Smi constant register is callee save.
+ __ push(v8::internal::kSmiConstantRegister);
+ __ InitializeSmiConstantRegister();
+}
+
+
+static void ExitCode(MacroAssembler* masm) {
+ // Return -1 if kSmiConstantRegister was clobbered during the test.
+ __ Move(rdx, Smi::FromInt(1));
+ __ cmpq(rdx, v8::internal::kSmiConstantRegister);
+ __ movq(rdx, Immediate(-1));
+ __ cmovq(not_equal, rax, rdx);
+ __ pop(v8::internal::kSmiConstantRegister);
+}
+
+
TEST(Smi) {
// Check that C++ Smi operations work as expected.
int64_t test_numbers[] = {
@@ -139,6 +156,7 @@ TEST(SmiMove) {
MacroAssembler assembler(buffer, static_cast<int>(actual_size));
MacroAssembler* masm = &assembler; // Create a pointer for the __ macro.
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestMoveSmi(masm, &exit, 1, Smi::FromInt(0));
@@ -156,6 +174,7 @@ TEST(SmiMove) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -225,6 +244,7 @@ TEST(SmiCompare) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestSmiCompare(masm, &exit, 0x10, 0, 0);
@@ -249,6 +269,7 @@ TEST(SmiCompare) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -272,6 +293,7 @@ TEST(Integer32ToSmi) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
__ movq(rax, Immediate(1)); // Test number.
@@ -349,6 +371,7 @@ TEST(Integer32ToSmi) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -397,6 +420,7 @@ TEST(Integer64PlusConstantToSmi) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
int64_t twice_max = static_cast<int64_t>(Smi::kMaxValue) * 2;
@@ -416,6 +440,7 @@ TEST(Integer64PlusConstantToSmi) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -438,6 +463,7 @@ TEST(SmiCheck) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
Condition cond;
@@ -613,6 +639,7 @@ TEST(SmiCheck) {
__ xor_(rax, rax);
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -683,6 +710,7 @@ TEST(SmiNeg) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestSmiNeg(masm, &exit, 0x10, 0);
@@ -696,6 +724,7 @@ TEST(SmiNeg) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -768,6 +797,7 @@ TEST(SmiAdd) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
// No-overflow tests.
@@ -782,6 +812,7 @@ TEST(SmiAdd) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -955,6 +986,7 @@ TEST(SmiSub) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
SmiSubTest(masm, &exit, 0x10, 1, 2);
@@ -977,6 +1009,7 @@ TEST(SmiSub) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -1042,6 +1075,7 @@ TEST(SmiMul) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestSmiMul(masm, &exit, 0x10, 0, 0);
@@ -1061,6 +1095,7 @@ TEST(SmiMul) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -1081,51 +1116,51 @@ void TestSmiDiv(MacroAssembler* masm, Label* exit, int id, int x, int y) {
#endif
bool fraction = !division_by_zero && !overflow && (x % y != 0);
__ Move(r11, Smi::FromInt(x));
- __ Move(r12, Smi::FromInt(y));
+ __ Move(r14, Smi::FromInt(y));
if (!fraction && !overflow && !negative_zero && !division_by_zero) {
// Division succeeds
__ movq(rcx, r11);
- __ movq(r15, Immediate(id));
+ __ movq(r12, Immediate(id));
int result = x / y;
__ Move(r8, Smi::FromInt(result));
- __ SmiDiv(r9, rcx, r12, exit);
- // Might have destroyed rcx and r12.
- __ incq(r15);
+ __ SmiDiv(r9, rcx, r14, exit);
+ // Might have destroyed rcx and r14.
+ __ incq(r12);
__ SmiCompare(r9, r8);
__ j(not_equal, exit);
- __ incq(r15);
+ __ incq(r12);
__ movq(rcx, r11);
- __ Move(r12, Smi::FromInt(y));
+ __ Move(r14, Smi::FromInt(y));
__ SmiCompare(rcx, r11);
__ j(not_equal, exit);
- __ incq(r15);
- __ SmiDiv(rcx, rcx, r12, exit);
+ __ incq(r12);
+ __ SmiDiv(rcx, rcx, r14, exit);
- __ incq(r15);
+ __ incq(r12);
__ SmiCompare(rcx, r8);
__ j(not_equal, exit);
} else {
// Division fails.
- __ movq(r15, Immediate(id + 8));
+ __ movq(r12, Immediate(id + 8));
Label fail_ok, fail_ok2;
__ movq(rcx, r11);
- __ SmiDiv(r9, rcx, r12, &fail_ok);
+ __ SmiDiv(r9, rcx, r14, &fail_ok);
__ jmp(exit);
__ bind(&fail_ok);
- __ incq(r15);
+ __ incq(r12);
__ SmiCompare(rcx, r11);
__ j(not_equal, exit);
- __ incq(r15);
- __ SmiDiv(rcx, rcx, r12, &fail_ok2);
+ __ incq(r12);
+ __ SmiDiv(rcx, rcx, r14, &fail_ok2);
__ jmp(exit);
__ bind(&fail_ok2);
- __ incq(r15);
+ __ incq(r12);
__ SmiCompare(rcx, r11);
__ j(not_equal, exit);
}
@@ -1145,10 +1180,11 @@ TEST(SmiDiv) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
+ __ push(r14);
__ push(r12);
- __ push(r15);
TestSmiDiv(masm, &exit, 0x10, 1, 1);
TestSmiDiv(masm, &exit, 0x20, 1, 0);
TestSmiDiv(masm, &exit, 0x30, -1, 0);
@@ -1170,11 +1206,12 @@ TEST(SmiDiv) {
TestSmiDiv(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue);
TestSmiDiv(masm, &exit, 0x140, Smi::kMinValue, -1);
- __ xor_(r15, r15); // Success.
+ __ xor_(r12, r12); // Success.
__ bind(&exit);
- __ movq(rax, r15);
- __ pop(r15);
+ __ movq(rax, r12);
__ pop(r12);
+ __ pop(r14);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -1192,47 +1229,47 @@ void TestSmiMod(MacroAssembler* masm, Label* exit, int id, int x, int y) {
bool negative_zero = (!fraction && x < 0);
__ Move(rcx, Smi::FromInt(x));
__ movq(r11, rcx);
- __ Move(r12, Smi::FromInt(y));
+ __ Move(r14, Smi::FromInt(y));
if (!division_overflow && !negative_zero && !division_by_zero) {
// Modulo succeeds
- __ movq(r15, Immediate(id));
+ __ movq(r12, Immediate(id));
int result = x % y;
__ Move(r8, Smi::FromInt(result));
- __ SmiMod(r9, rcx, r12, exit);
+ __ SmiMod(r9, rcx, r14, exit);
- __ incq(r15);
+ __ incq(r12);
__ SmiCompare(r9, r8);
__ j(not_equal, exit);
- __ incq(r15);
+ __ incq(r12);
__ SmiCompare(rcx, r11);
__ j(not_equal, exit);
- __ incq(r15);
- __ SmiMod(rcx, rcx, r12, exit);
+ __ incq(r12);
+ __ SmiMod(rcx, rcx, r14, exit);
- __ incq(r15);
+ __ incq(r12);
__ SmiCompare(rcx, r8);
__ j(not_equal, exit);
} else {
// Modulo fails.
- __ movq(r15, Immediate(id + 8));
+ __ movq(r12, Immediate(id + 8));
Label fail_ok, fail_ok2;
- __ SmiMod(r9, rcx, r12, &fail_ok);
+ __ SmiMod(r9, rcx, r14, &fail_ok);
__ jmp(exit);
__ bind(&fail_ok);
- __ incq(r15);
+ __ incq(r12);
__ SmiCompare(rcx, r11);
__ j(not_equal, exit);
- __ incq(r15);
- __ SmiMod(rcx, rcx, r12, &fail_ok2);
+ __ incq(r12);
+ __ SmiMod(rcx, rcx, r14, &fail_ok2);
__ jmp(exit);
__ bind(&fail_ok2);
- __ incq(r15);
+ __ incq(r12);
__ SmiCompare(rcx, r11);
__ j(not_equal, exit);
}
@@ -1252,10 +1289,11 @@ TEST(SmiMod) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
+ __ push(r14);
__ push(r12);
- __ push(r15);
TestSmiMod(masm, &exit, 0x10, 1, 1);
TestSmiMod(masm, &exit, 0x20, 1, 0);
TestSmiMod(masm, &exit, 0x30, -1, 0);
@@ -1277,11 +1315,12 @@ TEST(SmiMod) {
TestSmiMod(masm, &exit, 0x130, Smi::kMinValue, Smi::kMinValue);
TestSmiMod(masm, &exit, 0x140, Smi::kMinValue, -1);
- __ xor_(r15, r15); // Success.
+ __ xor_(r12, r12); // Success.
__ bind(&exit);
- __ movq(rax, r15);
- __ pop(r15);
+ __ movq(rax, r12);
__ pop(r12);
+ __ pop(r14);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -1336,7 +1375,7 @@ TEST(SmiIndex) {
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer =
- static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2,
+ static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3,
&actual_size,
true));
CHECK(buffer);
@@ -1345,6 +1384,7 @@ TEST(SmiIndex) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestSmiIndex(masm, &exit, 0x10, 0);
@@ -1355,6 +1395,7 @@ TEST(SmiIndex) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -1411,6 +1452,7 @@ TEST(SmiSelectNonSmi) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false); // Avoid inline checks.
+ EntryCode(masm);
Label exit;
TestSelectNonSmi(masm, &exit, 0x10, 0, 0);
@@ -1425,6 +1467,7 @@ TEST(SmiSelectNonSmi) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -1487,6 +1530,7 @@ TEST(SmiAnd) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestSmiAnd(masm, &exit, 0x10, 0, 0);
@@ -1503,6 +1547,7 @@ TEST(SmiAnd) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -1565,6 +1610,7 @@ TEST(SmiOr) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestSmiOr(masm, &exit, 0x10, 0, 0);
@@ -1583,6 +1629,7 @@ TEST(SmiOr) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -1645,6 +1692,7 @@ TEST(SmiXor) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestSmiXor(masm, &exit, 0x10, 0, 0);
@@ -1663,6 +1711,7 @@ TEST(SmiXor) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -1709,6 +1758,7 @@ TEST(SmiNot) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestSmiNot(masm, &exit, 0x10, 0);
@@ -1722,6 +1772,7 @@ TEST(SmiNot) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -1793,7 +1844,7 @@ TEST(SmiShiftLeft) {
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer =
- static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3,
+ static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4,
&actual_size,
true));
CHECK(buffer);
@@ -1802,6 +1853,7 @@ TEST(SmiShiftLeft) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestSmiShiftLeft(masm, &exit, 0x10, 0);
@@ -1814,6 +1866,7 @@ TEST(SmiShiftLeft) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -1896,7 +1949,7 @@ TEST(SmiShiftLogicalRight) {
// Allocate an executable page of memory.
size_t actual_size;
byte* buffer =
- static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2,
+ static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3,
&actual_size,
true));
CHECK(buffer);
@@ -1905,6 +1958,7 @@ TEST(SmiShiftLogicalRight) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestSmiShiftLogicalRight(masm, &exit, 0x10, 0);
@@ -1917,6 +1971,7 @@ TEST(SmiShiftLogicalRight) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -1971,6 +2026,7 @@ TEST(SmiShiftArithmeticRight) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestSmiShiftArithmeticRight(masm, &exit, 0x10, 0);
@@ -1983,6 +2039,7 @@ TEST(SmiShiftArithmeticRight) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -2032,6 +2089,7 @@ TEST(PositiveSmiTimesPowerOfTwoToInteger64) {
MacroAssembler* masm = &assembler;
masm->set_allow_stub_calls(false);
+ EntryCode(masm);
Label exit;
TestPositiveSmiPowerUp(masm, &exit, 0x20, 0);
@@ -2046,6 +2104,7 @@ TEST(PositiveSmiTimesPowerOfTwoToInteger64) {
__ xor_(rax, rax); // Success.
__ bind(&exit);
+ ExitCode(masm);
__ ret(0);
CodeDesc desc;
@@ -2074,8 +2133,9 @@ TEST(OperandOffset) {
masm->set_allow_stub_calls(false);
Label exit;
- __ push(r12);
+ EntryCode(masm);
__ push(r13);
+ __ push(r14);
__ push(rbx);
__ push(rbp);
__ push(Immediate(0x100)); // <-- rbp
@@ -2093,7 +2153,7 @@ TEST(OperandOffset) {
// r12 = rsp[3]
// rbx = rsp[5]
// r13 = rsp[7]
- __ lea(r12, Operand(rsp, 3 * kPointerSize));
+ __ lea(r14, Operand(rsp, 3 * kPointerSize));
__ lea(r13, Operand(rbp, -3 * kPointerSize));
__ lea(rbx, Operand(rbp, -5 * kPointerSize));
__ movl(rcx, Immediate(2));
@@ -2396,8 +2456,9 @@ TEST(OperandOffset) {
__ lea(rsp, Operand(rbp, kPointerSize));
__ pop(rbp);
__ pop(rbx);
+ __ pop(r14);
__ pop(r13);
- __ pop(r12);
+ ExitCode(masm);
__ ret(0);
« no previous file with comments | « src/x64/register-allocator-x64-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698