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 11 matching lines...) Expand all Loading... |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #include <stdlib.h> | 28 #include <stdlib.h> |
29 | 29 |
30 #include "src/v8.h" | 30 #include "src/v8.h" |
31 | 31 |
| 32 #include "src/base/platform/platform.h" |
32 #include "src/factory.h" | 33 #include "src/factory.h" |
33 #include "src/macro-assembler.h" | 34 #include "src/macro-assembler.h" |
34 #include "src/platform.h" | |
35 #include "src/serialize.h" | 35 #include "src/serialize.h" |
36 #include "test/cctest/cctest.h" | 36 #include "test/cctest/cctest.h" |
37 | 37 |
38 namespace i = v8::internal; | 38 namespace i = v8::internal; |
39 using i::Address; | 39 using i::Address; |
40 using i::Assembler; | 40 using i::Assembler; |
41 using i::CodeDesc; | 41 using i::CodeDesc; |
42 using i::Condition; | 42 using i::Condition; |
43 using i::FUNCTION_CAST; | 43 using i::FUNCTION_CAST; |
44 using i::HandleScope; | 44 using i::HandleScope; |
45 using i::Immediate; | 45 using i::Immediate; |
46 using i::Isolate; | 46 using i::Isolate; |
47 using i::Label; | 47 using i::Label; |
48 using i::MacroAssembler; | 48 using i::MacroAssembler; |
49 using i::OS; | |
50 using i::Operand; | 49 using i::Operand; |
51 using i::RelocInfo; | 50 using i::RelocInfo; |
52 using i::Representation; | 51 using i::Representation; |
53 using i::Smi; | 52 using i::Smi; |
54 using i::SmiIndex; | 53 using i::SmiIndex; |
55 using i::byte; | 54 using i::byte; |
56 using i::carry; | 55 using i::carry; |
57 using i::greater; | 56 using i::greater; |
58 using i::greater_equal; | 57 using i::greater_equal; |
59 using i::kIntSize; | 58 using i::kIntSize; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 __ cmpq(rcx, rdx); | 149 __ cmpq(rcx, rdx); |
151 __ j(not_equal, exit); | 150 __ j(not_equal, exit); |
152 } | 151 } |
153 | 152 |
154 | 153 |
155 // Test that we can move a Smi value literally into a register. | 154 // Test that we can move a Smi value literally into a register. |
156 TEST(SmiMove) { | 155 TEST(SmiMove) { |
157 i::V8::Initialize(NULL); | 156 i::V8::Initialize(NULL); |
158 // Allocate an executable page of memory. | 157 // Allocate an executable page of memory. |
159 size_t actual_size; | 158 size_t actual_size; |
160 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 159 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
161 &actual_size, | 160 Assembler::kMinimalBufferSize, &actual_size, true)); |
162 true)); | |
163 CHECK(buffer); | 161 CHECK(buffer); |
164 Isolate* isolate = CcTest::i_isolate(); | 162 Isolate* isolate = CcTest::i_isolate(); |
165 HandleScope handles(isolate); | 163 HandleScope handles(isolate); |
166 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 164 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
167 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. | 165 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. |
168 EntryCode(masm); | 166 EntryCode(masm); |
169 Label exit; | 167 Label exit; |
170 | 168 |
171 TestMoveSmi(masm, &exit, 1, Smi::FromInt(0)); | 169 TestMoveSmi(masm, &exit, 1, Smi::FromInt(0)); |
172 TestMoveSmi(masm, &exit, 2, Smi::FromInt(127)); | 170 TestMoveSmi(masm, &exit, 2, Smi::FromInt(127)); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 __ j(not_equal, exit); | 235 __ j(not_equal, exit); |
238 } | 236 } |
239 } | 237 } |
240 | 238 |
241 | 239 |
242 // Test that we can compare smis for equality (and more). | 240 // Test that we can compare smis for equality (and more). |
243 TEST(SmiCompare) { | 241 TEST(SmiCompare) { |
244 i::V8::Initialize(NULL); | 242 i::V8::Initialize(NULL); |
245 // Allocate an executable page of memory. | 243 // Allocate an executable page of memory. |
246 size_t actual_size; | 244 size_t actual_size; |
247 byte* buffer = | 245 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
248 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 246 Assembler::kMinimalBufferSize * 2, &actual_size, true)); |
249 &actual_size, | |
250 true)); | |
251 CHECK(buffer); | 247 CHECK(buffer); |
252 Isolate* isolate = CcTest::i_isolate(); | 248 Isolate* isolate = CcTest::i_isolate(); |
253 HandleScope handles(isolate); | 249 HandleScope handles(isolate); |
254 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 250 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
255 | 251 |
256 MacroAssembler* masm = &assembler; | 252 MacroAssembler* masm = &assembler; |
257 EntryCode(masm); | 253 EntryCode(masm); |
258 Label exit; | 254 Label exit; |
259 | 255 |
260 TestSmiCompare(masm, &exit, 0x10, 0, 0); | 256 TestSmiCompare(masm, &exit, 0x10, 0, 0); |
(...skipping 27 matching lines...) Expand all Loading... |
288 int result = FUNCTION_CAST<F0>(buffer)(); | 284 int result = FUNCTION_CAST<F0>(buffer)(); |
289 CHECK_EQ(0, result); | 285 CHECK_EQ(0, result); |
290 } | 286 } |
291 | 287 |
292 | 288 |
293 | 289 |
294 TEST(Integer32ToSmi) { | 290 TEST(Integer32ToSmi) { |
295 i::V8::Initialize(NULL); | 291 i::V8::Initialize(NULL); |
296 // Allocate an executable page of memory. | 292 // Allocate an executable page of memory. |
297 size_t actual_size; | 293 size_t actual_size; |
298 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 294 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
299 &actual_size, | 295 Assembler::kMinimalBufferSize, &actual_size, true)); |
300 true)); | |
301 CHECK(buffer); | 296 CHECK(buffer); |
302 Isolate* isolate = CcTest::i_isolate(); | 297 Isolate* isolate = CcTest::i_isolate(); |
303 HandleScope handles(isolate); | 298 HandleScope handles(isolate); |
304 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 299 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
305 | 300 |
306 MacroAssembler* masm = &assembler; | 301 MacroAssembler* masm = &assembler; |
307 EntryCode(masm); | 302 EntryCode(masm); |
308 Label exit; | 303 Label exit; |
309 | 304 |
310 __ movq(rax, Immediate(1)); // Test number. | 305 __ movq(rax, Immediate(1)); // Test number. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 __ Integer64PlusConstantToSmi(rcx, rcx, y); | 411 __ Integer64PlusConstantToSmi(rcx, rcx, y); |
417 __ cmpq(rcx, r8); | 412 __ cmpq(rcx, r8); |
418 __ j(not_equal, exit); | 413 __ j(not_equal, exit); |
419 } | 414 } |
420 | 415 |
421 | 416 |
422 TEST(Integer64PlusConstantToSmi) { | 417 TEST(Integer64PlusConstantToSmi) { |
423 i::V8::Initialize(NULL); | 418 i::V8::Initialize(NULL); |
424 // Allocate an executable page of memory. | 419 // Allocate an executable page of memory. |
425 size_t actual_size; | 420 size_t actual_size; |
426 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 421 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
427 &actual_size, | 422 Assembler::kMinimalBufferSize, &actual_size, true)); |
428 true)); | |
429 CHECK(buffer); | 423 CHECK(buffer); |
430 Isolate* isolate = CcTest::i_isolate(); | 424 Isolate* isolate = CcTest::i_isolate(); |
431 HandleScope handles(isolate); | 425 HandleScope handles(isolate); |
432 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 426 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
433 | 427 |
434 MacroAssembler* masm = &assembler; | 428 MacroAssembler* masm = &assembler; |
435 EntryCode(masm); | 429 EntryCode(masm); |
436 Label exit; | 430 Label exit; |
437 | 431 |
438 int64_t twice_max = static_cast<int64_t>(Smi::kMaxValue) * 2; | 432 int64_t twice_max = static_cast<int64_t>(Smi::kMaxValue) * 2; |
(...skipping 21 matching lines...) Expand all Loading... |
460 // Call the function from C++. | 454 // Call the function from C++. |
461 int result = FUNCTION_CAST<F0>(buffer)(); | 455 int result = FUNCTION_CAST<F0>(buffer)(); |
462 CHECK_EQ(0, result); | 456 CHECK_EQ(0, result); |
463 } | 457 } |
464 | 458 |
465 | 459 |
466 TEST(SmiCheck) { | 460 TEST(SmiCheck) { |
467 i::V8::Initialize(NULL); | 461 i::V8::Initialize(NULL); |
468 // Allocate an executable page of memory. | 462 // Allocate an executable page of memory. |
469 size_t actual_size; | 463 size_t actual_size; |
470 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 464 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
471 &actual_size, | 465 Assembler::kMinimalBufferSize, &actual_size, true)); |
472 true)); | |
473 CHECK(buffer); | 466 CHECK(buffer); |
474 Isolate* isolate = CcTest::i_isolate(); | 467 Isolate* isolate = CcTest::i_isolate(); |
475 HandleScope handles(isolate); | 468 HandleScope handles(isolate); |
476 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 469 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
477 | 470 |
478 MacroAssembler* masm = &assembler; | 471 MacroAssembler* masm = &assembler; |
479 EntryCode(masm); | 472 EntryCode(masm); |
480 Label exit; | 473 Label exit; |
481 Condition cond; | 474 Condition cond; |
482 | 475 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 __ cmpq(rcx, r8); | 700 __ cmpq(rcx, r8); |
708 __ j(not_equal, exit); | 701 __ j(not_equal, exit); |
709 } | 702 } |
710 } | 703 } |
711 | 704 |
712 | 705 |
713 TEST(SmiNeg) { | 706 TEST(SmiNeg) { |
714 i::V8::Initialize(NULL); | 707 i::V8::Initialize(NULL); |
715 // Allocate an executable page of memory. | 708 // Allocate an executable page of memory. |
716 size_t actual_size; | 709 size_t actual_size; |
717 byte* buffer = | 710 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
718 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 711 Assembler::kMinimalBufferSize, &actual_size, true)); |
719 &actual_size, | |
720 true)); | |
721 CHECK(buffer); | 712 CHECK(buffer); |
722 Isolate* isolate = CcTest::i_isolate(); | 713 Isolate* isolate = CcTest::i_isolate(); |
723 HandleScope handles(isolate); | 714 HandleScope handles(isolate); |
724 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 715 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
725 | 716 |
726 MacroAssembler* masm = &assembler; | 717 MacroAssembler* masm = &assembler; |
727 EntryCode(masm); | 718 EntryCode(masm); |
728 Label exit; | 719 Label exit; |
729 | 720 |
730 TestSmiNeg(masm, &exit, 0x10, 0); | 721 TestSmiNeg(masm, &exit, 0x10, 0); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 __ cmpq(rcx, r11); | 914 __ cmpq(rcx, r11); |
924 __ j(equal, exit); | 915 __ j(equal, exit); |
925 } | 916 } |
926 } | 917 } |
927 | 918 |
928 | 919 |
929 TEST(SmiAdd) { | 920 TEST(SmiAdd) { |
930 i::V8::Initialize(NULL); | 921 i::V8::Initialize(NULL); |
931 // Allocate an executable page of memory. | 922 // Allocate an executable page of memory. |
932 size_t actual_size; | 923 size_t actual_size; |
933 byte* buffer = | 924 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
934 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, | 925 Assembler::kMinimalBufferSize * 3, &actual_size, true)); |
935 &actual_size, | |
936 true)); | |
937 CHECK(buffer); | 926 CHECK(buffer); |
938 Isolate* isolate = CcTest::i_isolate(); | 927 Isolate* isolate = CcTest::i_isolate(); |
939 HandleScope handles(isolate); | 928 HandleScope handles(isolate); |
940 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 929 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
941 | 930 |
942 MacroAssembler* masm = &assembler; | 931 MacroAssembler* masm = &assembler; |
943 EntryCode(masm); | 932 EntryCode(masm); |
944 Label exit; | 933 Label exit; |
945 | 934 |
946 // No-overflow tests. | 935 // No-overflow tests. |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 __ cmpq(rcx, r11); | 1133 __ cmpq(rcx, r11); |
1145 __ j(equal, exit); | 1134 __ j(equal, exit); |
1146 } | 1135 } |
1147 } | 1136 } |
1148 | 1137 |
1149 | 1138 |
1150 TEST(SmiSub) { | 1139 TEST(SmiSub) { |
1151 i::V8::Initialize(NULL); | 1140 i::V8::Initialize(NULL); |
1152 // Allocate an executable page of memory. | 1141 // Allocate an executable page of memory. |
1153 size_t actual_size; | 1142 size_t actual_size; |
1154 byte* buffer = | 1143 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
1155 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, | 1144 Assembler::kMinimalBufferSize * 4, &actual_size, true)); |
1156 &actual_size, | |
1157 true)); | |
1158 CHECK(buffer); | 1145 CHECK(buffer); |
1159 Isolate* isolate = CcTest::i_isolate(); | 1146 Isolate* isolate = CcTest::i_isolate(); |
1160 HandleScope handles(isolate); | 1147 HandleScope handles(isolate); |
1161 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1148 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
1162 | 1149 |
1163 MacroAssembler* masm = &assembler; | 1150 MacroAssembler* masm = &assembler; |
1164 EntryCode(masm); | 1151 EntryCode(masm); |
1165 Label exit; | 1152 Label exit; |
1166 | 1153 |
1167 SmiSubTest(masm, &exit, 0x10, 1, 2); | 1154 SmiSubTest(masm, &exit, 0x10, 1, 2); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 // __ cmpq(r11, rcx); | 1222 // __ cmpq(r11, rcx); |
1236 // __ j(not_equal, exit); | 1223 // __ j(not_equal, exit); |
1237 } | 1224 } |
1238 } | 1225 } |
1239 | 1226 |
1240 | 1227 |
1241 TEST(SmiMul) { | 1228 TEST(SmiMul) { |
1242 i::V8::Initialize(NULL); | 1229 i::V8::Initialize(NULL); |
1243 // Allocate an executable page of memory. | 1230 // Allocate an executable page of memory. |
1244 size_t actual_size; | 1231 size_t actual_size; |
1245 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1232 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
1246 &actual_size, | 1233 Assembler::kMinimalBufferSize, &actual_size, true)); |
1247 true)); | |
1248 CHECK(buffer); | 1234 CHECK(buffer); |
1249 Isolate* isolate = CcTest::i_isolate(); | 1235 Isolate* isolate = CcTest::i_isolate(); |
1250 HandleScope handles(isolate); | 1236 HandleScope handles(isolate); |
1251 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1237 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
1252 | 1238 |
1253 MacroAssembler* masm = &assembler; | 1239 MacroAssembler* masm = &assembler; |
1254 EntryCode(masm); | 1240 EntryCode(masm); |
1255 Label exit; | 1241 Label exit; |
1256 | 1242 |
1257 TestSmiMul(masm, &exit, 0x10, 0, 0); | 1243 TestSmiMul(masm, &exit, 0x10, 0, 0); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 __ cmpq(rcx, r11); | 1326 __ cmpq(rcx, r11); |
1341 __ j(not_equal, exit); | 1327 __ j(not_equal, exit); |
1342 } | 1328 } |
1343 } | 1329 } |
1344 | 1330 |
1345 | 1331 |
1346 TEST(SmiDiv) { | 1332 TEST(SmiDiv) { |
1347 i::V8::Initialize(NULL); | 1333 i::V8::Initialize(NULL); |
1348 // Allocate an executable page of memory. | 1334 // Allocate an executable page of memory. |
1349 size_t actual_size; | 1335 size_t actual_size; |
1350 byte* buffer = | 1336 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
1351 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1337 Assembler::kMinimalBufferSize * 2, &actual_size, true)); |
1352 &actual_size, | |
1353 true)); | |
1354 CHECK(buffer); | 1338 CHECK(buffer); |
1355 Isolate* isolate = CcTest::i_isolate(); | 1339 Isolate* isolate = CcTest::i_isolate(); |
1356 HandleScope handles(isolate); | 1340 HandleScope handles(isolate); |
1357 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1341 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
1358 | 1342 |
1359 MacroAssembler* masm = &assembler; | 1343 MacroAssembler* masm = &assembler; |
1360 EntryCode(masm); | 1344 EntryCode(masm); |
1361 Label exit; | 1345 Label exit; |
1362 | 1346 |
1363 __ pushq(r14); | 1347 __ pushq(r14); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 __ cmpq(rcx, r11); | 1434 __ cmpq(rcx, r11); |
1451 __ j(not_equal, exit); | 1435 __ j(not_equal, exit); |
1452 } | 1436 } |
1453 } | 1437 } |
1454 | 1438 |
1455 | 1439 |
1456 TEST(SmiMod) { | 1440 TEST(SmiMod) { |
1457 i::V8::Initialize(NULL); | 1441 i::V8::Initialize(NULL); |
1458 // Allocate an executable page of memory. | 1442 // Allocate an executable page of memory. |
1459 size_t actual_size; | 1443 size_t actual_size; |
1460 byte* buffer = | 1444 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
1461 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1445 Assembler::kMinimalBufferSize * 2, &actual_size, true)); |
1462 &actual_size, | |
1463 true)); | |
1464 CHECK(buffer); | 1446 CHECK(buffer); |
1465 Isolate* isolate = CcTest::i_isolate(); | 1447 Isolate* isolate = CcTest::i_isolate(); |
1466 HandleScope handles(isolate); | 1448 HandleScope handles(isolate); |
1467 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1449 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
1468 | 1450 |
1469 MacroAssembler* masm = &assembler; | 1451 MacroAssembler* masm = &assembler; |
1470 EntryCode(masm); | 1452 EntryCode(masm); |
1471 Label exit; | 1453 Label exit; |
1472 | 1454 |
1473 __ pushq(r14); | 1455 __ pushq(r14); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 __ j(not_equal, exit); | 1529 __ j(not_equal, exit); |
1548 __ incq(rax); | 1530 __ incq(rax); |
1549 } | 1531 } |
1550 } | 1532 } |
1551 | 1533 |
1552 | 1534 |
1553 TEST(SmiIndex) { | 1535 TEST(SmiIndex) { |
1554 i::V8::Initialize(NULL); | 1536 i::V8::Initialize(NULL); |
1555 // Allocate an executable page of memory. | 1537 // Allocate an executable page of memory. |
1556 size_t actual_size; | 1538 size_t actual_size; |
1557 byte* buffer = | 1539 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
1558 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 5, | 1540 Assembler::kMinimalBufferSize * 5, &actual_size, true)); |
1559 &actual_size, | |
1560 true)); | |
1561 CHECK(buffer); | 1541 CHECK(buffer); |
1562 Isolate* isolate = CcTest::i_isolate(); | 1542 Isolate* isolate = CcTest::i_isolate(); |
1563 HandleScope handles(isolate); | 1543 HandleScope handles(isolate); |
1564 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1544 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
1565 | 1545 |
1566 MacroAssembler* masm = &assembler; | 1546 MacroAssembler* masm = &assembler; |
1567 EntryCode(masm); | 1547 EntryCode(masm); |
1568 Label exit; | 1548 Label exit; |
1569 | 1549 |
1570 TestSmiIndex(masm, &exit, 0x10, 0); | 1550 TestSmiIndex(masm, &exit, 0x10, 0); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 __ SelectNonSmi(r9, rcx, rdx, &fail_ok); | 1596 __ SelectNonSmi(r9, rcx, rdx, &fail_ok); |
1617 __ jmp(exit); | 1597 __ jmp(exit); |
1618 __ bind(&fail_ok); | 1598 __ bind(&fail_ok); |
1619 } | 1599 } |
1620 | 1600 |
1621 | 1601 |
1622 TEST(SmiSelectNonSmi) { | 1602 TEST(SmiSelectNonSmi) { |
1623 i::V8::Initialize(NULL); | 1603 i::V8::Initialize(NULL); |
1624 // Allocate an executable page of memory. | 1604 // Allocate an executable page of memory. |
1625 size_t actual_size; | 1605 size_t actual_size; |
1626 byte* buffer = | 1606 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
1627 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1607 Assembler::kMinimalBufferSize * 2, &actual_size, true)); |
1628 &actual_size, | |
1629 true)); | |
1630 CHECK(buffer); | 1608 CHECK(buffer); |
1631 Isolate* isolate = CcTest::i_isolate(); | 1609 Isolate* isolate = CcTest::i_isolate(); |
1632 HandleScope handles(isolate); | 1610 HandleScope handles(isolate); |
1633 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1611 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
1634 | 1612 |
1635 MacroAssembler* masm = &assembler; | 1613 MacroAssembler* masm = &assembler; |
1636 EntryCode(masm); | 1614 EntryCode(masm); |
1637 Label exit; | 1615 Label exit; |
1638 | 1616 |
1639 TestSelectNonSmi(masm, &exit, 0x10, 0, 0); | 1617 TestSelectNonSmi(masm, &exit, 0x10, 0, 0); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1695 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y)); | 1673 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y)); |
1696 __ cmpq(r8, rcx); | 1674 __ cmpq(r8, rcx); |
1697 __ j(not_equal, exit); | 1675 __ j(not_equal, exit); |
1698 } | 1676 } |
1699 | 1677 |
1700 | 1678 |
1701 TEST(SmiAnd) { | 1679 TEST(SmiAnd) { |
1702 i::V8::Initialize(NULL); | 1680 i::V8::Initialize(NULL); |
1703 // Allocate an executable page of memory. | 1681 // Allocate an executable page of memory. |
1704 size_t actual_size; | 1682 size_t actual_size; |
1705 byte* buffer = | 1683 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
1706 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1684 Assembler::kMinimalBufferSize * 2, &actual_size, true)); |
1707 &actual_size, | |
1708 true)); | |
1709 CHECK(buffer); | 1685 CHECK(buffer); |
1710 Isolate* isolate = CcTest::i_isolate(); | 1686 Isolate* isolate = CcTest::i_isolate(); |
1711 HandleScope handles(isolate); | 1687 HandleScope handles(isolate); |
1712 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1688 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
1713 | 1689 |
1714 MacroAssembler* masm = &assembler; | 1690 MacroAssembler* masm = &assembler; |
1715 EntryCode(masm); | 1691 EntryCode(masm); |
1716 Label exit; | 1692 Label exit; |
1717 | 1693 |
1718 TestSmiAnd(masm, &exit, 0x10, 0, 0); | 1694 TestSmiAnd(masm, &exit, 0x10, 0, 0); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y)); | 1752 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y)); |
1777 __ cmpq(r8, rcx); | 1753 __ cmpq(r8, rcx); |
1778 __ j(not_equal, exit); | 1754 __ j(not_equal, exit); |
1779 } | 1755 } |
1780 | 1756 |
1781 | 1757 |
1782 TEST(SmiOr) { | 1758 TEST(SmiOr) { |
1783 i::V8::Initialize(NULL); | 1759 i::V8::Initialize(NULL); |
1784 // Allocate an executable page of memory. | 1760 // Allocate an executable page of memory. |
1785 size_t actual_size; | 1761 size_t actual_size; |
1786 byte* buffer = | 1762 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
1787 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1763 Assembler::kMinimalBufferSize * 2, &actual_size, true)); |
1788 &actual_size, | |
1789 true)); | |
1790 CHECK(buffer); | 1764 CHECK(buffer); |
1791 Isolate* isolate = CcTest::i_isolate(); | 1765 Isolate* isolate = CcTest::i_isolate(); |
1792 HandleScope handles(isolate); | 1766 HandleScope handles(isolate); |
1793 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1767 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
1794 | 1768 |
1795 MacroAssembler* masm = &assembler; | 1769 MacroAssembler* masm = &assembler; |
1796 EntryCode(masm); | 1770 EntryCode(masm); |
1797 Label exit; | 1771 Label exit; |
1798 | 1772 |
1799 TestSmiOr(masm, &exit, 0x10, 0, 0); | 1773 TestSmiOr(masm, &exit, 0x10, 0, 0); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1859 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y)); | 1833 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y)); |
1860 __ cmpq(r8, rcx); | 1834 __ cmpq(r8, rcx); |
1861 __ j(not_equal, exit); | 1835 __ j(not_equal, exit); |
1862 } | 1836 } |
1863 | 1837 |
1864 | 1838 |
1865 TEST(SmiXor) { | 1839 TEST(SmiXor) { |
1866 i::V8::Initialize(NULL); | 1840 i::V8::Initialize(NULL); |
1867 // Allocate an executable page of memory. | 1841 // Allocate an executable page of memory. |
1868 size_t actual_size; | 1842 size_t actual_size; |
1869 byte* buffer = | 1843 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
1870 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1844 Assembler::kMinimalBufferSize * 2, &actual_size, true)); |
1871 &actual_size, | |
1872 true)); | |
1873 CHECK(buffer); | 1845 CHECK(buffer); |
1874 Isolate* isolate = CcTest::i_isolate(); | 1846 Isolate* isolate = CcTest::i_isolate(); |
1875 HandleScope handles(isolate); | 1847 HandleScope handles(isolate); |
1876 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1848 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
1877 | 1849 |
1878 MacroAssembler* masm = &assembler; | 1850 MacroAssembler* masm = &assembler; |
1879 EntryCode(masm); | 1851 EntryCode(masm); |
1880 Label exit; | 1852 Label exit; |
1881 | 1853 |
1882 TestSmiXor(masm, &exit, 0x10, 0, 0); | 1854 TestSmiXor(masm, &exit, 0x10, 0, 0); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 __ SmiNot(rcx, rcx); | 1898 __ SmiNot(rcx, rcx); |
1927 __ cmpq(rcx, r8); | 1899 __ cmpq(rcx, r8); |
1928 __ j(not_equal, exit); | 1900 __ j(not_equal, exit); |
1929 } | 1901 } |
1930 | 1902 |
1931 | 1903 |
1932 TEST(SmiNot) { | 1904 TEST(SmiNot) { |
1933 i::V8::Initialize(NULL); | 1905 i::V8::Initialize(NULL); |
1934 // Allocate an executable page of memory. | 1906 // Allocate an executable page of memory. |
1935 size_t actual_size; | 1907 size_t actual_size; |
1936 byte* buffer = | 1908 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
1937 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1909 Assembler::kMinimalBufferSize, &actual_size, true)); |
1938 &actual_size, | |
1939 true)); | |
1940 CHECK(buffer); | 1910 CHECK(buffer); |
1941 Isolate* isolate = CcTest::i_isolate(); | 1911 Isolate* isolate = CcTest::i_isolate(); |
1942 HandleScope handles(isolate); | 1912 HandleScope handles(isolate); |
1943 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1913 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
1944 | 1914 |
1945 MacroAssembler* masm = &assembler; | 1915 MacroAssembler* masm = &assembler; |
1946 EntryCode(masm); | 1916 EntryCode(masm); |
1947 Label exit; | 1917 Label exit; |
1948 | 1918 |
1949 TestSmiNot(masm, &exit, 0x10, 0); | 1919 TestSmiNot(masm, &exit, 0x10, 0); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2022 | 1992 |
2023 __ incq(rax); | 1993 __ incq(rax); |
2024 } | 1994 } |
2025 } | 1995 } |
2026 | 1996 |
2027 | 1997 |
2028 TEST(SmiShiftLeft) { | 1998 TEST(SmiShiftLeft) { |
2029 i::V8::Initialize(NULL); | 1999 i::V8::Initialize(NULL); |
2030 // Allocate an executable page of memory. | 2000 // Allocate an executable page of memory. |
2031 size_t actual_size; | 2001 size_t actual_size; |
2032 byte* buffer = | 2002 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
2033 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 7, | 2003 Assembler::kMinimalBufferSize * 7, &actual_size, true)); |
2034 &actual_size, | |
2035 true)); | |
2036 CHECK(buffer); | 2004 CHECK(buffer); |
2037 Isolate* isolate = CcTest::i_isolate(); | 2005 Isolate* isolate = CcTest::i_isolate(); |
2038 HandleScope handles(isolate); | 2006 HandleScope handles(isolate); |
2039 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2007 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
2040 | 2008 |
2041 MacroAssembler* masm = &assembler; | 2009 MacroAssembler* masm = &assembler; |
2042 EntryCode(masm); | 2010 EntryCode(masm); |
2043 Label exit; | 2011 Label exit; |
2044 | 2012 |
2045 TestSmiShiftLeft(masm, &exit, 0x10, 0); | 2013 TestSmiShiftLeft(masm, &exit, 0x10, 0); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2128 __ addq(rax, Immediate(3)); | 2096 __ addq(rax, Immediate(3)); |
2129 } | 2097 } |
2130 } | 2098 } |
2131 } | 2099 } |
2132 | 2100 |
2133 | 2101 |
2134 TEST(SmiShiftLogicalRight) { | 2102 TEST(SmiShiftLogicalRight) { |
2135 i::V8::Initialize(NULL); | 2103 i::V8::Initialize(NULL); |
2136 // Allocate an executable page of memory. | 2104 // Allocate an executable page of memory. |
2137 size_t actual_size; | 2105 size_t actual_size; |
2138 byte* buffer = | 2106 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
2139 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 5, | 2107 Assembler::kMinimalBufferSize * 5, &actual_size, true)); |
2140 &actual_size, | |
2141 true)); | |
2142 CHECK(buffer); | 2108 CHECK(buffer); |
2143 Isolate* isolate = CcTest::i_isolate(); | 2109 Isolate* isolate = CcTest::i_isolate(); |
2144 HandleScope handles(isolate); | 2110 HandleScope handles(isolate); |
2145 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2111 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
2146 | 2112 |
2147 MacroAssembler* masm = &assembler; | 2113 MacroAssembler* masm = &assembler; |
2148 EntryCode(masm); | 2114 EntryCode(masm); |
2149 Label exit; | 2115 Label exit; |
2150 | 2116 |
2151 TestSmiShiftLogicalRight(masm, &exit, 0x10, 0); | 2117 TestSmiShiftLogicalRight(masm, &exit, 0x10, 0); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2197 | 2163 |
2198 __ incq(rax); | 2164 __ incq(rax); |
2199 } | 2165 } |
2200 } | 2166 } |
2201 | 2167 |
2202 | 2168 |
2203 TEST(SmiShiftArithmeticRight) { | 2169 TEST(SmiShiftArithmeticRight) { |
2204 i::V8::Initialize(NULL); | 2170 i::V8::Initialize(NULL); |
2205 // Allocate an executable page of memory. | 2171 // Allocate an executable page of memory. |
2206 size_t actual_size; | 2172 size_t actual_size; |
2207 byte* buffer = | 2173 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
2208 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, | 2174 Assembler::kMinimalBufferSize * 3, &actual_size, true)); |
2209 &actual_size, | |
2210 true)); | |
2211 CHECK(buffer); | 2175 CHECK(buffer); |
2212 Isolate* isolate = CcTest::i_isolate(); | 2176 Isolate* isolate = CcTest::i_isolate(); |
2213 HandleScope handles(isolate); | 2177 HandleScope handles(isolate); |
2214 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2178 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
2215 | 2179 |
2216 MacroAssembler* masm = &assembler; | 2180 MacroAssembler* masm = &assembler; |
2217 EntryCode(masm); | 2181 EntryCode(masm); |
2218 Label exit; | 2182 Label exit; |
2219 | 2183 |
2220 TestSmiShiftArithmeticRight(masm, &exit, 0x10, 0); | 2184 TestSmiShiftArithmeticRight(masm, &exit, 0x10, 0); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2261 __ j(not_equal, exit); | 2225 __ j(not_equal, exit); |
2262 __ incq(rax); | 2226 __ incq(rax); |
2263 } | 2227 } |
2264 } | 2228 } |
2265 | 2229 |
2266 | 2230 |
2267 TEST(PositiveSmiTimesPowerOfTwoToInteger64) { | 2231 TEST(PositiveSmiTimesPowerOfTwoToInteger64) { |
2268 i::V8::Initialize(NULL); | 2232 i::V8::Initialize(NULL); |
2269 // Allocate an executable page of memory. | 2233 // Allocate an executable page of memory. |
2270 size_t actual_size; | 2234 size_t actual_size; |
2271 byte* buffer = | 2235 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
2272 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, | 2236 Assembler::kMinimalBufferSize * 4, &actual_size, true)); |
2273 &actual_size, | |
2274 true)); | |
2275 CHECK(buffer); | 2237 CHECK(buffer); |
2276 Isolate* isolate = CcTest::i_isolate(); | 2238 Isolate* isolate = CcTest::i_isolate(); |
2277 HandleScope handles(isolate); | 2239 HandleScope handles(isolate); |
2278 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2240 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
2279 | 2241 |
2280 MacroAssembler* masm = &assembler; | 2242 MacroAssembler* masm = &assembler; |
2281 EntryCode(masm); | 2243 EntryCode(masm); |
2282 Label exit; | 2244 Label exit; |
2283 | 2245 |
2284 TestPositiveSmiPowerUp(masm, &exit, 0x20, 0); | 2246 TestPositiveSmiPowerUp(masm, &exit, 0x20, 0); |
(...skipping 19 matching lines...) Expand all Loading... |
2304 } | 2266 } |
2305 | 2267 |
2306 | 2268 |
2307 TEST(OperandOffset) { | 2269 TEST(OperandOffset) { |
2308 i::V8::Initialize(NULL); | 2270 i::V8::Initialize(NULL); |
2309 uint32_t data[256]; | 2271 uint32_t data[256]; |
2310 for (uint32_t i = 0; i < 256; i++) { data[i] = i * 0x01010101; } | 2272 for (uint32_t i = 0; i < 256; i++) { data[i] = i * 0x01010101; } |
2311 | 2273 |
2312 // Allocate an executable page of memory. | 2274 // Allocate an executable page of memory. |
2313 size_t actual_size; | 2275 size_t actual_size; |
2314 byte* buffer = | 2276 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
2315 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 2277 Assembler::kMinimalBufferSize * 2, &actual_size, true)); |
2316 &actual_size, | |
2317 true)); | |
2318 CHECK(buffer); | 2278 CHECK(buffer); |
2319 Isolate* isolate = CcTest::i_isolate(); | 2279 Isolate* isolate = CcTest::i_isolate(); |
2320 HandleScope handles(isolate); | 2280 HandleScope handles(isolate); |
2321 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2281 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
2322 | 2282 |
2323 MacroAssembler* masm = &assembler; | 2283 MacroAssembler* masm = &assembler; |
2324 Label exit; | 2284 Label exit; |
2325 | 2285 |
2326 EntryCode(masm); | 2286 EntryCode(masm); |
2327 __ pushq(r13); | 2287 __ pushq(r13); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2658 int result = FUNCTION_CAST<F0>(buffer)(); | 2618 int result = FUNCTION_CAST<F0>(buffer)(); |
2659 CHECK_EQ(0, result); | 2619 CHECK_EQ(0, result); |
2660 } | 2620 } |
2661 | 2621 |
2662 | 2622 |
2663 TEST(LoadAndStoreWithRepresentation) { | 2623 TEST(LoadAndStoreWithRepresentation) { |
2664 v8::internal::V8::Initialize(NULL); | 2624 v8::internal::V8::Initialize(NULL); |
2665 | 2625 |
2666 // Allocate an executable page of memory. | 2626 // Allocate an executable page of memory. |
2667 size_t actual_size; | 2627 size_t actual_size; |
2668 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 2628 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( |
2669 &actual_size, | 2629 Assembler::kMinimalBufferSize, &actual_size, true)); |
2670 true)); | |
2671 CHECK(buffer); | 2630 CHECK(buffer); |
2672 Isolate* isolate = CcTest::i_isolate(); | 2631 Isolate* isolate = CcTest::i_isolate(); |
2673 HandleScope handles(isolate); | 2632 HandleScope handles(isolate); |
2674 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2633 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
2675 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. | 2634 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. |
2676 EntryCode(masm); | 2635 EntryCode(masm); |
2677 __ subq(rsp, Immediate(1 * kPointerSize)); | 2636 __ subq(rsp, Immediate(1 * kPointerSize)); |
2678 Label exit; | 2637 Label exit; |
2679 | 2638 |
2680 // Test 1. | 2639 // Test 1. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2804 | 2763 |
2805 CodeDesc desc; | 2764 CodeDesc desc; |
2806 masm->GetCode(&desc); | 2765 masm->GetCode(&desc); |
2807 // Call the function from C++. | 2766 // Call the function from C++. |
2808 int result = FUNCTION_CAST<F0>(buffer)(); | 2767 int result = FUNCTION_CAST<F0>(buffer)(); |
2809 CHECK_EQ(0, result); | 2768 CHECK_EQ(0, result); |
2810 } | 2769 } |
2811 | 2770 |
2812 | 2771 |
2813 #undef __ | 2772 #undef __ |
OLD | NEW |