| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 __ Move(rdx, Smi::FromInt(y)); | 198 __ Move(rdx, Smi::FromInt(y)); |
| 199 __ movq(r9, rdx); | 199 __ movq(r9, rdx); |
| 200 __ SmiCompare(rcx, rdx); | 200 __ SmiCompare(rcx, rdx); |
| 201 if (x < y) { | 201 if (x < y) { |
| 202 __ movl(rax, Immediate(id + 1)); | 202 __ movl(rax, Immediate(id + 1)); |
| 203 __ j(greater_equal, exit); | 203 __ j(greater_equal, exit); |
| 204 } else if (x > y) { | 204 } else if (x > y) { |
| 205 __ movl(rax, Immediate(id + 2)); | 205 __ movl(rax, Immediate(id + 2)); |
| 206 __ j(less_equal, exit); | 206 __ j(less_equal, exit); |
| 207 } else { | 207 } else { |
| 208 ASSERT_EQ(x, y); | 208 DCHECK_EQ(x, y); |
| 209 __ movl(rax, Immediate(id + 3)); | 209 __ movl(rax, Immediate(id + 3)); |
| 210 __ j(not_equal, exit); | 210 __ j(not_equal, exit); |
| 211 } | 211 } |
| 212 __ movl(rax, Immediate(id + 4)); | 212 __ movl(rax, Immediate(id + 4)); |
| 213 __ cmpq(rcx, r8); | 213 __ cmpq(rcx, r8); |
| 214 __ j(not_equal, exit); | 214 __ j(not_equal, exit); |
| 215 __ incq(rax); | 215 __ incq(rax); |
| 216 __ cmpq(rdx, r9); | 216 __ cmpq(rdx, r9); |
| 217 __ j(not_equal, exit); | 217 __ j(not_equal, exit); |
| 218 | 218 |
| 219 if (x != y) { | 219 if (x != y) { |
| 220 __ SmiCompare(rdx, rcx); | 220 __ SmiCompare(rdx, rcx); |
| 221 if (y < x) { | 221 if (y < x) { |
| 222 __ movl(rax, Immediate(id + 9)); | 222 __ movl(rax, Immediate(id + 9)); |
| 223 __ j(greater_equal, exit); | 223 __ j(greater_equal, exit); |
| 224 } else { | 224 } else { |
| 225 ASSERT(y > x); | 225 DCHECK(y > x); |
| 226 __ movl(rax, Immediate(id + 10)); | 226 __ movl(rax, Immediate(id + 10)); |
| 227 __ j(less_equal, exit); | 227 __ j(less_equal, exit); |
| 228 } | 228 } |
| 229 } else { | 229 } else { |
| 230 __ cmpq(rcx, rcx); | 230 __ cmpq(rcx, rcx); |
| 231 __ movl(rax, Immediate(id + 11)); | 231 __ movl(rax, Immediate(id + 11)); |
| 232 __ j(not_equal, exit); | 232 __ j(not_equal, exit); |
| 233 __ incq(rax); | 233 __ incq(rax); |
| 234 __ cmpq(rcx, r8); | 234 __ cmpq(rcx, r8); |
| 235 __ j(not_equal, exit); | 235 __ j(not_equal, exit); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 CHECK_EQ(0, result); | 387 CHECK_EQ(0, result); |
| 388 } | 388 } |
| 389 | 389 |
| 390 | 390 |
| 391 void TestI64PlusConstantToSmi(MacroAssembler* masm, | 391 void TestI64PlusConstantToSmi(MacroAssembler* masm, |
| 392 Label* exit, | 392 Label* exit, |
| 393 int id, | 393 int id, |
| 394 int64_t x, | 394 int64_t x, |
| 395 int y) { | 395 int y) { |
| 396 int64_t result = x + y; | 396 int64_t result = x + y; |
| 397 ASSERT(Smi::IsValid(result)); | 397 DCHECK(Smi::IsValid(result)); |
| 398 __ movl(rax, Immediate(id)); | 398 __ movl(rax, Immediate(id)); |
| 399 __ Move(r8, Smi::FromInt(static_cast<int>(result))); | 399 __ Move(r8, Smi::FromInt(static_cast<int>(result))); |
| 400 __ movq(rcx, x); | 400 __ movq(rcx, x); |
| 401 __ movq(r11, rcx); | 401 __ movq(r11, rcx); |
| 402 __ Integer64PlusConstantToSmi(rdx, rcx, y); | 402 __ Integer64PlusConstantToSmi(rdx, rcx, y); |
| 403 __ cmpq(rdx, r8); | 403 __ cmpq(rdx, r8); |
| 404 __ j(not_equal, exit); | 404 __ j(not_equal, exit); |
| 405 | 405 |
| 406 __ incq(rax); | 406 __ incq(rax); |
| 407 __ cmpq(r11, rcx); | 407 __ cmpq(r11, rcx); |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 __ cmpq(rcx, r8); | 804 __ cmpq(rcx, r8); |
| 805 __ j(not_equal, exit); | 805 __ j(not_equal, exit); |
| 806 } | 806 } |
| 807 | 807 |
| 808 | 808 |
| 809 static void SmiAddOverflowTest(MacroAssembler* masm, | 809 static void SmiAddOverflowTest(MacroAssembler* masm, |
| 810 Label* exit, | 810 Label* exit, |
| 811 int id, | 811 int id, |
| 812 int x) { | 812 int x) { |
| 813 // Adds a Smi to x so that the addition overflows. | 813 // Adds a Smi to x so that the addition overflows. |
| 814 ASSERT(x != 0); // Can't overflow by adding a Smi. | 814 DCHECK(x != 0); // Can't overflow by adding a Smi. |
| 815 int y_max = (x > 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue - x - 1); | 815 int y_max = (x > 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue - x - 1); |
| 816 int y_min = (x > 0) ? (Smi::kMaxValue - x + 1) : (Smi::kMinValue + 0); | 816 int y_min = (x > 0) ? (Smi::kMaxValue - x + 1) : (Smi::kMinValue + 0); |
| 817 | 817 |
| 818 __ movl(rax, Immediate(id)); | 818 __ movl(rax, Immediate(id)); |
| 819 __ Move(rcx, Smi::FromInt(x)); | 819 __ Move(rcx, Smi::FromInt(x)); |
| 820 __ movq(r11, rcx); // Store original Smi value of x in r11. | 820 __ movq(r11, rcx); // Store original Smi value of x in r11. |
| 821 __ Move(rdx, Smi::FromInt(y_min)); | 821 __ Move(rdx, Smi::FromInt(y_min)); |
| 822 { | 822 { |
| 823 Label overflow_ok; | 823 Label overflow_ok; |
| 824 __ SmiAdd(r9, rcx, rdx, &overflow_ok); | 824 __ SmiAdd(r9, rcx, rdx, &overflow_ok); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 __ cmpq(rcx, r8); | 1021 __ cmpq(rcx, r8); |
| 1022 __ j(not_equal, exit); | 1022 __ j(not_equal, exit); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 | 1025 |
| 1026 static void SmiSubOverflowTest(MacroAssembler* masm, | 1026 static void SmiSubOverflowTest(MacroAssembler* masm, |
| 1027 Label* exit, | 1027 Label* exit, |
| 1028 int id, | 1028 int id, |
| 1029 int x) { | 1029 int x) { |
| 1030 // Subtracts a Smi from x so that the subtraction overflows. | 1030 // Subtracts a Smi from x so that the subtraction overflows. |
| 1031 ASSERT(x != -1); // Can't overflow by subtracting a Smi. | 1031 DCHECK(x != -1); // Can't overflow by subtracting a Smi. |
| 1032 int y_max = (x < 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue + 0); | 1032 int y_max = (x < 0) ? (Smi::kMaxValue + 0) : (Smi::kMinValue + 0); |
| 1033 int y_min = (x < 0) ? (Smi::kMaxValue + x + 2) : (Smi::kMinValue + x); | 1033 int y_min = (x < 0) ? (Smi::kMaxValue + x + 2) : (Smi::kMinValue + x); |
| 1034 | 1034 |
| 1035 __ movl(rax, Immediate(id)); | 1035 __ movl(rax, Immediate(id)); |
| 1036 __ Move(rcx, Smi::FromInt(x)); | 1036 __ Move(rcx, Smi::FromInt(x)); |
| 1037 __ movq(r11, rcx); // Store original Smi value of x in r11. | 1037 __ movq(r11, rcx); // Store original Smi value of x in r11. |
| 1038 __ Move(rdx, Smi::FromInt(y_min)); | 1038 __ Move(rdx, Smi::FromInt(y_min)); |
| 1039 { | 1039 { |
| 1040 Label overflow_ok; | 1040 Label overflow_ok; |
| 1041 __ SmiSub(r9, rcx, rdx, &overflow_ok); | 1041 __ SmiSub(r9, rcx, rdx, &overflow_ok); |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1490 CHECK_EQ(0, result); | 1490 CHECK_EQ(0, result); |
| 1491 } | 1491 } |
| 1492 | 1492 |
| 1493 | 1493 |
| 1494 void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { | 1494 void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) { |
| 1495 __ movl(rax, Immediate(id)); | 1495 __ movl(rax, Immediate(id)); |
| 1496 | 1496 |
| 1497 for (int i = 0; i < 8; i++) { | 1497 for (int i = 0; i < 8; i++) { |
| 1498 __ Move(rcx, Smi::FromInt(x)); | 1498 __ Move(rcx, Smi::FromInt(x)); |
| 1499 SmiIndex index = masm->SmiToIndex(rdx, rcx, i); | 1499 SmiIndex index = masm->SmiToIndex(rdx, rcx, i); |
| 1500 ASSERT(index.reg.is(rcx) || index.reg.is(rdx)); | 1500 DCHECK(index.reg.is(rcx) || index.reg.is(rdx)); |
| 1501 __ shlq(index.reg, Immediate(index.scale)); | 1501 __ shlq(index.reg, Immediate(index.scale)); |
| 1502 __ Set(r8, static_cast<intptr_t>(x) << i); | 1502 __ Set(r8, static_cast<intptr_t>(x) << i); |
| 1503 __ cmpq(index.reg, r8); | 1503 __ cmpq(index.reg, r8); |
| 1504 __ j(not_equal, exit); | 1504 __ j(not_equal, exit); |
| 1505 __ incq(rax); | 1505 __ incq(rax); |
| 1506 __ Move(rcx, Smi::FromInt(x)); | 1506 __ Move(rcx, Smi::FromInt(x)); |
| 1507 index = masm->SmiToIndex(rcx, rcx, i); | 1507 index = masm->SmiToIndex(rcx, rcx, i); |
| 1508 ASSERT(index.reg.is(rcx)); | 1508 DCHECK(index.reg.is(rcx)); |
| 1509 __ shlq(rcx, Immediate(index.scale)); | 1509 __ shlq(rcx, Immediate(index.scale)); |
| 1510 __ Set(r8, static_cast<intptr_t>(x) << i); | 1510 __ Set(r8, static_cast<intptr_t>(x) << i); |
| 1511 __ cmpq(rcx, r8); | 1511 __ cmpq(rcx, r8); |
| 1512 __ j(not_equal, exit); | 1512 __ j(not_equal, exit); |
| 1513 __ incq(rax); | 1513 __ incq(rax); |
| 1514 | 1514 |
| 1515 __ Move(rcx, Smi::FromInt(x)); | 1515 __ Move(rcx, Smi::FromInt(x)); |
| 1516 index = masm->SmiToNegativeIndex(rdx, rcx, i); | 1516 index = masm->SmiToNegativeIndex(rdx, rcx, i); |
| 1517 ASSERT(index.reg.is(rcx) || index.reg.is(rdx)); | 1517 DCHECK(index.reg.is(rcx) || index.reg.is(rdx)); |
| 1518 __ shlq(index.reg, Immediate(index.scale)); | 1518 __ shlq(index.reg, Immediate(index.scale)); |
| 1519 __ Set(r8, static_cast<intptr_t>(-x) << i); | 1519 __ Set(r8, static_cast<intptr_t>(-x) << i); |
| 1520 __ cmpq(index.reg, r8); | 1520 __ cmpq(index.reg, r8); |
| 1521 __ j(not_equal, exit); | 1521 __ j(not_equal, exit); |
| 1522 __ incq(rax); | 1522 __ incq(rax); |
| 1523 __ Move(rcx, Smi::FromInt(x)); | 1523 __ Move(rcx, Smi::FromInt(x)); |
| 1524 index = masm->SmiToNegativeIndex(rcx, rcx, i); | 1524 index = masm->SmiToNegativeIndex(rcx, rcx, i); |
| 1525 ASSERT(index.reg.is(rcx)); | 1525 DCHECK(index.reg.is(rcx)); |
| 1526 __ shlq(rcx, Immediate(index.scale)); | 1526 __ shlq(rcx, Immediate(index.scale)); |
| 1527 __ Set(r8, static_cast<intptr_t>(-x) << i); | 1527 __ Set(r8, static_cast<intptr_t>(-x) << i); |
| 1528 __ cmpq(rcx, r8); | 1528 __ cmpq(rcx, r8); |
| 1529 __ j(not_equal, exit); | 1529 __ j(not_equal, exit); |
| 1530 __ incq(rax); | 1530 __ incq(rax); |
| 1531 } | 1531 } |
| 1532 } | 1532 } |
| 1533 | 1533 |
| 1534 | 1534 |
| 1535 TEST(SmiIndex) { | 1535 TEST(SmiIndex) { |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2196 | 2196 |
| 2197 CodeDesc desc; | 2197 CodeDesc desc; |
| 2198 masm->GetCode(&desc); | 2198 masm->GetCode(&desc); |
| 2199 // Call the function from C++. | 2199 // Call the function from C++. |
| 2200 int result = FUNCTION_CAST<F0>(buffer)(); | 2200 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2201 CHECK_EQ(0, result); | 2201 CHECK_EQ(0, result); |
| 2202 } | 2202 } |
| 2203 | 2203 |
| 2204 | 2204 |
| 2205 void TestPositiveSmiPowerUp(MacroAssembler* masm, Label* exit, int id, int x) { | 2205 void TestPositiveSmiPowerUp(MacroAssembler* masm, Label* exit, int id, int x) { |
| 2206 ASSERT(x >= 0); | 2206 DCHECK(x >= 0); |
| 2207 int powers[] = { 0, 1, 2, 3, 8, 16, 24, 31 }; | 2207 int powers[] = { 0, 1, 2, 3, 8, 16, 24, 31 }; |
| 2208 int power_count = 8; | 2208 int power_count = 8; |
| 2209 __ movl(rax, Immediate(id)); | 2209 __ movl(rax, Immediate(id)); |
| 2210 for (int i = 0; i < power_count; i++) { | 2210 for (int i = 0; i < power_count; i++) { |
| 2211 int power = powers[i]; | 2211 int power = powers[i]; |
| 2212 intptr_t result = static_cast<intptr_t>(x) << power; | 2212 intptr_t result = static_cast<intptr_t>(x) << power; |
| 2213 __ Set(r8, result); | 2213 __ Set(r8, result); |
| 2214 __ Move(rcx, Smi::FromInt(x)); | 2214 __ Move(rcx, Smi::FromInt(x)); |
| 2215 __ movq(r11, rcx); | 2215 __ movq(r11, rcx); |
| 2216 __ PositiveSmiTimesPowerOfTwoToInteger64(rdx, rcx, power); | 2216 __ PositiveSmiTimesPowerOfTwoToInteger64(rdx, rcx, power); |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2763 | 2763 |
| 2764 CodeDesc desc; | 2764 CodeDesc desc; |
| 2765 masm->GetCode(&desc); | 2765 masm->GetCode(&desc); |
| 2766 // Call the function from C++. | 2766 // Call the function from C++. |
| 2767 int result = FUNCTION_CAST<F0>(buffer)(); | 2767 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2768 CHECK_EQ(0, result); | 2768 CHECK_EQ(0, result); |
| 2769 } | 2769 } |
| 2770 | 2770 |
| 2771 | 2771 |
| 2772 #undef __ | 2772 #undef __ |
| OLD | NEW |