Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: test/cctest/test-macro-assembler-x64.cc

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

Powered by Google App Engine
This is Rietveld 408576698