| 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 17 matching lines...) Expand all Loading... |
| 28 #include <stdlib.h> | 28 #include <stdlib.h> |
| 29 | 29 |
| 30 #include "v8.h" | 30 #include "v8.h" |
| 31 | 31 |
| 32 #include "macro-assembler.h" | 32 #include "macro-assembler.h" |
| 33 #include "factory.h" | 33 #include "factory.h" |
| 34 #include "platform.h" | 34 #include "platform.h" |
| 35 #include "serialize.h" | 35 #include "serialize.h" |
| 36 #include "cctest.h" | 36 #include "cctest.h" |
| 37 | 37 |
| 38 using v8::internal::Assembler; | 38 namespace i = v8::internal; |
| 39 using v8::internal::CodeDesc; | 39 using i::Assembler; |
| 40 using v8::internal::Condition; | 40 using i::CodeDesc; |
| 41 using v8::internal::FUNCTION_CAST; | 41 using i::Condition; |
| 42 using v8::internal::HandleScope; | 42 using i::FUNCTION_CAST; |
| 43 using v8::internal::Immediate; | 43 using i::HandleScope; |
| 44 using v8::internal::Isolate; | 44 using i::Immediate; |
| 45 using v8::internal::Label; | 45 using i::Isolate; |
| 46 using v8::internal::MacroAssembler; | 46 using i::Label; |
| 47 using v8::internal::OS; | 47 using i::MacroAssembler; |
| 48 using v8::internal::Operand; | 48 using i::OS; |
| 49 using v8::internal::RelocInfo; | 49 using i::Operand; |
| 50 using v8::internal::Smi; | 50 using i::RelocInfo; |
| 51 using v8::internal::SmiIndex; | 51 using i::Smi; |
| 52 using v8::internal::byte; | 52 using i::SmiIndex; |
| 53 using v8::internal::carry; | 53 using i::byte; |
| 54 using v8::internal::greater; | 54 using i::carry; |
| 55 using v8::internal::greater_equal; | 55 using i::greater; |
| 56 using v8::internal::kIntSize; | 56 using i::greater_equal; |
| 57 using v8::internal::kPointerSize; | 57 using i::kIntSize; |
| 58 using v8::internal::kSmiTagMask; | 58 using i::kPointerSize; |
| 59 using v8::internal::kSmiValueSize; | 59 using i::kSmiTagMask; |
| 60 using v8::internal::less_equal; | 60 using i::kSmiValueSize; |
| 61 using v8::internal::negative; | 61 using i::less_equal; |
| 62 using v8::internal::not_carry; | 62 using i::negative; |
| 63 using v8::internal::not_equal; | 63 using i::not_carry; |
| 64 using v8::internal::not_zero; | 64 using i::not_equal; |
| 65 using v8::internal::positive; | 65 using i::not_zero; |
| 66 using v8::internal::r11; | 66 using i::positive; |
| 67 using v8::internal::r13; | 67 using i::r11; |
| 68 using v8::internal::r14; | 68 using i::r13; |
| 69 using v8::internal::r15; | 69 using i::r14; |
| 70 using v8::internal::r8; | 70 using i::r15; |
| 71 using v8::internal::r9; | 71 using i::r8; |
| 72 using v8::internal::rax; | 72 using i::r9; |
| 73 using v8::internal::rbp; | 73 using i::rax; |
| 74 using v8::internal::rbx; | 74 using i::rbp; |
| 75 using v8::internal::rcx; | 75 using i::rbx; |
| 76 using v8::internal::rdi; | 76 using i::rcx; |
| 77 using v8::internal::rdx; | 77 using i::rdi; |
| 78 using v8::internal::rsi; | 78 using i::rdx; |
| 79 using v8::internal::rsp; | 79 using i::rsi; |
| 80 using v8::internal::times_pointer_size; | 80 using i::rsp; |
| 81 using i::times_pointer_size; |
| 81 | 82 |
| 82 // Test the x64 assembler by compiling some simple functions into | 83 // Test the x64 assembler by compiling some simple functions into |
| 83 // a buffer and executing them. These tests do not initialize the | 84 // a buffer and executing them. These tests do not initialize the |
| 84 // V8 library, create a context, or use any V8 objects. | 85 // V8 library, create a context, or use any V8 objects. |
| 85 // The AMD64 calling convention is used, with the first five arguments | 86 // The AMD64 calling convention is used, with the first five arguments |
| 86 // in RSI, RDI, RDX, RCX, R8, and R9, and floating point arguments in | 87 // in RSI, RDI, RDX, RCX, R8, and R9, and floating point arguments in |
| 87 // the XMM registers. The return value is in RAX. | 88 // the XMM registers. The return value is in RAX. |
| 88 // This calling convention is used on Linux, with GCC, and on Mac OS, | 89 // This calling convention is used on Linux, with GCC, and on Mac OS, |
| 89 // with GCC. A different convention is used on 64-bit windows. | 90 // with GCC. A different convention is used on 64-bit windows. |
| 90 | 91 |
| 91 typedef int (*F0)(); | 92 typedef int (*F0)(); |
| 92 | 93 |
| 93 #define __ masm-> | 94 #define __ masm-> |
| 94 | 95 |
| 95 | 96 |
| 96 static void EntryCode(MacroAssembler* masm) { | 97 static void EntryCode(MacroAssembler* masm) { |
| 97 // Smi constant register is callee save. | 98 // Smi constant register is callee save. |
| 98 __ push(v8::internal::kSmiConstantRegister); | 99 __ push(i::kSmiConstantRegister); |
| 99 __ push(v8::internal::kRootRegister); | 100 __ push(i::kRootRegister); |
| 100 __ InitializeSmiConstantRegister(); | 101 __ InitializeSmiConstantRegister(); |
| 101 __ InitializeRootRegister(); | 102 __ InitializeRootRegister(); |
| 102 } | 103 } |
| 103 | 104 |
| 104 | 105 |
| 105 static void ExitCode(MacroAssembler* masm) { | 106 static void ExitCode(MacroAssembler* masm) { |
| 106 // Return -1 if kSmiConstantRegister was clobbered during the test. | 107 // Return -1 if kSmiConstantRegister was clobbered during the test. |
| 107 __ Move(rdx, Smi::FromInt(1)); | 108 __ Move(rdx, Smi::FromInt(1)); |
| 108 __ cmpq(rdx, v8::internal::kSmiConstantRegister); | 109 __ cmpq(rdx, i::kSmiConstantRegister); |
| 109 __ movq(rdx, Immediate(-1)); | 110 __ movq(rdx, Immediate(-1)); |
| 110 __ cmovq(not_equal, rax, rdx); | 111 __ cmovq(not_equal, rax, rdx); |
| 111 __ pop(v8::internal::kRootRegister); | 112 __ pop(i::kRootRegister); |
| 112 __ pop(v8::internal::kSmiConstantRegister); | 113 __ pop(i::kSmiConstantRegister); |
| 113 } | 114 } |
| 114 | 115 |
| 115 | 116 |
| 116 TEST(Smi) { | 117 TEST(Smi) { |
| 117 // Check that C++ Smi operations work as expected. | 118 // Check that C++ Smi operations work as expected. |
| 118 int64_t test_numbers[] = { | 119 int64_t test_numbers[] = { |
| 119 0, 1, -1, 127, 128, -128, -129, 255, 256, -256, -257, | 120 0, 1, -1, 127, 128, -128, -129, 255, 256, -256, -257, |
| 120 Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1, | 121 Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1, |
| 121 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1 | 122 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1 |
| 122 }; | 123 }; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 143 __ movl(rax, Immediate(id)); | 144 __ movl(rax, Immediate(id)); |
| 144 __ Move(rcx, value); | 145 __ Move(rcx, value); |
| 145 __ Set(rdx, reinterpret_cast<intptr_t>(value)); | 146 __ Set(rdx, reinterpret_cast<intptr_t>(value)); |
| 146 __ cmpq(rcx, rdx); | 147 __ cmpq(rcx, rdx); |
| 147 __ j(not_equal, exit); | 148 __ j(not_equal, exit); |
| 148 } | 149 } |
| 149 | 150 |
| 150 | 151 |
| 151 // Test that we can move a Smi value literally into a register. | 152 // Test that we can move a Smi value literally into a register. |
| 152 TEST(SmiMove) { | 153 TEST(SmiMove) { |
| 153 v8::internal::V8::Initialize(NULL); | 154 i::V8::Initialize(NULL); |
| 154 // Allocate an executable page of memory. | 155 // Allocate an executable page of memory. |
| 155 size_t actual_size; | 156 size_t actual_size; |
| 156 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 157 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 157 &actual_size, | 158 &actual_size, |
| 158 true)); | 159 true)); |
| 159 CHECK(buffer); | 160 CHECK(buffer); |
| 160 Isolate* isolate = CcTest::i_isolate(); | 161 Isolate* isolate = CcTest::i_isolate(); |
| 161 HandleScope handles(isolate); | 162 HandleScope handles(isolate); |
| 162 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 163 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 163 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. | 164 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 __ j(not_equal, exit); | 232 __ j(not_equal, exit); |
| 232 __ incq(rax); | 233 __ incq(rax); |
| 233 __ cmpq(rcx, r8); | 234 __ cmpq(rcx, r8); |
| 234 __ j(not_equal, exit); | 235 __ j(not_equal, exit); |
| 235 } | 236 } |
| 236 } | 237 } |
| 237 | 238 |
| 238 | 239 |
| 239 // Test that we can compare smis for equality (and more). | 240 // Test that we can compare smis for equality (and more). |
| 240 TEST(SmiCompare) { | 241 TEST(SmiCompare) { |
| 241 v8::internal::V8::Initialize(NULL); | 242 i::V8::Initialize(NULL); |
| 242 // Allocate an executable page of memory. | 243 // Allocate an executable page of memory. |
| 243 size_t actual_size; | 244 size_t actual_size; |
| 244 byte* buffer = | 245 byte* buffer = |
| 245 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 246 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 246 &actual_size, | 247 &actual_size, |
| 247 true)); | 248 true)); |
| 248 CHECK(buffer); | 249 CHECK(buffer); |
| 249 Isolate* isolate = CcTest::i_isolate(); | 250 Isolate* isolate = CcTest::i_isolate(); |
| 250 HandleScope handles(isolate); | 251 HandleScope handles(isolate); |
| 251 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 252 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 CodeDesc desc; | 284 CodeDesc desc; |
| 284 masm->GetCode(&desc); | 285 masm->GetCode(&desc); |
| 285 // Call the function from C++. | 286 // Call the function from C++. |
| 286 int result = FUNCTION_CAST<F0>(buffer)(); | 287 int result = FUNCTION_CAST<F0>(buffer)(); |
| 287 CHECK_EQ(0, result); | 288 CHECK_EQ(0, result); |
| 288 } | 289 } |
| 289 | 290 |
| 290 | 291 |
| 291 | 292 |
| 292 TEST(Integer32ToSmi) { | 293 TEST(Integer32ToSmi) { |
| 293 v8::internal::V8::Initialize(NULL); | 294 i::V8::Initialize(NULL); |
| 294 // Allocate an executable page of memory. | 295 // Allocate an executable page of memory. |
| 295 size_t actual_size; | 296 size_t actual_size; |
| 296 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 297 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 297 &actual_size, | 298 &actual_size, |
| 298 true)); | 299 true)); |
| 299 CHECK(buffer); | 300 CHECK(buffer); |
| 300 Isolate* isolate = CcTest::i_isolate(); | 301 Isolate* isolate = CcTest::i_isolate(); |
| 301 HandleScope handles(isolate); | 302 HandleScope handles(isolate); |
| 302 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 303 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 303 | 304 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 __ j(not_equal, exit); | 413 __ j(not_equal, exit); |
| 413 | 414 |
| 414 __ incq(rax); | 415 __ incq(rax); |
| 415 __ Integer64PlusConstantToSmi(rcx, rcx, y); | 416 __ Integer64PlusConstantToSmi(rcx, rcx, y); |
| 416 __ cmpq(rcx, r8); | 417 __ cmpq(rcx, r8); |
| 417 __ j(not_equal, exit); | 418 __ j(not_equal, exit); |
| 418 } | 419 } |
| 419 | 420 |
| 420 | 421 |
| 421 TEST(Integer64PlusConstantToSmi) { | 422 TEST(Integer64PlusConstantToSmi) { |
| 422 v8::internal::V8::Initialize(NULL); | 423 i::V8::Initialize(NULL); |
| 423 // Allocate an executable page of memory. | 424 // Allocate an executable page of memory. |
| 424 size_t actual_size; | 425 size_t actual_size; |
| 425 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 426 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 426 &actual_size, | 427 &actual_size, |
| 427 true)); | 428 true)); |
| 428 CHECK(buffer); | 429 CHECK(buffer); |
| 429 Isolate* isolate = CcTest::i_isolate(); | 430 Isolate* isolate = CcTest::i_isolate(); |
| 430 HandleScope handles(isolate); | 431 HandleScope handles(isolate); |
| 431 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 432 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 432 | 433 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 457 | 458 |
| 458 CodeDesc desc; | 459 CodeDesc desc; |
| 459 masm->GetCode(&desc); | 460 masm->GetCode(&desc); |
| 460 // Call the function from C++. | 461 // Call the function from C++. |
| 461 int result = FUNCTION_CAST<F0>(buffer)(); | 462 int result = FUNCTION_CAST<F0>(buffer)(); |
| 462 CHECK_EQ(0, result); | 463 CHECK_EQ(0, result); |
| 463 } | 464 } |
| 464 | 465 |
| 465 | 466 |
| 466 TEST(SmiCheck) { | 467 TEST(SmiCheck) { |
| 467 v8::internal::V8::Initialize(NULL); | 468 i::V8::Initialize(NULL); |
| 468 // Allocate an executable page of memory. | 469 // Allocate an executable page of memory. |
| 469 size_t actual_size; | 470 size_t actual_size; |
| 470 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 471 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 471 &actual_size, | 472 &actual_size, |
| 472 true)); | 473 true)); |
| 473 CHECK(buffer); | 474 CHECK(buffer); |
| 474 Isolate* isolate = CcTest::i_isolate(); | 475 Isolate* isolate = CcTest::i_isolate(); |
| 475 HandleScope handles(isolate); | 476 HandleScope handles(isolate); |
| 476 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 477 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 477 | 478 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 __ jmp(exit); | 706 __ jmp(exit); |
| 706 __ bind(&smi_ok2); | 707 __ bind(&smi_ok2); |
| 707 __ incq(rax); | 708 __ incq(rax); |
| 708 __ cmpq(rcx, r8); | 709 __ cmpq(rcx, r8); |
| 709 __ j(not_equal, exit); | 710 __ j(not_equal, exit); |
| 710 } | 711 } |
| 711 } | 712 } |
| 712 | 713 |
| 713 | 714 |
| 714 TEST(SmiNeg) { | 715 TEST(SmiNeg) { |
| 715 v8::internal::V8::Initialize(NULL); | 716 i::V8::Initialize(NULL); |
| 716 // Allocate an executable page of memory. | 717 // Allocate an executable page of memory. |
| 717 size_t actual_size; | 718 size_t actual_size; |
| 718 byte* buffer = | 719 byte* buffer = |
| 719 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 720 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 720 &actual_size, | 721 &actual_size, |
| 721 true)); | 722 true)); |
| 722 CHECK(buffer); | 723 CHECK(buffer); |
| 723 Isolate* isolate = CcTest::i_isolate(); | 724 Isolate* isolate = CcTest::i_isolate(); |
| 724 HandleScope handles(isolate); | 725 HandleScope handles(isolate); |
| 725 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 726 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 __ jmp(exit); | 901 __ jmp(exit); |
| 901 __ bind(&overflow_ok); | 902 __ bind(&overflow_ok); |
| 902 __ incq(rax); | 903 __ incq(rax); |
| 903 __ cmpq(rcx, r11); | 904 __ cmpq(rcx, r11); |
| 904 __ j(not_equal, exit); | 905 __ j(not_equal, exit); |
| 905 } | 906 } |
| 906 } | 907 } |
| 907 | 908 |
| 908 | 909 |
| 909 TEST(SmiAdd) { | 910 TEST(SmiAdd) { |
| 910 v8::internal::V8::Initialize(NULL); | 911 i::V8::Initialize(NULL); |
| 911 // Allocate an executable page of memory. | 912 // Allocate an executable page of memory. |
| 912 size_t actual_size; | 913 size_t actual_size; |
| 913 byte* buffer = | 914 byte* buffer = |
| 914 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 915 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 915 &actual_size, | 916 &actual_size, |
| 916 true)); | 917 true)); |
| 917 CHECK(buffer); | 918 CHECK(buffer); |
| 918 Isolate* isolate = CcTest::i_isolate(); | 919 Isolate* isolate = CcTest::i_isolate(); |
| 919 HandleScope handles(isolate); | 920 HandleScope handles(isolate); |
| 920 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 921 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 __ incq(rax); // Test 2. | 980 __ incq(rax); // Test 2. |
| 980 __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); | 981 __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); |
| 981 __ cmpq(r9, r8); | 982 __ cmpq(r9, r8); |
| 982 __ j(not_equal, exit); | 983 __ j(not_equal, exit); |
| 983 | 984 |
| 984 __ incq(rax); // Test 3. | 985 __ incq(rax); // Test 3. |
| 985 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); | 986 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); |
| 986 __ cmpq(rcx, r8); | 987 __ cmpq(rcx, r8); |
| 987 __ j(not_equal, exit); | 988 __ j(not_equal, exit); |
| 988 | 989 |
| 990 i::SmiOperationExecutionMode overflow_mode( |
| 991 (1 << i::NEED_RESERVE_SOURCES) | (1 << i::BAILOUT_ON_OVERFLOW)); |
| 989 __ Move(rcx, Smi::FromInt(first)); | 992 __ Move(rcx, Smi::FromInt(first)); |
| 990 | |
| 991 __ incq(rax); // Test 4. | 993 __ incq(rax); // Test 4. |
| 992 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), exit); | 994 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), overflow_mode, exit); |
| 993 __ cmpq(r9, r8); | 995 __ cmpq(rcx, r8); |
| 994 __ j(not_equal, exit); | 996 __ j(not_equal, exit); |
| 995 | 997 |
| 998 i::SmiOperationExecutionMode no_overflow_mode( |
| 999 (1 << i::NEED_RESERVE_SOURCES) | (1 << i::BAILOUT_ON_NO_OVERFLOW)); |
| 1000 __ Move(rcx, Smi::FromInt(first)); |
| 1001 Label done; |
| 996 __ incq(rax); // Test 5. | 1002 __ incq(rax); // Test 5. |
| 997 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), exit); | 1003 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), no_overflow_mode, &done); |
| 1004 __ jmp(exit); |
| 1005 __ bind(&done); |
| 998 __ cmpq(rcx, r8); | 1006 __ cmpq(rcx, r8); |
| 999 __ j(not_equal, exit); | 1007 __ j(not_equal, exit); |
| 1000 } | 1008 } |
| 1001 | 1009 |
| 1002 | 1010 |
| 1003 static void SmiSubOverflowTest(MacroAssembler* masm, | 1011 static void SmiSubOverflowTest(MacroAssembler* masm, |
| 1004 Label* exit, | 1012 Label* exit, |
| 1005 int id, | 1013 int id, |
| 1006 int x) { | 1014 int x) { |
| 1007 // Subtracts a Smi from x so that the subtraction overflows. | 1015 // Subtracts a Smi from x so that the subtraction overflows. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1028 __ incq(rax); | 1036 __ incq(rax); |
| 1029 __ SmiSub(rcx, rcx, rdx, &overflow_ok); | 1037 __ SmiSub(rcx, rcx, rdx, &overflow_ok); |
| 1030 __ jmp(exit); | 1038 __ jmp(exit); |
| 1031 __ bind(&overflow_ok); | 1039 __ bind(&overflow_ok); |
| 1032 __ incq(rax); | 1040 __ incq(rax); |
| 1033 __ cmpq(rcx, r11); | 1041 __ cmpq(rcx, r11); |
| 1034 __ j(not_equal, exit); | 1042 __ j(not_equal, exit); |
| 1035 } | 1043 } |
| 1036 | 1044 |
| 1037 __ movq(rcx, r11); | 1045 __ movq(rcx, r11); |
| 1046 i::SmiOperationExecutionMode mode( |
| 1047 (1 << i::NEED_RESERVE_SOURCES) | (1 << i::BAILOUT_ON_OVERFLOW)); |
| 1038 { | 1048 { |
| 1039 Label overflow_ok; | 1049 Label overflow_ok; |
| 1040 __ incq(rax); | 1050 __ incq(rax); |
| 1041 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), &overflow_ok); | 1051 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), mode, &overflow_ok); |
| 1042 __ jmp(exit); | 1052 __ jmp(exit); |
| 1043 __ bind(&overflow_ok); | 1053 __ bind(&overflow_ok); |
| 1044 __ incq(rax); | 1054 __ incq(rax); |
| 1045 __ cmpq(rcx, r11); | |
| 1046 __ j(not_equal, exit); | |
| 1047 } | |
| 1048 | |
| 1049 { | |
| 1050 Label overflow_ok; | |
| 1051 __ incq(rax); | |
| 1052 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), &overflow_ok); | |
| 1053 __ jmp(exit); | |
| 1054 __ bind(&overflow_ok); | |
| 1055 __ incq(rax); | |
| 1056 __ cmpq(rcx, r11); | 1055 __ cmpq(rcx, r11); |
| 1057 __ j(not_equal, exit); | 1056 __ j(not_equal, exit); |
| 1058 } | 1057 } |
| 1059 | 1058 |
| 1060 __ Move(rdx, Smi::FromInt(y_max)); | 1059 __ Move(rdx, Smi::FromInt(y_max)); |
| 1061 | 1060 |
| 1062 { | 1061 { |
| 1063 Label overflow_ok; | 1062 Label overflow_ok; |
| 1064 __ incq(rax); | 1063 __ incq(rax); |
| 1065 __ SmiSub(r9, rcx, rdx, &overflow_ok); | 1064 __ SmiSub(r9, rcx, rdx, &overflow_ok); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1078 __ bind(&overflow_ok); | 1077 __ bind(&overflow_ok); |
| 1079 __ incq(rax); | 1078 __ incq(rax); |
| 1080 __ cmpq(rcx, r11); | 1079 __ cmpq(rcx, r11); |
| 1081 __ j(not_equal, exit); | 1080 __ j(not_equal, exit); |
| 1082 } | 1081 } |
| 1083 | 1082 |
| 1084 __ movq(rcx, r11); | 1083 __ movq(rcx, r11); |
| 1085 { | 1084 { |
| 1086 Label overflow_ok; | 1085 Label overflow_ok; |
| 1087 __ incq(rax); | 1086 __ incq(rax); |
| 1088 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_max), &overflow_ok); | 1087 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), mode, &overflow_ok); |
| 1089 __ jmp(exit); | 1088 __ jmp(exit); |
| 1090 __ bind(&overflow_ok); | 1089 __ bind(&overflow_ok); |
| 1091 __ incq(rax); | 1090 __ incq(rax); |
| 1092 __ cmpq(rcx, r11); | |
| 1093 __ j(not_equal, exit); | |
| 1094 } | |
| 1095 | |
| 1096 { | |
| 1097 Label overflow_ok; | |
| 1098 __ incq(rax); | |
| 1099 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), &overflow_ok); | |
| 1100 __ jmp(exit); | |
| 1101 __ bind(&overflow_ok); | |
| 1102 __ incq(rax); | |
| 1103 __ cmpq(rcx, r11); | 1091 __ cmpq(rcx, r11); |
| 1104 __ j(not_equal, exit); | 1092 __ j(not_equal, exit); |
| 1105 } | 1093 } |
| 1106 } | 1094 } |
| 1107 | 1095 |
| 1108 | 1096 |
| 1109 TEST(SmiSub) { | 1097 TEST(SmiSub) { |
| 1110 v8::internal::V8::Initialize(NULL); | 1098 i::V8::Initialize(NULL); |
| 1111 // Allocate an executable page of memory. | 1099 // Allocate an executable page of memory. |
| 1112 size_t actual_size; | 1100 size_t actual_size; |
| 1113 byte* buffer = | 1101 byte* buffer = |
| 1114 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1102 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 1115 &actual_size, | 1103 &actual_size, |
| 1116 true)); | 1104 true)); |
| 1117 CHECK(buffer); | 1105 CHECK(buffer); |
| 1118 Isolate* isolate = CcTest::i_isolate(); | 1106 Isolate* isolate = CcTest::i_isolate(); |
| 1119 HandleScope handles(isolate); | 1107 HandleScope handles(isolate); |
| 1120 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1108 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 __ bind(&overflow_ok2); | 1180 __ bind(&overflow_ok2); |
| 1193 // 31-bit version doesn't preserve rcx on failure. | 1181 // 31-bit version doesn't preserve rcx on failure. |
| 1194 // __ incq(rax); | 1182 // __ incq(rax); |
| 1195 // __ cmpq(r11, rcx); | 1183 // __ cmpq(r11, rcx); |
| 1196 // __ j(not_equal, exit); | 1184 // __ j(not_equal, exit); |
| 1197 } | 1185 } |
| 1198 } | 1186 } |
| 1199 | 1187 |
| 1200 | 1188 |
| 1201 TEST(SmiMul) { | 1189 TEST(SmiMul) { |
| 1202 v8::internal::V8::Initialize(NULL); | 1190 i::V8::Initialize(NULL); |
| 1203 // Allocate an executable page of memory. | 1191 // Allocate an executable page of memory. |
| 1204 size_t actual_size; | 1192 size_t actual_size; |
| 1205 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1193 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1206 &actual_size, | 1194 &actual_size, |
| 1207 true)); | 1195 true)); |
| 1208 CHECK(buffer); | 1196 CHECK(buffer); |
| 1209 Isolate* isolate = CcTest::i_isolate(); | 1197 Isolate* isolate = CcTest::i_isolate(); |
| 1210 HandleScope handles(isolate); | 1198 HandleScope handles(isolate); |
| 1211 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1199 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 1212 | 1200 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 __ bind(&fail_ok2); | 1286 __ bind(&fail_ok2); |
| 1299 | 1287 |
| 1300 __ incq(r15); | 1288 __ incq(r15); |
| 1301 __ cmpq(rcx, r11); | 1289 __ cmpq(rcx, r11); |
| 1302 __ j(not_equal, exit); | 1290 __ j(not_equal, exit); |
| 1303 } | 1291 } |
| 1304 } | 1292 } |
| 1305 | 1293 |
| 1306 | 1294 |
| 1307 TEST(SmiDiv) { | 1295 TEST(SmiDiv) { |
| 1308 v8::internal::V8::Initialize(NULL); | 1296 i::V8::Initialize(NULL); |
| 1309 // Allocate an executable page of memory. | 1297 // Allocate an executable page of memory. |
| 1310 size_t actual_size; | 1298 size_t actual_size; |
| 1311 byte* buffer = | 1299 byte* buffer = |
| 1312 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1300 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 1313 &actual_size, | 1301 &actual_size, |
| 1314 true)); | 1302 true)); |
| 1315 CHECK(buffer); | 1303 CHECK(buffer); |
| 1316 Isolate* isolate = CcTest::i_isolate(); | 1304 Isolate* isolate = CcTest::i_isolate(); |
| 1317 HandleScope handles(isolate); | 1305 HandleScope handles(isolate); |
| 1318 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1306 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 __ bind(&fail_ok2); | 1397 __ bind(&fail_ok2); |
| 1410 | 1398 |
| 1411 __ incq(r15); | 1399 __ incq(r15); |
| 1412 __ cmpq(rcx, r11); | 1400 __ cmpq(rcx, r11); |
| 1413 __ j(not_equal, exit); | 1401 __ j(not_equal, exit); |
| 1414 } | 1402 } |
| 1415 } | 1403 } |
| 1416 | 1404 |
| 1417 | 1405 |
| 1418 TEST(SmiMod) { | 1406 TEST(SmiMod) { |
| 1419 v8::internal::V8::Initialize(NULL); | 1407 i::V8::Initialize(NULL); |
| 1420 // Allocate an executable page of memory. | 1408 // Allocate an executable page of memory. |
| 1421 size_t actual_size; | 1409 size_t actual_size; |
| 1422 byte* buffer = | 1410 byte* buffer = |
| 1423 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1411 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 1424 &actual_size, | 1412 &actual_size, |
| 1425 true)); | 1413 true)); |
| 1426 CHECK(buffer); | 1414 CHECK(buffer); |
| 1427 Isolate* isolate = CcTest::i_isolate(); | 1415 Isolate* isolate = CcTest::i_isolate(); |
| 1428 HandleScope handles(isolate); | 1416 HandleScope handles(isolate); |
| 1429 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1417 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 __ shl(rcx, Immediate(index.scale)); | 1495 __ shl(rcx, Immediate(index.scale)); |
| 1508 __ Set(r8, static_cast<intptr_t>(-x) << i); | 1496 __ Set(r8, static_cast<intptr_t>(-x) << i); |
| 1509 __ cmpq(rcx, r8); | 1497 __ cmpq(rcx, r8); |
| 1510 __ j(not_equal, exit); | 1498 __ j(not_equal, exit); |
| 1511 __ incq(rax); | 1499 __ incq(rax); |
| 1512 } | 1500 } |
| 1513 } | 1501 } |
| 1514 | 1502 |
| 1515 | 1503 |
| 1516 TEST(SmiIndex) { | 1504 TEST(SmiIndex) { |
| 1517 v8::internal::V8::Initialize(NULL); | 1505 i::V8::Initialize(NULL); |
| 1518 // Allocate an executable page of memory. | 1506 // Allocate an executable page of memory. |
| 1519 size_t actual_size; | 1507 size_t actual_size; |
| 1520 byte* buffer = | 1508 byte* buffer = |
| 1521 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, | 1509 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, |
| 1522 &actual_size, | 1510 &actual_size, |
| 1523 true)); | 1511 true)); |
| 1524 CHECK(buffer); | 1512 CHECK(buffer); |
| 1525 Isolate* isolate = CcTest::i_isolate(); | 1513 Isolate* isolate = CcTest::i_isolate(); |
| 1526 HandleScope handles(isolate); | 1514 HandleScope handles(isolate); |
| 1527 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1515 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 __ Move(rdx, Smi::FromInt(y)); | 1565 __ Move(rdx, Smi::FromInt(y)); |
| 1578 __ xor_(rcx, Immediate(kSmiTagMask)); | 1566 __ xor_(rcx, Immediate(kSmiTagMask)); |
| 1579 __ xor_(rdx, Immediate(kSmiTagMask)); | 1567 __ xor_(rdx, Immediate(kSmiTagMask)); |
| 1580 __ SelectNonSmi(r9, rcx, rdx, &fail_ok); | 1568 __ SelectNonSmi(r9, rcx, rdx, &fail_ok); |
| 1581 __ jmp(exit); | 1569 __ jmp(exit); |
| 1582 __ bind(&fail_ok); | 1570 __ bind(&fail_ok); |
| 1583 } | 1571 } |
| 1584 | 1572 |
| 1585 | 1573 |
| 1586 TEST(SmiSelectNonSmi) { | 1574 TEST(SmiSelectNonSmi) { |
| 1587 v8::internal::V8::Initialize(NULL); | 1575 i::V8::Initialize(NULL); |
| 1588 // Allocate an executable page of memory. | 1576 // Allocate an executable page of memory. |
| 1589 size_t actual_size; | 1577 size_t actual_size; |
| 1590 byte* buffer = | 1578 byte* buffer = |
| 1591 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1579 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1592 &actual_size, | 1580 &actual_size, |
| 1593 true)); | 1581 true)); |
| 1594 CHECK(buffer); | 1582 CHECK(buffer); |
| 1595 Isolate* isolate = CcTest::i_isolate(); | 1583 Isolate* isolate = CcTest::i_isolate(); |
| 1596 HandleScope handles(isolate); | 1584 HandleScope handles(isolate); |
| 1597 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1585 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 __ j(not_equal, exit); | 1645 __ j(not_equal, exit); |
| 1658 | 1646 |
| 1659 __ incq(rax); | 1647 __ incq(rax); |
| 1660 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y)); | 1648 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y)); |
| 1661 __ cmpq(r8, rcx); | 1649 __ cmpq(r8, rcx); |
| 1662 __ j(not_equal, exit); | 1650 __ j(not_equal, exit); |
| 1663 } | 1651 } |
| 1664 | 1652 |
| 1665 | 1653 |
| 1666 TEST(SmiAnd) { | 1654 TEST(SmiAnd) { |
| 1667 v8::internal::V8::Initialize(NULL); | 1655 i::V8::Initialize(NULL); |
| 1668 // Allocate an executable page of memory. | 1656 // Allocate an executable page of memory. |
| 1669 size_t actual_size; | 1657 size_t actual_size; |
| 1670 byte* buffer = | 1658 byte* buffer = |
| 1671 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1659 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1672 &actual_size, | 1660 &actual_size, |
| 1673 true)); | 1661 true)); |
| 1674 CHECK(buffer); | 1662 CHECK(buffer); |
| 1675 Isolate* isolate = CcTest::i_isolate(); | 1663 Isolate* isolate = CcTest::i_isolate(); |
| 1676 HandleScope handles(isolate); | 1664 HandleScope handles(isolate); |
| 1677 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1665 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1739 __ j(not_equal, exit); | 1727 __ j(not_equal, exit); |
| 1740 | 1728 |
| 1741 __ incq(rax); | 1729 __ incq(rax); |
| 1742 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y)); | 1730 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y)); |
| 1743 __ cmpq(r8, rcx); | 1731 __ cmpq(r8, rcx); |
| 1744 __ j(not_equal, exit); | 1732 __ j(not_equal, exit); |
| 1745 } | 1733 } |
| 1746 | 1734 |
| 1747 | 1735 |
| 1748 TEST(SmiOr) { | 1736 TEST(SmiOr) { |
| 1749 v8::internal::V8::Initialize(NULL); | 1737 i::V8::Initialize(NULL); |
| 1750 // Allocate an executable page of memory. | 1738 // Allocate an executable page of memory. |
| 1751 size_t actual_size; | 1739 size_t actual_size; |
| 1752 byte* buffer = | 1740 byte* buffer = |
| 1753 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1741 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1754 &actual_size, | 1742 &actual_size, |
| 1755 true)); | 1743 true)); |
| 1756 CHECK(buffer); | 1744 CHECK(buffer); |
| 1757 Isolate* isolate = CcTest::i_isolate(); | 1745 Isolate* isolate = CcTest::i_isolate(); |
| 1758 HandleScope handles(isolate); | 1746 HandleScope handles(isolate); |
| 1759 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1747 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 __ j(not_equal, exit); | 1811 __ j(not_equal, exit); |
| 1824 | 1812 |
| 1825 __ incq(rax); | 1813 __ incq(rax); |
| 1826 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y)); | 1814 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y)); |
| 1827 __ cmpq(r8, rcx); | 1815 __ cmpq(r8, rcx); |
| 1828 __ j(not_equal, exit); | 1816 __ j(not_equal, exit); |
| 1829 } | 1817 } |
| 1830 | 1818 |
| 1831 | 1819 |
| 1832 TEST(SmiXor) { | 1820 TEST(SmiXor) { |
| 1833 v8::internal::V8::Initialize(NULL); | 1821 i::V8::Initialize(NULL); |
| 1834 // Allocate an executable page of memory. | 1822 // Allocate an executable page of memory. |
| 1835 size_t actual_size; | 1823 size_t actual_size; |
| 1836 byte* buffer = | 1824 byte* buffer = |
| 1837 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1825 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1838 &actual_size, | 1826 &actual_size, |
| 1839 true)); | 1827 true)); |
| 1840 CHECK(buffer); | 1828 CHECK(buffer); |
| 1841 Isolate* isolate = CcTest::i_isolate(); | 1829 Isolate* isolate = CcTest::i_isolate(); |
| 1842 HandleScope handles(isolate); | 1830 HandleScope handles(isolate); |
| 1843 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1831 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 __ j(not_equal, exit); | 1879 __ j(not_equal, exit); |
| 1892 | 1880 |
| 1893 __ incq(rax); | 1881 __ incq(rax); |
| 1894 __ SmiNot(rcx, rcx); | 1882 __ SmiNot(rcx, rcx); |
| 1895 __ cmpq(rcx, r8); | 1883 __ cmpq(rcx, r8); |
| 1896 __ j(not_equal, exit); | 1884 __ j(not_equal, exit); |
| 1897 } | 1885 } |
| 1898 | 1886 |
| 1899 | 1887 |
| 1900 TEST(SmiNot) { | 1888 TEST(SmiNot) { |
| 1901 v8::internal::V8::Initialize(NULL); | 1889 i::V8::Initialize(NULL); |
| 1902 // Allocate an executable page of memory. | 1890 // Allocate an executable page of memory. |
| 1903 size_t actual_size; | 1891 size_t actual_size; |
| 1904 byte* buffer = | 1892 byte* buffer = |
| 1905 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1893 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1906 &actual_size, | 1894 &actual_size, |
| 1907 true)); | 1895 true)); |
| 1908 CHECK(buffer); | 1896 CHECK(buffer); |
| 1909 Isolate* isolate = CcTest::i_isolate(); | 1897 Isolate* isolate = CcTest::i_isolate(); |
| 1910 HandleScope handles(isolate); | 1898 HandleScope handles(isolate); |
| 1911 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1899 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 __ incq(rax); | 1976 __ incq(rax); |
| 1989 __ cmpq(rdx, r8); | 1977 __ cmpq(rdx, r8); |
| 1990 __ j(not_equal, exit); | 1978 __ j(not_equal, exit); |
| 1991 | 1979 |
| 1992 __ incq(rax); | 1980 __ incq(rax); |
| 1993 } | 1981 } |
| 1994 } | 1982 } |
| 1995 | 1983 |
| 1996 | 1984 |
| 1997 TEST(SmiShiftLeft) { | 1985 TEST(SmiShiftLeft) { |
| 1998 v8::internal::V8::Initialize(NULL); | 1986 i::V8::Initialize(NULL); |
| 1999 // Allocate an executable page of memory. | 1987 // Allocate an executable page of memory. |
| 2000 size_t actual_size; | 1988 size_t actual_size; |
| 2001 byte* buffer = | 1989 byte* buffer = |
| 2002 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, | 1990 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, |
| 2003 &actual_size, | 1991 &actual_size, |
| 2004 true)); | 1992 true)); |
| 2005 CHECK(buffer); | 1993 CHECK(buffer); |
| 2006 Isolate* isolate = CcTest::i_isolate(); | 1994 Isolate* isolate = CcTest::i_isolate(); |
| 2007 HandleScope handles(isolate); | 1995 HandleScope handles(isolate); |
| 2008 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1996 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 __ cmpq(rcx, r11); | 2083 __ cmpq(rcx, r11); |
| 2096 __ j(not_equal, exit); | 2084 __ j(not_equal, exit); |
| 2097 | 2085 |
| 2098 __ addq(rax, Immediate(3)); | 2086 __ addq(rax, Immediate(3)); |
| 2099 } | 2087 } |
| 2100 } | 2088 } |
| 2101 } | 2089 } |
| 2102 | 2090 |
| 2103 | 2091 |
| 2104 TEST(SmiShiftLogicalRight) { | 2092 TEST(SmiShiftLogicalRight) { |
| 2105 v8::internal::V8::Initialize(NULL); | 2093 i::V8::Initialize(NULL); |
| 2106 // Allocate an executable page of memory. | 2094 // Allocate an executable page of memory. |
| 2107 size_t actual_size; | 2095 size_t actual_size; |
| 2108 byte* buffer = | 2096 byte* buffer = |
| 2109 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, | 2097 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, |
| 2110 &actual_size, | 2098 &actual_size, |
| 2111 true)); | 2099 true)); |
| 2112 CHECK(buffer); | 2100 CHECK(buffer); |
| 2113 Isolate* isolate = CcTest::i_isolate(); | 2101 Isolate* isolate = CcTest::i_isolate(); |
| 2114 HandleScope handles(isolate); | 2102 HandleScope handles(isolate); |
| 2115 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2103 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2165 | 2153 |
| 2166 __ cmpq(rdx, r8); | 2154 __ cmpq(rdx, r8); |
| 2167 __ j(not_equal, exit); | 2155 __ j(not_equal, exit); |
| 2168 | 2156 |
| 2169 __ incq(rax); | 2157 __ incq(rax); |
| 2170 } | 2158 } |
| 2171 } | 2159 } |
| 2172 | 2160 |
| 2173 | 2161 |
| 2174 TEST(SmiShiftArithmeticRight) { | 2162 TEST(SmiShiftArithmeticRight) { |
| 2175 v8::internal::V8::Initialize(NULL); | 2163 i::V8::Initialize(NULL); |
| 2176 // Allocate an executable page of memory. | 2164 // Allocate an executable page of memory. |
| 2177 size_t actual_size; | 2165 size_t actual_size; |
| 2178 byte* buffer = | 2166 byte* buffer = |
| 2179 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 2167 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 2180 &actual_size, | 2168 &actual_size, |
| 2181 true)); | 2169 true)); |
| 2182 CHECK(buffer); | 2170 CHECK(buffer); |
| 2183 Isolate* isolate = CcTest::i_isolate(); | 2171 Isolate* isolate = CcTest::i_isolate(); |
| 2184 HandleScope handles(isolate); | 2172 HandleScope handles(isolate); |
| 2185 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2173 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2230 __ incq(rax); | 2218 __ incq(rax); |
| 2231 __ PositiveSmiTimesPowerOfTwoToInteger64(rcx, rcx, power); | 2219 __ PositiveSmiTimesPowerOfTwoToInteger64(rcx, rcx, power); |
| 2232 __ cmpq(rdx, r8); | 2220 __ cmpq(rdx, r8); |
| 2233 __ j(not_equal, exit); | 2221 __ j(not_equal, exit); |
| 2234 __ incq(rax); | 2222 __ incq(rax); |
| 2235 } | 2223 } |
| 2236 } | 2224 } |
| 2237 | 2225 |
| 2238 | 2226 |
| 2239 TEST(PositiveSmiTimesPowerOfTwoToInteger64) { | 2227 TEST(PositiveSmiTimesPowerOfTwoToInteger64) { |
| 2240 v8::internal::V8::Initialize(NULL); | 2228 i::V8::Initialize(NULL); |
| 2241 // Allocate an executable page of memory. | 2229 // Allocate an executable page of memory. |
| 2242 size_t actual_size; | 2230 size_t actual_size; |
| 2243 byte* buffer = | 2231 byte* buffer = |
| 2244 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, | 2232 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, |
| 2245 &actual_size, | 2233 &actual_size, |
| 2246 true)); | 2234 true)); |
| 2247 CHECK(buffer); | 2235 CHECK(buffer); |
| 2248 Isolate* isolate = CcTest::i_isolate(); | 2236 Isolate* isolate = CcTest::i_isolate(); |
| 2249 HandleScope handles(isolate); | 2237 HandleScope handles(isolate); |
| 2250 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2238 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2271 | 2259 |
| 2272 CodeDesc desc; | 2260 CodeDesc desc; |
| 2273 masm->GetCode(&desc); | 2261 masm->GetCode(&desc); |
| 2274 // Call the function from C++. | 2262 // Call the function from C++. |
| 2275 int result = FUNCTION_CAST<F0>(buffer)(); | 2263 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2276 CHECK_EQ(0, result); | 2264 CHECK_EQ(0, result); |
| 2277 } | 2265 } |
| 2278 | 2266 |
| 2279 | 2267 |
| 2280 TEST(OperandOffset) { | 2268 TEST(OperandOffset) { |
| 2281 v8::internal::V8::Initialize(NULL); | 2269 i::V8::Initialize(NULL); |
| 2282 int data[256]; | 2270 int data[256]; |
| 2283 for (int i = 0; i < 256; i++) { data[i] = i * 0x01010101; } | 2271 for (int i = 0; i < 256; i++) { data[i] = i * 0x01010101; } |
| 2284 | 2272 |
| 2285 // Allocate an executable page of memory. | 2273 // Allocate an executable page of memory. |
| 2286 size_t actual_size; | 2274 size_t actual_size; |
| 2287 byte* buffer = | 2275 byte* buffer = |
| 2288 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 2276 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 2289 &actual_size, | 2277 &actual_size, |
| 2290 true)); | 2278 true)); |
| 2291 CHECK(buffer); | 2279 CHECK(buffer); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 CodeDesc desc; | 2617 CodeDesc desc; |
| 2630 masm->GetCode(&desc); | 2618 masm->GetCode(&desc); |
| 2631 // Call the function from C++. | 2619 // Call the function from C++. |
| 2632 int result = FUNCTION_CAST<F0>(buffer)(); | 2620 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2633 CHECK_EQ(0, result); | 2621 CHECK_EQ(0, result); |
| 2634 } | 2622 } |
| 2635 | 2623 |
| 2636 | 2624 |
| 2637 | 2625 |
| 2638 #undef __ | 2626 #undef __ |
| OLD | NEW |