| 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 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), exit); | 794 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), exit); |
| 795 __ cmpq(r9, r8); | 795 __ cmpq(r9, r8); |
| 796 __ j(not_equal, exit); | 796 __ j(not_equal, exit); |
| 797 | 797 |
| 798 __ incq(rax); | 798 __ incq(rax); |
| 799 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), exit); | 799 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), exit); |
| 800 __ cmpq(rcx, r8); | 800 __ cmpq(rcx, r8); |
| 801 __ j(not_equal, exit); | 801 __ j(not_equal, exit); |
| 802 } | 802 } |
| 803 | 803 |
| 804 |
| 804 TEST(SmiAdd) { | 805 TEST(SmiAdd) { |
| 805 v8::internal::V8::Initialize(NULL); | 806 v8::internal::V8::Initialize(NULL); |
| 806 // Allocate an executable page of memory. | 807 // Allocate an executable page of memory. |
| 807 size_t actual_size; | 808 size_t actual_size; |
| 808 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 809 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 809 &actual_size, | 810 &actual_size, |
| 810 true)); | 811 true)); |
| 811 CHECK(buffer); | 812 CHECK(buffer); |
| 812 Isolate* isolate = Isolate::Current(); | 813 Isolate* isolate = Isolate::Current(); |
| 813 HandleScope handles(isolate); | 814 HandleScope handles(isolate); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 masm->GetCode(&desc); | 1125 masm->GetCode(&desc); |
| 1125 // Call the function from C++. | 1126 // Call the function from C++. |
| 1126 int result = FUNCTION_CAST<F0>(buffer)(); | 1127 int result = FUNCTION_CAST<F0>(buffer)(); |
| 1127 CHECK_EQ(0, result); | 1128 CHECK_EQ(0, result); |
| 1128 } | 1129 } |
| 1129 | 1130 |
| 1130 | 1131 |
| 1131 void TestSmiDiv(MacroAssembler* masm, Label* exit, int id, int x, int y) { | 1132 void TestSmiDiv(MacroAssembler* masm, Label* exit, int id, int x, int y) { |
| 1132 bool division_by_zero = (y == 0); | 1133 bool division_by_zero = (y == 0); |
| 1133 bool negative_zero = (x == 0 && y < 0); | 1134 bool negative_zero = (x == 0 && y < 0); |
| 1134 #ifdef V8_TARGET_ARCH_X64 | 1135 #if V8_TARGET_ARCH_X64 |
| 1135 bool overflow = (x == Smi::kMinValue && y < 0); // Safe approx. used. | 1136 bool overflow = (x == Smi::kMinValue && y < 0); // Safe approx. used. |
| 1136 #else | 1137 #else |
| 1137 bool overflow = (x == Smi::kMinValue && y == -1); | 1138 bool overflow = (x == Smi::kMinValue && y == -1); |
| 1138 #endif | 1139 #endif |
| 1139 bool fraction = !division_by_zero && !overflow && (x % y != 0); | 1140 bool fraction = !division_by_zero && !overflow && (x % y != 0); |
| 1140 __ Move(r11, Smi::FromInt(x)); | 1141 __ Move(r11, Smi::FromInt(x)); |
| 1141 __ Move(r14, Smi::FromInt(y)); | 1142 __ Move(r14, Smi::FromInt(y)); |
| 1142 if (!fraction && !overflow && !negative_zero && !division_by_zero) { | 1143 if (!fraction && !overflow && !negative_zero && !division_by_zero) { |
| 1143 // Division succeeds | 1144 // Division succeeds |
| 1144 __ movq(rcx, r11); | 1145 __ movq(rcx, r11); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 index = masm->SmiToNegativeIndex(rcx, rcx, i); | 1391 index = masm->SmiToNegativeIndex(rcx, rcx, i); |
| 1391 ASSERT(index.reg.is(rcx)); | 1392 ASSERT(index.reg.is(rcx)); |
| 1392 __ shl(rcx, Immediate(index.scale)); | 1393 __ shl(rcx, Immediate(index.scale)); |
| 1393 __ Set(r8, static_cast<intptr_t>(-x) << i); | 1394 __ Set(r8, static_cast<intptr_t>(-x) << i); |
| 1394 __ cmpq(rcx, r8); | 1395 __ cmpq(rcx, r8); |
| 1395 __ j(not_equal, exit); | 1396 __ j(not_equal, exit); |
| 1396 __ incq(rax); | 1397 __ incq(rax); |
| 1397 } | 1398 } |
| 1398 } | 1399 } |
| 1399 | 1400 |
| 1401 |
| 1400 TEST(SmiIndex) { | 1402 TEST(SmiIndex) { |
| 1401 v8::internal::V8::Initialize(NULL); | 1403 v8::internal::V8::Initialize(NULL); |
| 1402 // Allocate an executable page of memory. | 1404 // Allocate an executable page of memory. |
| 1403 size_t actual_size; | 1405 size_t actual_size; |
| 1404 byte* buffer = | 1406 byte* buffer = |
| 1405 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, | 1407 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, |
| 1406 &actual_size, | 1408 &actual_size, |
| 1407 true)); | 1409 true)); |
| 1408 CHECK(buffer); | 1410 CHECK(buffer); |
| 1409 Isolate* isolate = Isolate::Current(); | 1411 Isolate* isolate = Isolate::Current(); |
| (...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2513 CodeDesc desc; | 2515 CodeDesc desc; |
| 2514 masm->GetCode(&desc); | 2516 masm->GetCode(&desc); |
| 2515 // Call the function from C++. | 2517 // Call the function from C++. |
| 2516 int result = FUNCTION_CAST<F0>(buffer)(); | 2518 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2517 CHECK_EQ(0, result); | 2519 CHECK_EQ(0, result); |
| 2518 } | 2520 } |
| 2519 | 2521 |
| 2520 | 2522 |
| 2521 | 2523 |
| 2522 #undef __ | 2524 #undef __ |
| OLD | NEW |