| 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::equal; |
| 66 using v8::internal::r11; | 66 using i::not_zero; |
| 67 using v8::internal::r13; | 67 using i::positive; |
| 68 using v8::internal::r14; | 68 using i::r11; |
| 69 using v8::internal::r15; | 69 using i::r13; |
| 70 using v8::internal::r8; | 70 using i::r14; |
| 71 using v8::internal::r9; | 71 using i::r15; |
| 72 using v8::internal::rax; | 72 using i::r8; |
| 73 using v8::internal::rbp; | 73 using i::r9; |
| 74 using v8::internal::rbx; | 74 using i::rax; |
| 75 using v8::internal::rcx; | 75 using i::rbp; |
| 76 using v8::internal::rdi; | 76 using i::rbx; |
| 77 using v8::internal::rdx; | 77 using i::rcx; |
| 78 using v8::internal::rsi; | 78 using i::rdi; |
| 79 using v8::internal::rsp; | 79 using i::rdx; |
| 80 using v8::internal::times_pointer_size; | 80 using i::rsi; |
| 81 using i::rsp; |
| 82 using i::times_pointer_size; |
| 81 | 83 |
| 82 // Test the x64 assembler by compiling some simple functions into | 84 // Test the x64 assembler by compiling some simple functions into |
| 83 // a buffer and executing them. These tests do not initialize the | 85 // a buffer and executing them. These tests do not initialize the |
| 84 // V8 library, create a context, or use any V8 objects. | 86 // V8 library, create a context, or use any V8 objects. |
| 85 // The AMD64 calling convention is used, with the first five arguments | 87 // 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 | 88 // in RSI, RDI, RDX, RCX, R8, and R9, and floating point arguments in |
| 87 // the XMM registers. The return value is in RAX. | 89 // the XMM registers. The return value is in RAX. |
| 88 // This calling convention is used on Linux, with GCC, and on Mac OS, | 90 // 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. | 91 // with GCC. A different convention is used on 64-bit windows. |
| 90 | 92 |
| 91 typedef int (*F0)(); | 93 typedef int (*F0)(); |
| 92 | 94 |
| 93 #define __ masm-> | 95 #define __ masm-> |
| 94 | 96 |
| 95 | 97 |
| 96 static void EntryCode(MacroAssembler* masm) { | 98 static void EntryCode(MacroAssembler* masm) { |
| 97 // Smi constant register is callee save. | 99 // Smi constant register is callee save. |
| 98 __ push(v8::internal::kSmiConstantRegister); | 100 __ push(i::kSmiConstantRegister); |
| 99 __ push(v8::internal::kRootRegister); | 101 __ push(i::kRootRegister); |
| 100 __ InitializeSmiConstantRegister(); | 102 __ InitializeSmiConstantRegister(); |
| 101 __ InitializeRootRegister(); | 103 __ InitializeRootRegister(); |
| 102 } | 104 } |
| 103 | 105 |
| 104 | 106 |
| 105 static void ExitCode(MacroAssembler* masm) { | 107 static void ExitCode(MacroAssembler* masm) { |
| 106 // Return -1 if kSmiConstantRegister was clobbered during the test. | 108 // Return -1 if kSmiConstantRegister was clobbered during the test. |
| 107 __ Move(rdx, Smi::FromInt(1)); | 109 __ Move(rdx, Smi::FromInt(1)); |
| 108 __ cmpq(rdx, v8::internal::kSmiConstantRegister); | 110 __ cmpq(rdx, i::kSmiConstantRegister); |
| 109 __ movq(rdx, Immediate(-1)); | 111 __ movq(rdx, Immediate(-1)); |
| 110 __ cmovq(not_equal, rax, rdx); | 112 __ cmovq(not_equal, rax, rdx); |
| 111 __ pop(v8::internal::kRootRegister); | 113 __ pop(i::kRootRegister); |
| 112 __ pop(v8::internal::kSmiConstantRegister); | 114 __ pop(i::kSmiConstantRegister); |
| 113 } | 115 } |
| 114 | 116 |
| 115 | 117 |
| 116 TEST(Smi) { | 118 TEST(Smi) { |
| 117 // Check that C++ Smi operations work as expected. | 119 // Check that C++ Smi operations work as expected. |
| 118 int64_t test_numbers[] = { | 120 int64_t test_numbers[] = { |
| 119 0, 1, -1, 127, 128, -128, -129, 255, 256, -256, -257, | 121 0, 1, -1, 127, 128, -128, -129, 255, 256, -256, -257, |
| 120 Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1, | 122 Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1, |
| 121 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1 | 123 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1 |
| 122 }; | 124 }; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 143 __ movl(rax, Immediate(id)); | 145 __ movl(rax, Immediate(id)); |
| 144 __ Move(rcx, value); | 146 __ Move(rcx, value); |
| 145 __ Set(rdx, reinterpret_cast<intptr_t>(value)); | 147 __ Set(rdx, reinterpret_cast<intptr_t>(value)); |
| 146 __ cmpq(rcx, rdx); | 148 __ cmpq(rcx, rdx); |
| 147 __ j(not_equal, exit); | 149 __ j(not_equal, exit); |
| 148 } | 150 } |
| 149 | 151 |
| 150 | 152 |
| 151 // Test that we can move a Smi value literally into a register. | 153 // Test that we can move a Smi value literally into a register. |
| 152 TEST(SmiMove) { | 154 TEST(SmiMove) { |
| 153 v8::internal::V8::Initialize(NULL); | 155 i::V8::Initialize(NULL); |
| 154 // Allocate an executable page of memory. | 156 // Allocate an executable page of memory. |
| 155 size_t actual_size; | 157 size_t actual_size; |
| 156 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 158 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 157 &actual_size, | 159 &actual_size, |
| 158 true)); | 160 true)); |
| 159 CHECK(buffer); | 161 CHECK(buffer); |
| 160 Isolate* isolate = CcTest::i_isolate(); | 162 Isolate* isolate = CcTest::i_isolate(); |
| 161 HandleScope handles(isolate); | 163 HandleScope handles(isolate); |
| 162 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 164 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 163 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. | 165 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); | 233 __ j(not_equal, exit); |
| 232 __ incq(rax); | 234 __ incq(rax); |
| 233 __ cmpq(rcx, r8); | 235 __ cmpq(rcx, r8); |
| 234 __ j(not_equal, exit); | 236 __ j(not_equal, exit); |
| 235 } | 237 } |
| 236 } | 238 } |
| 237 | 239 |
| 238 | 240 |
| 239 // Test that we can compare smis for equality (and more). | 241 // Test that we can compare smis for equality (and more). |
| 240 TEST(SmiCompare) { | 242 TEST(SmiCompare) { |
| 241 v8::internal::V8::Initialize(NULL); | 243 i::V8::Initialize(NULL); |
| 242 // Allocate an executable page of memory. | 244 // Allocate an executable page of memory. |
| 243 size_t actual_size; | 245 size_t actual_size; |
| 244 byte* buffer = | 246 byte* buffer = |
| 245 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 247 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 246 &actual_size, | 248 &actual_size, |
| 247 true)); | 249 true)); |
| 248 CHECK(buffer); | 250 CHECK(buffer); |
| 249 Isolate* isolate = CcTest::i_isolate(); | 251 Isolate* isolate = CcTest::i_isolate(); |
| 250 HandleScope handles(isolate); | 252 HandleScope handles(isolate); |
| 251 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 253 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; | 285 CodeDesc desc; |
| 284 masm->GetCode(&desc); | 286 masm->GetCode(&desc); |
| 285 // Call the function from C++. | 287 // Call the function from C++. |
| 286 int result = FUNCTION_CAST<F0>(buffer)(); | 288 int result = FUNCTION_CAST<F0>(buffer)(); |
| 287 CHECK_EQ(0, result); | 289 CHECK_EQ(0, result); |
| 288 } | 290 } |
| 289 | 291 |
| 290 | 292 |
| 291 | 293 |
| 292 TEST(Integer32ToSmi) { | 294 TEST(Integer32ToSmi) { |
| 293 v8::internal::V8::Initialize(NULL); | 295 i::V8::Initialize(NULL); |
| 294 // Allocate an executable page of memory. | 296 // Allocate an executable page of memory. |
| 295 size_t actual_size; | 297 size_t actual_size; |
| 296 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 298 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 297 &actual_size, | 299 &actual_size, |
| 298 true)); | 300 true)); |
| 299 CHECK(buffer); | 301 CHECK(buffer); |
| 300 Isolate* isolate = CcTest::i_isolate(); | 302 Isolate* isolate = CcTest::i_isolate(); |
| 301 HandleScope handles(isolate); | 303 HandleScope handles(isolate); |
| 302 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 304 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 303 | 305 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 __ j(not_equal, exit); | 414 __ j(not_equal, exit); |
| 413 | 415 |
| 414 __ incq(rax); | 416 __ incq(rax); |
| 415 __ Integer64PlusConstantToSmi(rcx, rcx, y); | 417 __ Integer64PlusConstantToSmi(rcx, rcx, y); |
| 416 __ cmpq(rcx, r8); | 418 __ cmpq(rcx, r8); |
| 417 __ j(not_equal, exit); | 419 __ j(not_equal, exit); |
| 418 } | 420 } |
| 419 | 421 |
| 420 | 422 |
| 421 TEST(Integer64PlusConstantToSmi) { | 423 TEST(Integer64PlusConstantToSmi) { |
| 422 v8::internal::V8::Initialize(NULL); | 424 i::V8::Initialize(NULL); |
| 423 // Allocate an executable page of memory. | 425 // Allocate an executable page of memory. |
| 424 size_t actual_size; | 426 size_t actual_size; |
| 425 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 427 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 426 &actual_size, | 428 &actual_size, |
| 427 true)); | 429 true)); |
| 428 CHECK(buffer); | 430 CHECK(buffer); |
| 429 Isolate* isolate = CcTest::i_isolate(); | 431 Isolate* isolate = CcTest::i_isolate(); |
| 430 HandleScope handles(isolate); | 432 HandleScope handles(isolate); |
| 431 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 433 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 432 | 434 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 457 | 459 |
| 458 CodeDesc desc; | 460 CodeDesc desc; |
| 459 masm->GetCode(&desc); | 461 masm->GetCode(&desc); |
| 460 // Call the function from C++. | 462 // Call the function from C++. |
| 461 int result = FUNCTION_CAST<F0>(buffer)(); | 463 int result = FUNCTION_CAST<F0>(buffer)(); |
| 462 CHECK_EQ(0, result); | 464 CHECK_EQ(0, result); |
| 463 } | 465 } |
| 464 | 466 |
| 465 | 467 |
| 466 TEST(SmiCheck) { | 468 TEST(SmiCheck) { |
| 467 v8::internal::V8::Initialize(NULL); | 469 i::V8::Initialize(NULL); |
| 468 // Allocate an executable page of memory. | 470 // Allocate an executable page of memory. |
| 469 size_t actual_size; | 471 size_t actual_size; |
| 470 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 472 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 471 &actual_size, | 473 &actual_size, |
| 472 true)); | 474 true)); |
| 473 CHECK(buffer); | 475 CHECK(buffer); |
| 474 Isolate* isolate = CcTest::i_isolate(); | 476 Isolate* isolate = CcTest::i_isolate(); |
| 475 HandleScope handles(isolate); | 477 HandleScope handles(isolate); |
| 476 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 478 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 477 | 479 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 __ jmp(exit); | 707 __ jmp(exit); |
| 706 __ bind(&smi_ok2); | 708 __ bind(&smi_ok2); |
| 707 __ incq(rax); | 709 __ incq(rax); |
| 708 __ cmpq(rcx, r8); | 710 __ cmpq(rcx, r8); |
| 709 __ j(not_equal, exit); | 711 __ j(not_equal, exit); |
| 710 } | 712 } |
| 711 } | 713 } |
| 712 | 714 |
| 713 | 715 |
| 714 TEST(SmiNeg) { | 716 TEST(SmiNeg) { |
| 715 v8::internal::V8::Initialize(NULL); | 717 i::V8::Initialize(NULL); |
| 716 // Allocate an executable page of memory. | 718 // Allocate an executable page of memory. |
| 717 size_t actual_size; | 719 size_t actual_size; |
| 718 byte* buffer = | 720 byte* buffer = |
| 719 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 721 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 720 &actual_size, | 722 &actual_size, |
| 721 true)); | 723 true)); |
| 722 CHECK(buffer); | 724 CHECK(buffer); |
| 723 Isolate* isolate = CcTest::i_isolate(); | 725 Isolate* isolate = CcTest::i_isolate(); |
| 724 HandleScope handles(isolate); | 726 HandleScope handles(isolate); |
| 725 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 727 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 __ Integer32ToSmi(rdx, rdx); | 764 __ Integer32ToSmi(rdx, rdx); |
| 763 __ movl(r8, Immediate(first + second)); | 765 __ movl(r8, Immediate(first + second)); |
| 764 __ Integer32ToSmi(r8, r8); | 766 __ Integer32ToSmi(r8, r8); |
| 765 | 767 |
| 766 __ movl(rax, Immediate(id)); // Test number. | 768 __ movl(rax, Immediate(id)); // Test number. |
| 767 __ SmiAdd(r9, rcx, rdx, exit); | 769 __ SmiAdd(r9, rcx, rdx, exit); |
| 768 __ cmpq(r9, r8); | 770 __ cmpq(r9, r8); |
| 769 __ j(not_equal, exit); | 771 __ j(not_equal, exit); |
| 770 | 772 |
| 771 __ incq(rax); | 773 __ incq(rax); |
| 772 __ SmiAdd(rcx, rcx, rdx, exit); \ | 774 __ SmiAdd(rcx, rcx, rdx, exit); |
| 773 __ cmpq(rcx, r8); | 775 __ cmpq(rcx, r8); |
| 774 __ j(not_equal, exit); | 776 __ j(not_equal, exit); |
| 775 | 777 |
| 776 __ movl(rcx, Immediate(first)); | 778 __ movl(rcx, Immediate(first)); |
| 777 __ Integer32ToSmi(rcx, rcx); | 779 __ Integer32ToSmi(rcx, rcx); |
| 778 | 780 |
| 779 __ incq(rax); | 781 __ incq(rax); |
| 780 __ SmiAddConstant(r9, rcx, Smi::FromInt(second)); | 782 __ SmiAddConstant(r9, rcx, Smi::FromInt(second)); |
| 781 __ cmpq(r9, r8); | 783 __ cmpq(r9, r8); |
| 782 __ j(not_equal, exit); | 784 __ j(not_equal, exit); |
| 783 | 785 |
| 784 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second)); | 786 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second)); |
| 785 __ cmpq(rcx, r8); | 787 __ cmpq(rcx, r8); |
| 786 __ j(not_equal, exit); | 788 __ j(not_equal, exit); |
| 787 | 789 |
| 788 __ movl(rcx, Immediate(first)); | 790 __ movl(rcx, Immediate(first)); |
| 789 __ Integer32ToSmi(rcx, rcx); | 791 __ Integer32ToSmi(rcx, rcx); |
| 790 | 792 |
| 793 i::SmiOperationExecutionMode mode; |
| 794 mode.Add(i::PRESERVE_SOURCE_REGISTER); |
| 795 mode.Add(i::BAILOUT_ON_OVERFLOW); |
| 791 __ incq(rax); | 796 __ incq(rax); |
| 792 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), exit); | 797 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), mode, exit); |
| 793 __ cmpq(r9, r8); | 798 __ cmpq(r9, r8); |
| 794 __ j(not_equal, exit); | 799 __ j(not_equal, exit); |
| 795 | 800 |
| 796 __ incq(rax); | 801 __ incq(rax); |
| 797 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), exit); | 802 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), mode, exit); |
| 803 __ cmpq(rcx, r8); |
| 804 __ j(not_equal, exit); |
| 805 |
| 806 __ movl(rcx, Immediate(first)); |
| 807 __ Integer32ToSmi(rcx, rcx); |
| 808 |
| 809 mode.RemoveAll(); |
| 810 mode.Add(i::PRESERVE_SOURCE_REGISTER); |
| 811 mode.Add(i::BAILOUT_ON_NO_OVERFLOW); |
| 812 Label done; |
| 813 __ incq(rax); |
| 814 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), mode, &done); |
| 815 __ jmp(exit); |
| 816 __ bind(&done); |
| 798 __ cmpq(rcx, r8); | 817 __ cmpq(rcx, r8); |
| 799 __ j(not_equal, exit); | 818 __ j(not_equal, exit); |
| 800 } | 819 } |
| 801 | 820 |
| 802 | 821 |
| 803 static void SmiAddOverflowTest(MacroAssembler* masm, | 822 static void SmiAddOverflowTest(MacroAssembler* masm, |
| 804 Label* exit, | 823 Label* exit, |
| 805 int id, | 824 int id, |
| 806 int x) { | 825 int x) { |
| 807 // Adds a Smi to x so that the addition overflows. | 826 // Adds a Smi to x so that the addition overflows. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 827 Label overflow_ok; | 846 Label overflow_ok; |
| 828 __ incq(rax); | 847 __ incq(rax); |
| 829 __ SmiAdd(rcx, rcx, rdx, &overflow_ok); | 848 __ SmiAdd(rcx, rcx, rdx, &overflow_ok); |
| 830 __ jmp(exit); | 849 __ jmp(exit); |
| 831 __ bind(&overflow_ok); | 850 __ bind(&overflow_ok); |
| 832 __ incq(rax); | 851 __ incq(rax); |
| 833 __ cmpq(rcx, r11); | 852 __ cmpq(rcx, r11); |
| 834 __ j(not_equal, exit); | 853 __ j(not_equal, exit); |
| 835 } | 854 } |
| 836 | 855 |
| 856 i::SmiOperationExecutionMode mode; |
| 857 mode.Add(i::PRESERVE_SOURCE_REGISTER); |
| 858 mode.Add(i::BAILOUT_ON_OVERFLOW); |
| 837 __ movq(rcx, r11); | 859 __ movq(rcx, r11); |
| 838 { | 860 { |
| 839 Label overflow_ok; | 861 Label overflow_ok; |
| 840 __ incq(rax); | 862 __ incq(rax); |
| 841 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_min), &overflow_ok); | 863 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_min), mode, &overflow_ok); |
| 842 __ jmp(exit); | 864 __ jmp(exit); |
| 843 __ bind(&overflow_ok); | 865 __ bind(&overflow_ok); |
| 844 __ incq(rax); | 866 __ incq(rax); |
| 845 __ cmpq(rcx, r11); | 867 __ cmpq(rcx, r11); |
| 846 __ j(not_equal, exit); | 868 __ j(not_equal, exit); |
| 847 } | 869 } |
| 848 | 870 |
| 849 { | 871 { |
| 850 Label overflow_ok; | 872 Label overflow_ok; |
| 851 __ incq(rax); | 873 __ incq(rax); |
| 852 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_min), &overflow_ok); | 874 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_min), mode, &overflow_ok); |
| 853 __ jmp(exit); | 875 __ jmp(exit); |
| 854 __ bind(&overflow_ok); | 876 __ bind(&overflow_ok); |
| 855 __ incq(rax); | 877 __ incq(rax); |
| 856 __ cmpq(rcx, r11); | 878 __ cmpq(rcx, r11); |
| 857 __ j(not_equal, exit); | 879 __ j(not_equal, exit); |
| 858 } | 880 } |
| 859 | 881 |
| 860 __ Move(rdx, Smi::FromInt(y_max)); | 882 __ Move(rdx, Smi::FromInt(y_max)); |
| 861 | 883 |
| 862 { | 884 { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 878 __ bind(&overflow_ok); | 900 __ bind(&overflow_ok); |
| 879 __ incq(rax); | 901 __ incq(rax); |
| 880 __ cmpq(rcx, r11); | 902 __ cmpq(rcx, r11); |
| 881 __ j(not_equal, exit); | 903 __ j(not_equal, exit); |
| 882 } | 904 } |
| 883 | 905 |
| 884 __ movq(rcx, r11); | 906 __ movq(rcx, r11); |
| 885 { | 907 { |
| 886 Label overflow_ok; | 908 Label overflow_ok; |
| 887 __ incq(rax); | 909 __ incq(rax); |
| 888 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_max), &overflow_ok); | 910 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_max), mode, &overflow_ok); |
| 889 __ jmp(exit); | 911 __ jmp(exit); |
| 890 __ bind(&overflow_ok); | 912 __ bind(&overflow_ok); |
| 891 __ incq(rax); | 913 __ incq(rax); |
| 892 __ cmpq(rcx, r11); | 914 __ cmpq(rcx, r11); |
| 893 __ j(not_equal, exit); | 915 __ j(not_equal, exit); |
| 894 } | 916 } |
| 895 | 917 |
| 918 mode.RemoveAll(); |
| 919 mode.Add(i::BAILOUT_ON_OVERFLOW); |
| 896 { | 920 { |
| 897 Label overflow_ok; | 921 Label overflow_ok; |
| 898 __ incq(rax); | 922 __ incq(rax); |
| 899 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_max), &overflow_ok); | 923 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_max), mode, &overflow_ok); |
| 900 __ jmp(exit); | 924 __ jmp(exit); |
| 901 __ bind(&overflow_ok); | 925 __ bind(&overflow_ok); |
| 902 __ incq(rax); | 926 __ incq(rax); |
| 903 __ cmpq(rcx, r11); | 927 __ cmpq(rcx, r11); |
| 904 __ j(not_equal, exit); | 928 __ j(equal, exit); |
| 905 } | 929 } |
| 906 } | 930 } |
| 907 | 931 |
| 908 | 932 |
| 909 TEST(SmiAdd) { | 933 TEST(SmiAdd) { |
| 910 v8::internal::V8::Initialize(NULL); | 934 i::V8::Initialize(NULL); |
| 911 // Allocate an executable page of memory. | 935 // Allocate an executable page of memory. |
| 912 size_t actual_size; | 936 size_t actual_size; |
| 913 byte* buffer = | 937 byte* buffer = |
| 914 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 938 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 915 &actual_size, | 939 &actual_size, |
| 916 true)); | 940 true)); |
| 917 CHECK(buffer); | 941 CHECK(buffer); |
| 918 Isolate* isolate = CcTest::i_isolate(); | 942 Isolate* isolate = CcTest::i_isolate(); |
| 919 HandleScope handles(isolate); | 943 HandleScope handles(isolate); |
| 920 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 944 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. | 1003 __ incq(rax); // Test 2. |
| 980 __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); | 1004 __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); |
| 981 __ cmpq(r9, r8); | 1005 __ cmpq(r9, r8); |
| 982 __ j(not_equal, exit); | 1006 __ j(not_equal, exit); |
| 983 | 1007 |
| 984 __ incq(rax); // Test 3. | 1008 __ incq(rax); // Test 3. |
| 985 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); | 1009 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); |
| 986 __ cmpq(rcx, r8); | 1010 __ cmpq(rcx, r8); |
| 987 __ j(not_equal, exit); | 1011 __ j(not_equal, exit); |
| 988 | 1012 |
| 1013 i::SmiOperationExecutionMode mode; |
| 1014 mode.Add(i::PRESERVE_SOURCE_REGISTER); |
| 1015 mode.Add(i::BAILOUT_ON_OVERFLOW); |
| 1016 __ Move(rcx, Smi::FromInt(first)); |
| 1017 __ incq(rax); // Test 4. |
| 1018 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), mode, exit); |
| 1019 __ cmpq(rcx, r8); |
| 1020 __ j(not_equal, exit); |
| 1021 |
| 989 __ Move(rcx, Smi::FromInt(first)); | 1022 __ Move(rcx, Smi::FromInt(first)); |
| 990 | 1023 __ incq(rax); // Test 5. |
| 991 __ incq(rax); // Test 4. | 1024 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), mode, exit); |
| 992 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), exit); | |
| 993 __ cmpq(r9, r8); | 1025 __ cmpq(r9, r8); |
| 994 __ j(not_equal, exit); | 1026 __ j(not_equal, exit); |
| 995 | 1027 |
| 996 __ incq(rax); // Test 5. | 1028 mode.RemoveAll(); |
| 997 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), exit); | 1029 mode.Add(i::PRESERVE_SOURCE_REGISTER); |
| 1030 mode.Add(i::BAILOUT_ON_NO_OVERFLOW); |
| 1031 __ Move(rcx, Smi::FromInt(first)); |
| 1032 Label done; |
| 1033 __ incq(rax); // Test 6. |
| 1034 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second), mode, &done); |
| 1035 __ jmp(exit); |
| 1036 __ bind(&done); |
| 998 __ cmpq(rcx, r8); | 1037 __ cmpq(rcx, r8); |
| 999 __ j(not_equal, exit); | 1038 __ j(not_equal, exit); |
| 1000 } | 1039 } |
| 1001 | 1040 |
| 1002 | 1041 |
| 1003 static void SmiSubOverflowTest(MacroAssembler* masm, | 1042 static void SmiSubOverflowTest(MacroAssembler* masm, |
| 1004 Label* exit, | 1043 Label* exit, |
| 1005 int id, | 1044 int id, |
| 1006 int x) { | 1045 int x) { |
| 1007 // Subtracts a Smi from x so that the subtraction overflows. | 1046 // Subtracts a Smi from x so that the subtraction overflows. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1027 Label overflow_ok; | 1066 Label overflow_ok; |
| 1028 __ incq(rax); | 1067 __ incq(rax); |
| 1029 __ SmiSub(rcx, rcx, rdx, &overflow_ok); | 1068 __ SmiSub(rcx, rcx, rdx, &overflow_ok); |
| 1030 __ jmp(exit); | 1069 __ jmp(exit); |
| 1031 __ bind(&overflow_ok); | 1070 __ bind(&overflow_ok); |
| 1032 __ incq(rax); | 1071 __ incq(rax); |
| 1033 __ cmpq(rcx, r11); | 1072 __ cmpq(rcx, r11); |
| 1034 __ j(not_equal, exit); | 1073 __ j(not_equal, exit); |
| 1035 } | 1074 } |
| 1036 | 1075 |
| 1076 i::SmiOperationExecutionMode mode; |
| 1077 mode.Add(i::PRESERVE_SOURCE_REGISTER); |
| 1078 mode.Add(i::BAILOUT_ON_OVERFLOW); |
| 1079 |
| 1037 __ movq(rcx, r11); | 1080 __ movq(rcx, r11); |
| 1038 { | 1081 { |
| 1039 Label overflow_ok; | 1082 Label overflow_ok; |
| 1040 __ incq(rax); | 1083 __ incq(rax); |
| 1041 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), &overflow_ok); | 1084 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), mode, &overflow_ok); |
| 1042 __ jmp(exit); | 1085 __ jmp(exit); |
| 1043 __ bind(&overflow_ok); | 1086 __ bind(&overflow_ok); |
| 1044 __ incq(rax); | 1087 __ incq(rax); |
| 1045 __ cmpq(rcx, r11); | 1088 __ cmpq(rcx, r11); |
| 1046 __ j(not_equal, exit); | 1089 __ j(not_equal, exit); |
| 1047 } | 1090 } |
| 1048 | 1091 |
| 1049 { | 1092 { |
| 1050 Label overflow_ok; | 1093 Label overflow_ok; |
| 1051 __ incq(rax); | 1094 __ incq(rax); |
| 1052 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), &overflow_ok); | 1095 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), mode, &overflow_ok); |
| 1053 __ jmp(exit); | 1096 __ jmp(exit); |
| 1054 __ bind(&overflow_ok); | 1097 __ bind(&overflow_ok); |
| 1055 __ incq(rax); | 1098 __ incq(rax); |
| 1056 __ cmpq(rcx, r11); | 1099 __ cmpq(rcx, r11); |
| 1057 __ j(not_equal, exit); | 1100 __ j(not_equal, exit); |
| 1058 } | 1101 } |
| 1059 | 1102 |
| 1060 __ Move(rdx, Smi::FromInt(y_max)); | 1103 __ Move(rdx, Smi::FromInt(y_max)); |
| 1061 | 1104 |
| 1062 { | 1105 { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1078 __ bind(&overflow_ok); | 1121 __ bind(&overflow_ok); |
| 1079 __ incq(rax); | 1122 __ incq(rax); |
| 1080 __ cmpq(rcx, r11); | 1123 __ cmpq(rcx, r11); |
| 1081 __ j(not_equal, exit); | 1124 __ j(not_equal, exit); |
| 1082 } | 1125 } |
| 1083 | 1126 |
| 1084 __ movq(rcx, r11); | 1127 __ movq(rcx, r11); |
| 1085 { | 1128 { |
| 1086 Label overflow_ok; | 1129 Label overflow_ok; |
| 1087 __ incq(rax); | 1130 __ incq(rax); |
| 1088 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_max), &overflow_ok); | 1131 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), mode, &overflow_ok); |
| 1089 __ jmp(exit); | 1132 __ jmp(exit); |
| 1090 __ bind(&overflow_ok); | 1133 __ bind(&overflow_ok); |
| 1091 __ incq(rax); | 1134 __ incq(rax); |
| 1092 __ cmpq(rcx, r11); | 1135 __ cmpq(rcx, r11); |
| 1093 __ j(not_equal, exit); | 1136 __ j(not_equal, exit); |
| 1094 } | 1137 } |
| 1095 | 1138 |
| 1139 mode.RemoveAll(); |
| 1140 mode.Add(i::BAILOUT_ON_OVERFLOW); |
| 1141 __ movq(rcx, r11); |
| 1096 { | 1142 { |
| 1097 Label overflow_ok; | 1143 Label overflow_ok; |
| 1098 __ incq(rax); | 1144 __ incq(rax); |
| 1099 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), &overflow_ok); | 1145 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), mode, &overflow_ok); |
| 1100 __ jmp(exit); | 1146 __ jmp(exit); |
| 1101 __ bind(&overflow_ok); | 1147 __ bind(&overflow_ok); |
| 1102 __ incq(rax); | 1148 __ incq(rax); |
| 1103 __ cmpq(rcx, r11); | 1149 __ cmpq(rcx, r11); |
| 1104 __ j(not_equal, exit); | 1150 __ j(equal, exit); |
| 1105 } | 1151 } |
| 1106 } | 1152 } |
| 1107 | 1153 |
| 1108 | 1154 |
| 1109 TEST(SmiSub) { | 1155 TEST(SmiSub) { |
| 1110 v8::internal::V8::Initialize(NULL); | 1156 i::V8::Initialize(NULL); |
| 1111 // Allocate an executable page of memory. | 1157 // Allocate an executable page of memory. |
| 1112 size_t actual_size; | 1158 size_t actual_size; |
| 1113 byte* buffer = | 1159 byte* buffer = |
| 1114 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1160 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 1115 &actual_size, | 1161 &actual_size, |
| 1116 true)); | 1162 true)); |
| 1117 CHECK(buffer); | 1163 CHECK(buffer); |
| 1118 Isolate* isolate = CcTest::i_isolate(); | 1164 Isolate* isolate = CcTest::i_isolate(); |
| 1119 HandleScope handles(isolate); | 1165 HandleScope handles(isolate); |
| 1120 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1166 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); | 1238 __ bind(&overflow_ok2); |
| 1193 // 31-bit version doesn't preserve rcx on failure. | 1239 // 31-bit version doesn't preserve rcx on failure. |
| 1194 // __ incq(rax); | 1240 // __ incq(rax); |
| 1195 // __ cmpq(r11, rcx); | 1241 // __ cmpq(r11, rcx); |
| 1196 // __ j(not_equal, exit); | 1242 // __ j(not_equal, exit); |
| 1197 } | 1243 } |
| 1198 } | 1244 } |
| 1199 | 1245 |
| 1200 | 1246 |
| 1201 TEST(SmiMul) { | 1247 TEST(SmiMul) { |
| 1202 v8::internal::V8::Initialize(NULL); | 1248 i::V8::Initialize(NULL); |
| 1203 // Allocate an executable page of memory. | 1249 // Allocate an executable page of memory. |
| 1204 size_t actual_size; | 1250 size_t actual_size; |
| 1205 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1251 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1206 &actual_size, | 1252 &actual_size, |
| 1207 true)); | 1253 true)); |
| 1208 CHECK(buffer); | 1254 CHECK(buffer); |
| 1209 Isolate* isolate = CcTest::i_isolate(); | 1255 Isolate* isolate = CcTest::i_isolate(); |
| 1210 HandleScope handles(isolate); | 1256 HandleScope handles(isolate); |
| 1211 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1257 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 1212 | 1258 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 __ bind(&fail_ok2); | 1344 __ bind(&fail_ok2); |
| 1299 | 1345 |
| 1300 __ incq(r15); | 1346 __ incq(r15); |
| 1301 __ cmpq(rcx, r11); | 1347 __ cmpq(rcx, r11); |
| 1302 __ j(not_equal, exit); | 1348 __ j(not_equal, exit); |
| 1303 } | 1349 } |
| 1304 } | 1350 } |
| 1305 | 1351 |
| 1306 | 1352 |
| 1307 TEST(SmiDiv) { | 1353 TEST(SmiDiv) { |
| 1308 v8::internal::V8::Initialize(NULL); | 1354 i::V8::Initialize(NULL); |
| 1309 // Allocate an executable page of memory. | 1355 // Allocate an executable page of memory. |
| 1310 size_t actual_size; | 1356 size_t actual_size; |
| 1311 byte* buffer = | 1357 byte* buffer = |
| 1312 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1358 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 1313 &actual_size, | 1359 &actual_size, |
| 1314 true)); | 1360 true)); |
| 1315 CHECK(buffer); | 1361 CHECK(buffer); |
| 1316 Isolate* isolate = CcTest::i_isolate(); | 1362 Isolate* isolate = CcTest::i_isolate(); |
| 1317 HandleScope handles(isolate); | 1363 HandleScope handles(isolate); |
| 1318 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1364 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); | 1455 __ bind(&fail_ok2); |
| 1410 | 1456 |
| 1411 __ incq(r15); | 1457 __ incq(r15); |
| 1412 __ cmpq(rcx, r11); | 1458 __ cmpq(rcx, r11); |
| 1413 __ j(not_equal, exit); | 1459 __ j(not_equal, exit); |
| 1414 } | 1460 } |
| 1415 } | 1461 } |
| 1416 | 1462 |
| 1417 | 1463 |
| 1418 TEST(SmiMod) { | 1464 TEST(SmiMod) { |
| 1419 v8::internal::V8::Initialize(NULL); | 1465 i::V8::Initialize(NULL); |
| 1420 // Allocate an executable page of memory. | 1466 // Allocate an executable page of memory. |
| 1421 size_t actual_size; | 1467 size_t actual_size; |
| 1422 byte* buffer = | 1468 byte* buffer = |
| 1423 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 1469 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 1424 &actual_size, | 1470 &actual_size, |
| 1425 true)); | 1471 true)); |
| 1426 CHECK(buffer); | 1472 CHECK(buffer); |
| 1427 Isolate* isolate = CcTest::i_isolate(); | 1473 Isolate* isolate = CcTest::i_isolate(); |
| 1428 HandleScope handles(isolate); | 1474 HandleScope handles(isolate); |
| 1429 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1475 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)); | 1553 __ shl(rcx, Immediate(index.scale)); |
| 1508 __ Set(r8, static_cast<intptr_t>(-x) << i); | 1554 __ Set(r8, static_cast<intptr_t>(-x) << i); |
| 1509 __ cmpq(rcx, r8); | 1555 __ cmpq(rcx, r8); |
| 1510 __ j(not_equal, exit); | 1556 __ j(not_equal, exit); |
| 1511 __ incq(rax); | 1557 __ incq(rax); |
| 1512 } | 1558 } |
| 1513 } | 1559 } |
| 1514 | 1560 |
| 1515 | 1561 |
| 1516 TEST(SmiIndex) { | 1562 TEST(SmiIndex) { |
| 1517 v8::internal::V8::Initialize(NULL); | 1563 i::V8::Initialize(NULL); |
| 1518 // Allocate an executable page of memory. | 1564 // Allocate an executable page of memory. |
| 1519 size_t actual_size; | 1565 size_t actual_size; |
| 1520 byte* buffer = | 1566 byte* buffer = |
| 1521 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, | 1567 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, |
| 1522 &actual_size, | 1568 &actual_size, |
| 1523 true)); | 1569 true)); |
| 1524 CHECK(buffer); | 1570 CHECK(buffer); |
| 1525 Isolate* isolate = CcTest::i_isolate(); | 1571 Isolate* isolate = CcTest::i_isolate(); |
| 1526 HandleScope handles(isolate); | 1572 HandleScope handles(isolate); |
| 1527 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1573 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)); | 1623 __ Move(rdx, Smi::FromInt(y)); |
| 1578 __ xor_(rcx, Immediate(kSmiTagMask)); | 1624 __ xor_(rcx, Immediate(kSmiTagMask)); |
| 1579 __ xor_(rdx, Immediate(kSmiTagMask)); | 1625 __ xor_(rdx, Immediate(kSmiTagMask)); |
| 1580 __ SelectNonSmi(r9, rcx, rdx, &fail_ok); | 1626 __ SelectNonSmi(r9, rcx, rdx, &fail_ok); |
| 1581 __ jmp(exit); | 1627 __ jmp(exit); |
| 1582 __ bind(&fail_ok); | 1628 __ bind(&fail_ok); |
| 1583 } | 1629 } |
| 1584 | 1630 |
| 1585 | 1631 |
| 1586 TEST(SmiSelectNonSmi) { | 1632 TEST(SmiSelectNonSmi) { |
| 1587 v8::internal::V8::Initialize(NULL); | 1633 i::V8::Initialize(NULL); |
| 1588 // Allocate an executable page of memory. | 1634 // Allocate an executable page of memory. |
| 1589 size_t actual_size; | 1635 size_t actual_size; |
| 1590 byte* buffer = | 1636 byte* buffer = |
| 1591 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1637 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1592 &actual_size, | 1638 &actual_size, |
| 1593 true)); | 1639 true)); |
| 1594 CHECK(buffer); | 1640 CHECK(buffer); |
| 1595 Isolate* isolate = CcTest::i_isolate(); | 1641 Isolate* isolate = CcTest::i_isolate(); |
| 1596 HandleScope handles(isolate); | 1642 HandleScope handles(isolate); |
| 1597 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1643 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); | 1703 __ j(not_equal, exit); |
| 1658 | 1704 |
| 1659 __ incq(rax); | 1705 __ incq(rax); |
| 1660 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y)); | 1706 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y)); |
| 1661 __ cmpq(r8, rcx); | 1707 __ cmpq(r8, rcx); |
| 1662 __ j(not_equal, exit); | 1708 __ j(not_equal, exit); |
| 1663 } | 1709 } |
| 1664 | 1710 |
| 1665 | 1711 |
| 1666 TEST(SmiAnd) { | 1712 TEST(SmiAnd) { |
| 1667 v8::internal::V8::Initialize(NULL); | 1713 i::V8::Initialize(NULL); |
| 1668 // Allocate an executable page of memory. | 1714 // Allocate an executable page of memory. |
| 1669 size_t actual_size; | 1715 size_t actual_size; |
| 1670 byte* buffer = | 1716 byte* buffer = |
| 1671 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1717 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1672 &actual_size, | 1718 &actual_size, |
| 1673 true)); | 1719 true)); |
| 1674 CHECK(buffer); | 1720 CHECK(buffer); |
| 1675 Isolate* isolate = CcTest::i_isolate(); | 1721 Isolate* isolate = CcTest::i_isolate(); |
| 1676 HandleScope handles(isolate); | 1722 HandleScope handles(isolate); |
| 1677 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1723 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); | 1785 __ j(not_equal, exit); |
| 1740 | 1786 |
| 1741 __ incq(rax); | 1787 __ incq(rax); |
| 1742 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y)); | 1788 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y)); |
| 1743 __ cmpq(r8, rcx); | 1789 __ cmpq(r8, rcx); |
| 1744 __ j(not_equal, exit); | 1790 __ j(not_equal, exit); |
| 1745 } | 1791 } |
| 1746 | 1792 |
| 1747 | 1793 |
| 1748 TEST(SmiOr) { | 1794 TEST(SmiOr) { |
| 1749 v8::internal::V8::Initialize(NULL); | 1795 i::V8::Initialize(NULL); |
| 1750 // Allocate an executable page of memory. | 1796 // Allocate an executable page of memory. |
| 1751 size_t actual_size; | 1797 size_t actual_size; |
| 1752 byte* buffer = | 1798 byte* buffer = |
| 1753 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1799 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1754 &actual_size, | 1800 &actual_size, |
| 1755 true)); | 1801 true)); |
| 1756 CHECK(buffer); | 1802 CHECK(buffer); |
| 1757 Isolate* isolate = CcTest::i_isolate(); | 1803 Isolate* isolate = CcTest::i_isolate(); |
| 1758 HandleScope handles(isolate); | 1804 HandleScope handles(isolate); |
| 1759 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1805 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); | 1869 __ j(not_equal, exit); |
| 1824 | 1870 |
| 1825 __ incq(rax); | 1871 __ incq(rax); |
| 1826 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y)); | 1872 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y)); |
| 1827 __ cmpq(r8, rcx); | 1873 __ cmpq(r8, rcx); |
| 1828 __ j(not_equal, exit); | 1874 __ j(not_equal, exit); |
| 1829 } | 1875 } |
| 1830 | 1876 |
| 1831 | 1877 |
| 1832 TEST(SmiXor) { | 1878 TEST(SmiXor) { |
| 1833 v8::internal::V8::Initialize(NULL); | 1879 i::V8::Initialize(NULL); |
| 1834 // Allocate an executable page of memory. | 1880 // Allocate an executable page of memory. |
| 1835 size_t actual_size; | 1881 size_t actual_size; |
| 1836 byte* buffer = | 1882 byte* buffer = |
| 1837 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1883 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1838 &actual_size, | 1884 &actual_size, |
| 1839 true)); | 1885 true)); |
| 1840 CHECK(buffer); | 1886 CHECK(buffer); |
| 1841 Isolate* isolate = CcTest::i_isolate(); | 1887 Isolate* isolate = CcTest::i_isolate(); |
| 1842 HandleScope handles(isolate); | 1888 HandleScope handles(isolate); |
| 1843 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1889 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); | 1937 __ j(not_equal, exit); |
| 1892 | 1938 |
| 1893 __ incq(rax); | 1939 __ incq(rax); |
| 1894 __ SmiNot(rcx, rcx); | 1940 __ SmiNot(rcx, rcx); |
| 1895 __ cmpq(rcx, r8); | 1941 __ cmpq(rcx, r8); |
| 1896 __ j(not_equal, exit); | 1942 __ j(not_equal, exit); |
| 1897 } | 1943 } |
| 1898 | 1944 |
| 1899 | 1945 |
| 1900 TEST(SmiNot) { | 1946 TEST(SmiNot) { |
| 1901 v8::internal::V8::Initialize(NULL); | 1947 i::V8::Initialize(NULL); |
| 1902 // Allocate an executable page of memory. | 1948 // Allocate an executable page of memory. |
| 1903 size_t actual_size; | 1949 size_t actual_size; |
| 1904 byte* buffer = | 1950 byte* buffer = |
| 1905 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 1951 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 1906 &actual_size, | 1952 &actual_size, |
| 1907 true)); | 1953 true)); |
| 1908 CHECK(buffer); | 1954 CHECK(buffer); |
| 1909 Isolate* isolate = CcTest::i_isolate(); | 1955 Isolate* isolate = CcTest::i_isolate(); |
| 1910 HandleScope handles(isolate); | 1956 HandleScope handles(isolate); |
| 1911 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 1957 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); | 2034 __ incq(rax); |
| 1989 __ cmpq(rdx, r8); | 2035 __ cmpq(rdx, r8); |
| 1990 __ j(not_equal, exit); | 2036 __ j(not_equal, exit); |
| 1991 | 2037 |
| 1992 __ incq(rax); | 2038 __ incq(rax); |
| 1993 } | 2039 } |
| 1994 } | 2040 } |
| 1995 | 2041 |
| 1996 | 2042 |
| 1997 TEST(SmiShiftLeft) { | 2043 TEST(SmiShiftLeft) { |
| 1998 v8::internal::V8::Initialize(NULL); | 2044 i::V8::Initialize(NULL); |
| 1999 // Allocate an executable page of memory. | 2045 // Allocate an executable page of memory. |
| 2000 size_t actual_size; | 2046 size_t actual_size; |
| 2001 byte* buffer = | 2047 byte* buffer = |
| 2002 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, | 2048 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, |
| 2003 &actual_size, | 2049 &actual_size, |
| 2004 true)); | 2050 true)); |
| 2005 CHECK(buffer); | 2051 CHECK(buffer); |
| 2006 Isolate* isolate = CcTest::i_isolate(); | 2052 Isolate* isolate = CcTest::i_isolate(); |
| 2007 HandleScope handles(isolate); | 2053 HandleScope handles(isolate); |
| 2008 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2054 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); | 2141 __ cmpq(rcx, r11); |
| 2096 __ j(not_equal, exit); | 2142 __ j(not_equal, exit); |
| 2097 | 2143 |
| 2098 __ addq(rax, Immediate(3)); | 2144 __ addq(rax, Immediate(3)); |
| 2099 } | 2145 } |
| 2100 } | 2146 } |
| 2101 } | 2147 } |
| 2102 | 2148 |
| 2103 | 2149 |
| 2104 TEST(SmiShiftLogicalRight) { | 2150 TEST(SmiShiftLogicalRight) { |
| 2105 v8::internal::V8::Initialize(NULL); | 2151 i::V8::Initialize(NULL); |
| 2106 // Allocate an executable page of memory. | 2152 // Allocate an executable page of memory. |
| 2107 size_t actual_size; | 2153 size_t actual_size; |
| 2108 byte* buffer = | 2154 byte* buffer = |
| 2109 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, | 2155 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, |
| 2110 &actual_size, | 2156 &actual_size, |
| 2111 true)); | 2157 true)); |
| 2112 CHECK(buffer); | 2158 CHECK(buffer); |
| 2113 Isolate* isolate = CcTest::i_isolate(); | 2159 Isolate* isolate = CcTest::i_isolate(); |
| 2114 HandleScope handles(isolate); | 2160 HandleScope handles(isolate); |
| 2115 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2161 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2165 | 2211 |
| 2166 __ cmpq(rdx, r8); | 2212 __ cmpq(rdx, r8); |
| 2167 __ j(not_equal, exit); | 2213 __ j(not_equal, exit); |
| 2168 | 2214 |
| 2169 __ incq(rax); | 2215 __ incq(rax); |
| 2170 } | 2216 } |
| 2171 } | 2217 } |
| 2172 | 2218 |
| 2173 | 2219 |
| 2174 TEST(SmiShiftArithmeticRight) { | 2220 TEST(SmiShiftArithmeticRight) { |
| 2175 v8::internal::V8::Initialize(NULL); | 2221 i::V8::Initialize(NULL); |
| 2176 // Allocate an executable page of memory. | 2222 // Allocate an executable page of memory. |
| 2177 size_t actual_size; | 2223 size_t actual_size; |
| 2178 byte* buffer = | 2224 byte* buffer = |
| 2179 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 2225 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 2180 &actual_size, | 2226 &actual_size, |
| 2181 true)); | 2227 true)); |
| 2182 CHECK(buffer); | 2228 CHECK(buffer); |
| 2183 Isolate* isolate = CcTest::i_isolate(); | 2229 Isolate* isolate = CcTest::i_isolate(); |
| 2184 HandleScope handles(isolate); | 2230 HandleScope handles(isolate); |
| 2185 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2231 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); | 2276 __ incq(rax); |
| 2231 __ PositiveSmiTimesPowerOfTwoToInteger64(rcx, rcx, power); | 2277 __ PositiveSmiTimesPowerOfTwoToInteger64(rcx, rcx, power); |
| 2232 __ cmpq(rdx, r8); | 2278 __ cmpq(rdx, r8); |
| 2233 __ j(not_equal, exit); | 2279 __ j(not_equal, exit); |
| 2234 __ incq(rax); | 2280 __ incq(rax); |
| 2235 } | 2281 } |
| 2236 } | 2282 } |
| 2237 | 2283 |
| 2238 | 2284 |
| 2239 TEST(PositiveSmiTimesPowerOfTwoToInteger64) { | 2285 TEST(PositiveSmiTimesPowerOfTwoToInteger64) { |
| 2240 v8::internal::V8::Initialize(NULL); | 2286 i::V8::Initialize(NULL); |
| 2241 // Allocate an executable page of memory. | 2287 // Allocate an executable page of memory. |
| 2242 size_t actual_size; | 2288 size_t actual_size; |
| 2243 byte* buffer = | 2289 byte* buffer = |
| 2244 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, | 2290 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, |
| 2245 &actual_size, | 2291 &actual_size, |
| 2246 true)); | 2292 true)); |
| 2247 CHECK(buffer); | 2293 CHECK(buffer); |
| 2248 Isolate* isolate = CcTest::i_isolate(); | 2294 Isolate* isolate = CcTest::i_isolate(); |
| 2249 HandleScope handles(isolate); | 2295 HandleScope handles(isolate); |
| 2250 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2296 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2271 | 2317 |
| 2272 CodeDesc desc; | 2318 CodeDesc desc; |
| 2273 masm->GetCode(&desc); | 2319 masm->GetCode(&desc); |
| 2274 // Call the function from C++. | 2320 // Call the function from C++. |
| 2275 int result = FUNCTION_CAST<F0>(buffer)(); | 2321 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2276 CHECK_EQ(0, result); | 2322 CHECK_EQ(0, result); |
| 2277 } | 2323 } |
| 2278 | 2324 |
| 2279 | 2325 |
| 2280 TEST(OperandOffset) { | 2326 TEST(OperandOffset) { |
| 2281 v8::internal::V8::Initialize(NULL); | 2327 i::V8::Initialize(NULL); |
| 2282 int data[256]; | 2328 int data[256]; |
| 2283 for (int i = 0; i < 256; i++) { data[i] = i * 0x01010101; } | 2329 for (int i = 0; i < 256; i++) { data[i] = i * 0x01010101; } |
| 2284 | 2330 |
| 2285 // Allocate an executable page of memory. | 2331 // Allocate an executable page of memory. |
| 2286 size_t actual_size; | 2332 size_t actual_size; |
| 2287 byte* buffer = | 2333 byte* buffer = |
| 2288 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, | 2334 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, |
| 2289 &actual_size, | 2335 &actual_size, |
| 2290 true)); | 2336 true)); |
| 2291 CHECK(buffer); | 2337 CHECK(buffer); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 CodeDesc desc; | 2675 CodeDesc desc; |
| 2630 masm->GetCode(&desc); | 2676 masm->GetCode(&desc); |
| 2631 // Call the function from C++. | 2677 // Call the function from C++. |
| 2632 int result = FUNCTION_CAST<F0>(buffer)(); | 2678 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2633 CHECK_EQ(0, result); | 2679 CHECK_EQ(0, result); |
| 2634 } | 2680 } |
| 2635 | 2681 |
| 2636 | 2682 |
| 2637 | 2683 |
| 2638 #undef __ | 2684 #undef __ |
| OLD | NEW |