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

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

Issue 71163006: Merge bleeding_edge r17376:17693. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Fix all.gyp 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 | « test/cctest/test-macro-assembler-ia32.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | 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 i::rsi;
83 using i::rsp;
84 using i::times_pointer_size;
82 85
83 // Test the x64 assembler by compiling some simple functions into 86 // Test the x64 assembler by compiling some simple functions into
84 // a buffer and executing them. These tests do not initialize the 87 // a buffer and executing them. These tests do not initialize the
85 // V8 library, create a context, or use any V8 objects. 88 // V8 library, create a context, or use any V8 objects.
86 // The AMD64 calling convention is used, with the first five arguments 89 // The AMD64 calling convention is used, with the first five arguments
87 // 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
88 // the XMM registers. The return value is in RAX. 91 // the XMM registers. The return value is in RAX.
89 // 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,
90 // with GCC. A different convention is used on 64-bit windows. 93 // with GCC. A different convention is used on 64-bit windows.
91 94
92 typedef int (*F0)(); 95 typedef int (*F0)();
93 96
94 #define __ masm-> 97 #define __ masm->
95 98
96 99
97 static void EntryCode(MacroAssembler* masm) { 100 static void EntryCode(MacroAssembler* masm) {
98 // Smi constant register is callee save. 101 // Smi constant register is callee save.
99 __ push(v8::internal::kSmiConstantRegister); 102 __ push(i::kSmiConstantRegister);
100 __ push(v8::internal::kRootRegister); 103 __ push(i::kRootRegister);
101 __ InitializeSmiConstantRegister(); 104 __ InitializeSmiConstantRegister();
102 __ InitializeRootRegister(); 105 __ InitializeRootRegister();
103 } 106 }
104 107
105 108
106 static void ExitCode(MacroAssembler* masm) { 109 static void ExitCode(MacroAssembler* masm) {
107 // Return -1 if kSmiConstantRegister was clobbered during the test. 110 // Return -1 if kSmiConstantRegister was clobbered during the test.
108 __ Move(rdx, Smi::FromInt(1)); 111 __ Move(rdx, Smi::FromInt(1));
109 __ cmpq(rdx, v8::internal::kSmiConstantRegister); 112 __ cmpq(rdx, i::kSmiConstantRegister);
110 __ movq(rdx, Immediate(-1)); 113 __ movq(rdx, Immediate(-1));
111 __ cmovq(not_equal, rax, rdx); 114 __ cmovq(not_equal, rax, rdx);
112 __ pop(v8::internal::kRootRegister); 115 __ pop(i::kRootRegister);
113 __ pop(v8::internal::kSmiConstantRegister); 116 __ pop(i::kSmiConstantRegister);
114 } 117 }
115 118
116 119
117 TEST(Smi) { 120 TEST(Smi) {
118 // Check that C++ Smi operations work as expected. 121 // Check that C++ Smi operations work as expected.
119 int64_t test_numbers[] = { 122 int64_t test_numbers[] = {
120 0, 1, -1, 127, 128, -128, -129, 255, 256, -256, -257, 123 0, 1, -1, 127, 128, -128, -129, 255, 256, -256, -257,
121 Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1, 124 Smi::kMaxValue, static_cast<int64_t>(Smi::kMaxValue) + 1,
122 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1 125 Smi::kMinValue, static_cast<int64_t>(Smi::kMinValue) - 1
123 }; 126 };
(...skipping 20 matching lines...) Expand all
144 __ movl(rax, Immediate(id)); 147 __ movl(rax, Immediate(id));
145 __ Move(rcx, value); 148 __ Move(rcx, value);
146 __ Set(rdx, reinterpret_cast<intptr_t>(value)); 149 __ Set(rdx, reinterpret_cast<intptr_t>(value));
147 __ cmpq(rcx, rdx); 150 __ cmpq(rcx, rdx);
148 __ j(not_equal, exit); 151 __ j(not_equal, exit);
149 } 152 }
150 153
151 154
152 // 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.
153 TEST(SmiMove) { 156 TEST(SmiMove) {
154 v8::internal::V8::Initialize(NULL); 157 i::V8::Initialize(NULL);
155 // Allocate an executable page of memory. 158 // Allocate an executable page of memory.
156 size_t actual_size; 159 size_t actual_size;
157 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 160 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
158 &actual_size, 161 &actual_size,
159 true)); 162 true));
160 CHECK(buffer); 163 CHECK(buffer);
161 Isolate* isolate = CcTest::i_isolate(); 164 Isolate* isolate = CcTest::i_isolate();
162 HandleScope handles(isolate); 165 HandleScope handles(isolate);
163 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 166 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
164 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
232 __ j(not_equal, exit); 235 __ j(not_equal, exit);
233 __ incq(rax); 236 __ incq(rax);
234 __ cmpq(rcx, r8); 237 __ cmpq(rcx, r8);
235 __ j(not_equal, exit); 238 __ j(not_equal, exit);
236 } 239 }
237 } 240 }
238 241
239 242
240 // Test that we can compare smis for equality (and more). 243 // Test that we can compare smis for equality (and more).
241 TEST(SmiCompare) { 244 TEST(SmiCompare) {
242 v8::internal::V8::Initialize(NULL); 245 i::V8::Initialize(NULL);
243 // Allocate an executable page of memory. 246 // Allocate an executable page of memory.
244 size_t actual_size; 247 size_t actual_size;
245 byte* buffer = 248 byte* buffer =
246 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 249 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2,
247 &actual_size, 250 &actual_size,
248 true)); 251 true));
249 CHECK(buffer); 252 CHECK(buffer);
250 Isolate* isolate = CcTest::i_isolate(); 253 Isolate* isolate = CcTest::i_isolate();
251 HandleScope handles(isolate); 254 HandleScope handles(isolate);
252 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
284 CodeDesc desc; 287 CodeDesc desc;
285 masm->GetCode(&desc); 288 masm->GetCode(&desc);
286 // Call the function from C++. 289 // Call the function from C++.
287 int result = FUNCTION_CAST<F0>(buffer)(); 290 int result = FUNCTION_CAST<F0>(buffer)();
288 CHECK_EQ(0, result); 291 CHECK_EQ(0, result);
289 } 292 }
290 293
291 294
292 295
293 TEST(Integer32ToSmi) { 296 TEST(Integer32ToSmi) {
294 v8::internal::V8::Initialize(NULL); 297 i::V8::Initialize(NULL);
295 // Allocate an executable page of memory. 298 // Allocate an executable page of memory.
296 size_t actual_size; 299 size_t actual_size;
297 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 300 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
298 &actual_size, 301 &actual_size,
299 true)); 302 true));
300 CHECK(buffer); 303 CHECK(buffer);
301 Isolate* isolate = CcTest::i_isolate(); 304 Isolate* isolate = CcTest::i_isolate();
302 HandleScope handles(isolate); 305 HandleScope handles(isolate);
303 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 306 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
304 307
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 398
396 void TestI64PlusConstantToSmi(MacroAssembler* masm, 399 void TestI64PlusConstantToSmi(MacroAssembler* masm,
397 Label* exit, 400 Label* exit,
398 int id, 401 int id,
399 int64_t x, 402 int64_t x,
400 int y) { 403 int y) {
401 int64_t result = x + y; 404 int64_t result = x + y;
402 ASSERT(Smi::IsValid(result)); 405 ASSERT(Smi::IsValid(result));
403 __ movl(rax, Immediate(id)); 406 __ movl(rax, Immediate(id));
404 __ Move(r8, Smi::FromInt(static_cast<int>(result))); 407 __ Move(r8, Smi::FromInt(static_cast<int>(result)));
405 __ movq(rcx, x, RelocInfo::NONE64); 408 __ movq(rcx, x);
406 __ movq(r11, rcx); 409 __ movq(r11, rcx);
407 __ Integer64PlusConstantToSmi(rdx, rcx, y); 410 __ Integer64PlusConstantToSmi(rdx, rcx, y);
408 __ cmpq(rdx, r8); 411 __ cmpq(rdx, r8);
409 __ j(not_equal, exit); 412 __ j(not_equal, exit);
410 413
411 __ incq(rax); 414 __ incq(rax);
412 __ cmpq(r11, rcx); 415 __ cmpq(r11, rcx);
413 __ j(not_equal, exit); 416 __ j(not_equal, exit);
414 417
415 __ incq(rax); 418 __ incq(rax);
416 __ Integer64PlusConstantToSmi(rcx, rcx, y); 419 __ Integer64PlusConstantToSmi(rcx, rcx, y);
417 __ cmpq(rcx, r8); 420 __ cmpq(rcx, r8);
418 __ j(not_equal, exit); 421 __ j(not_equal, exit);
419 } 422 }
420 423
421 424
422 TEST(Integer64PlusConstantToSmi) { 425 TEST(Integer64PlusConstantToSmi) {
423 v8::internal::V8::Initialize(NULL); 426 i::V8::Initialize(NULL);
424 // Allocate an executable page of memory. 427 // Allocate an executable page of memory.
425 size_t actual_size; 428 size_t actual_size;
426 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 429 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
427 &actual_size, 430 &actual_size,
428 true)); 431 true));
429 CHECK(buffer); 432 CHECK(buffer);
430 Isolate* isolate = CcTest::i_isolate(); 433 Isolate* isolate = CcTest::i_isolate();
431 HandleScope handles(isolate); 434 HandleScope handles(isolate);
432 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 435 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
433 436
(...skipping 24 matching lines...) Expand all
458 461
459 CodeDesc desc; 462 CodeDesc desc;
460 masm->GetCode(&desc); 463 masm->GetCode(&desc);
461 // Call the function from C++. 464 // Call the function from C++.
462 int result = FUNCTION_CAST<F0>(buffer)(); 465 int result = FUNCTION_CAST<F0>(buffer)();
463 CHECK_EQ(0, result); 466 CHECK_EQ(0, result);
464 } 467 }
465 468
466 469
467 TEST(SmiCheck) { 470 TEST(SmiCheck) {
468 v8::internal::V8::Initialize(NULL); 471 i::V8::Initialize(NULL);
469 // Allocate an executable page of memory. 472 // Allocate an executable page of memory.
470 size_t actual_size; 473 size_t actual_size;
471 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 474 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
472 &actual_size, 475 &actual_size,
473 true)); 476 true));
474 CHECK(buffer); 477 CHECK(buffer);
475 Isolate* isolate = CcTest::i_isolate(); 478 Isolate* isolate = CcTest::i_isolate();
476 HandleScope handles(isolate); 479 HandleScope handles(isolate);
477 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 480 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
478 481
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 __ jmp(exit); 709 __ jmp(exit);
707 __ bind(&smi_ok2); 710 __ bind(&smi_ok2);
708 __ incq(rax); 711 __ incq(rax);
709 __ cmpq(rcx, r8); 712 __ cmpq(rcx, r8);
710 __ j(not_equal, exit); 713 __ j(not_equal, exit);
711 } 714 }
712 } 715 }
713 716
714 717
715 TEST(SmiNeg) { 718 TEST(SmiNeg) {
716 v8::internal::V8::Initialize(NULL); 719 i::V8::Initialize(NULL);
717 // Allocate an executable page of memory. 720 // Allocate an executable page of memory.
718 size_t actual_size; 721 size_t actual_size;
719 byte* buffer = 722 byte* buffer =
720 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 723 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
721 &actual_size, 724 &actual_size,
722 true)); 725 true));
723 CHECK(buffer); 726 CHECK(buffer);
724 Isolate* isolate = CcTest::i_isolate(); 727 Isolate* isolate = CcTest::i_isolate();
725 HandleScope handles(isolate); 728 HandleScope handles(isolate);
726 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
763 __ Integer32ToSmi(rdx, rdx); 766 __ Integer32ToSmi(rdx, rdx);
764 __ movl(r8, Immediate(first + second)); 767 __ movl(r8, Immediate(first + second));
765 __ Integer32ToSmi(r8, r8); 768 __ Integer32ToSmi(r8, r8);
766 769
767 __ movl(rax, Immediate(id)); // Test number. 770 __ movl(rax, Immediate(id)); // Test number.
768 __ SmiAdd(r9, rcx, rdx, exit); 771 __ SmiAdd(r9, rcx, rdx, exit);
769 __ cmpq(r9, r8); 772 __ cmpq(r9, r8);
770 __ j(not_equal, exit); 773 __ j(not_equal, exit);
771 774
772 __ incq(rax); 775 __ incq(rax);
773 __ SmiAdd(rcx, rcx, rdx, exit); \ 776 __ SmiAdd(rcx, rcx, rdx, exit);
774 __ cmpq(rcx, r8); 777 __ cmpq(rcx, r8);
775 __ j(not_equal, exit); 778 __ j(not_equal, exit);
776 779
777 __ movl(rcx, Immediate(first)); 780 __ movl(rcx, Immediate(first));
778 __ Integer32ToSmi(rcx, rcx); 781 __ Integer32ToSmi(rcx, rcx);
779 782
780 __ incq(rax); 783 __ incq(rax);
781 __ SmiAddConstant(r9, rcx, Smi::FromInt(second)); 784 __ SmiAddConstant(r9, rcx, Smi::FromInt(second));
782 __ cmpq(r9, r8); 785 __ cmpq(r9, r8);
783 __ j(not_equal, exit); 786 __ j(not_equal, exit);
784 787
785 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second)); 788 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second));
786 __ cmpq(rcx, r8); 789 __ cmpq(rcx, r8);
787 __ j(not_equal, exit); 790 __ j(not_equal, exit);
788 791
789 __ movl(rcx, Immediate(first)); 792 __ movl(rcx, Immediate(first));
790 __ Integer32ToSmi(rcx, rcx); 793 __ Integer32ToSmi(rcx, rcx);
791 794
795 i::SmiOperationExecutionMode mode;
796 mode.Add(i::PRESERVE_SOURCE_REGISTER);
797 mode.Add(i::BAILOUT_ON_OVERFLOW);
792 __ incq(rax); 798 __ incq(rax);
793 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), exit); 799 __ SmiAddConstant(r9, rcx, Smi::FromInt(second), mode, exit);
794 __ cmpq(r9, r8); 800 __ cmpq(r9, r8);
795 __ j(not_equal, exit); 801 __ j(not_equal, exit);
796 802
797 __ incq(rax); 803 __ incq(rax);
798 __ 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);
799 __ cmpq(rcx, r8); 819 __ cmpq(rcx, r8);
800 __ j(not_equal, exit); 820 __ j(not_equal, exit);
801 } 821 }
802 822
803 823
804 static void SmiAddOverflowTest(MacroAssembler* masm, 824 static void SmiAddOverflowTest(MacroAssembler* masm,
805 Label* exit, 825 Label* exit,
806 int id, 826 int id,
807 int x) { 827 int x) {
808 // 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
828 Label overflow_ok; 848 Label overflow_ok;
829 __ incq(rax); 849 __ incq(rax);
830 __ SmiAdd(rcx, rcx, rdx, &overflow_ok); 850 __ SmiAdd(rcx, rcx, rdx, &overflow_ok);
831 __ jmp(exit); 851 __ jmp(exit);
832 __ bind(&overflow_ok); 852 __ bind(&overflow_ok);
833 __ incq(rax); 853 __ incq(rax);
834 __ cmpq(rcx, r11); 854 __ cmpq(rcx, r11);
835 __ j(not_equal, exit); 855 __ j(not_equal, exit);
836 } 856 }
837 857
858 i::SmiOperationExecutionMode mode;
859 mode.Add(i::PRESERVE_SOURCE_REGISTER);
860 mode.Add(i::BAILOUT_ON_OVERFLOW);
838 __ movq(rcx, r11); 861 __ movq(rcx, r11);
839 { 862 {
840 Label overflow_ok; 863 Label overflow_ok;
841 __ incq(rax); 864 __ incq(rax);
842 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_min), &overflow_ok); 865 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_min), mode, &overflow_ok);
843 __ jmp(exit); 866 __ jmp(exit);
844 __ bind(&overflow_ok); 867 __ bind(&overflow_ok);
845 __ incq(rax); 868 __ incq(rax);
846 __ cmpq(rcx, r11); 869 __ cmpq(rcx, r11);
847 __ j(not_equal, exit); 870 __ j(not_equal, exit);
848 } 871 }
849 872
850 { 873 {
851 Label overflow_ok; 874 Label overflow_ok;
852 __ incq(rax); 875 __ incq(rax);
853 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_min), &overflow_ok); 876 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_min), mode, &overflow_ok);
854 __ jmp(exit); 877 __ jmp(exit);
855 __ bind(&overflow_ok); 878 __ bind(&overflow_ok);
856 __ incq(rax); 879 __ incq(rax);
857 __ cmpq(rcx, r11); 880 __ cmpq(rcx, r11);
858 __ j(not_equal, exit); 881 __ j(not_equal, exit);
859 } 882 }
860 883
861 __ Move(rdx, Smi::FromInt(y_max)); 884 __ Move(rdx, Smi::FromInt(y_max));
862 885
863 { 886 {
(...skipping 15 matching lines...) Expand all
879 __ bind(&overflow_ok); 902 __ bind(&overflow_ok);
880 __ incq(rax); 903 __ incq(rax);
881 __ cmpq(rcx, r11); 904 __ cmpq(rcx, r11);
882 __ j(not_equal, exit); 905 __ j(not_equal, exit);
883 } 906 }
884 907
885 __ movq(rcx, r11); 908 __ movq(rcx, r11);
886 { 909 {
887 Label overflow_ok; 910 Label overflow_ok;
888 __ incq(rax); 911 __ incq(rax);
889 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_max), &overflow_ok); 912 __ SmiAddConstant(r9, rcx, Smi::FromInt(y_max), mode, &overflow_ok);
890 __ jmp(exit); 913 __ jmp(exit);
891 __ bind(&overflow_ok); 914 __ bind(&overflow_ok);
892 __ incq(rax); 915 __ incq(rax);
893 __ cmpq(rcx, r11); 916 __ cmpq(rcx, r11);
894 __ j(not_equal, exit); 917 __ j(not_equal, exit);
895 } 918 }
896 919
920 mode.RemoveAll();
921 mode.Add(i::BAILOUT_ON_OVERFLOW);
897 { 922 {
898 Label overflow_ok; 923 Label overflow_ok;
899 __ incq(rax); 924 __ incq(rax);
900 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_max), &overflow_ok); 925 __ SmiAddConstant(rcx, rcx, Smi::FromInt(y_max), mode, &overflow_ok);
901 __ jmp(exit); 926 __ jmp(exit);
902 __ bind(&overflow_ok); 927 __ bind(&overflow_ok);
903 __ incq(rax); 928 __ incq(rax);
904 __ cmpq(rcx, r11); 929 __ cmpq(rcx, r11);
905 __ j(not_equal, exit); 930 __ j(equal, exit);
906 } 931 }
907 } 932 }
908 933
909 934
910 TEST(SmiAdd) { 935 TEST(SmiAdd) {
911 v8::internal::V8::Initialize(NULL); 936 i::V8::Initialize(NULL);
912 // Allocate an executable page of memory. 937 // Allocate an executable page of memory.
913 size_t actual_size; 938 size_t actual_size;
914 byte* buffer = 939 byte* buffer =
915 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 940 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2,
916 &actual_size, 941 &actual_size,
917 true)); 942 true));
918 CHECK(buffer); 943 CHECK(buffer);
919 Isolate* isolate = CcTest::i_isolate(); 944 Isolate* isolate = CcTest::i_isolate();
920 HandleScope handles(isolate); 945 HandleScope handles(isolate);
921 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
980 __ incq(rax); // Test 2. 1005 __ incq(rax); // Test 2.
981 __ SmiSubConstant(r9, rcx, Smi::FromInt(second)); 1006 __ SmiSubConstant(r9, rcx, Smi::FromInt(second));
982 __ cmpq(r9, r8); 1007 __ cmpq(r9, r8);
983 __ j(not_equal, exit); 1008 __ j(not_equal, exit);
984 1009
985 __ incq(rax); // Test 3. 1010 __ incq(rax); // Test 3.
986 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second)); 1011 __ SmiSubConstant(rcx, rcx, Smi::FromInt(second));
987 __ cmpq(rcx, r8); 1012 __ cmpq(rcx, r8);
988 __ j(not_equal, exit); 1013 __ j(not_equal, exit);
989 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
990 __ Move(rcx, Smi::FromInt(first)); 1024 __ Move(rcx, Smi::FromInt(first));
991 1025 __ incq(rax); // Test 5.
992 __ incq(rax); // Test 4. 1026 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), mode, exit);
993 __ SmiSubConstant(r9, rcx, Smi::FromInt(second), exit);
994 __ cmpq(r9, r8); 1027 __ cmpq(r9, r8);
995 __ j(not_equal, exit); 1028 __ j(not_equal, exit);
996 1029
997 __ incq(rax); // Test 5. 1030 mode.RemoveAll();
998 __ 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);
999 __ cmpq(rcx, r8); 1039 __ cmpq(rcx, r8);
1000 __ j(not_equal, exit); 1040 __ j(not_equal, exit);
1001 } 1041 }
1002 1042
1003 1043
1004 static void SmiSubOverflowTest(MacroAssembler* masm, 1044 static void SmiSubOverflowTest(MacroAssembler* masm,
1005 Label* exit, 1045 Label* exit,
1006 int id, 1046 int id,
1007 int x) { 1047 int x) {
1008 // 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
1028 Label overflow_ok; 1068 Label overflow_ok;
1029 __ incq(rax); 1069 __ incq(rax);
1030 __ SmiSub(rcx, rcx, rdx, &overflow_ok); 1070 __ SmiSub(rcx, rcx, rdx, &overflow_ok);
1031 __ jmp(exit); 1071 __ jmp(exit);
1032 __ bind(&overflow_ok); 1072 __ bind(&overflow_ok);
1033 __ incq(rax); 1073 __ incq(rax);
1034 __ cmpq(rcx, r11); 1074 __ cmpq(rcx, r11);
1035 __ j(not_equal, exit); 1075 __ j(not_equal, exit);
1036 } 1076 }
1037 1077
1078 i::SmiOperationExecutionMode mode;
1079 mode.Add(i::PRESERVE_SOURCE_REGISTER);
1080 mode.Add(i::BAILOUT_ON_OVERFLOW);
1081
1038 __ movq(rcx, r11); 1082 __ movq(rcx, r11);
1039 { 1083 {
1040 Label overflow_ok; 1084 Label overflow_ok;
1041 __ incq(rax); 1085 __ incq(rax);
1042 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), &overflow_ok); 1086 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_min), mode, &overflow_ok);
1043 __ jmp(exit); 1087 __ jmp(exit);
1044 __ bind(&overflow_ok); 1088 __ bind(&overflow_ok);
1045 __ incq(rax); 1089 __ incq(rax);
1046 __ cmpq(rcx, r11); 1090 __ cmpq(rcx, r11);
1047 __ j(not_equal, exit); 1091 __ j(not_equal, exit);
1048 } 1092 }
1049 1093
1050 { 1094 {
1051 Label overflow_ok; 1095 Label overflow_ok;
1052 __ incq(rax); 1096 __ incq(rax);
1053 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), &overflow_ok); 1097 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_min), mode, &overflow_ok);
1054 __ jmp(exit); 1098 __ jmp(exit);
1055 __ bind(&overflow_ok); 1099 __ bind(&overflow_ok);
1056 __ incq(rax); 1100 __ incq(rax);
1057 __ cmpq(rcx, r11); 1101 __ cmpq(rcx, r11);
1058 __ j(not_equal, exit); 1102 __ j(not_equal, exit);
1059 } 1103 }
1060 1104
1061 __ Move(rdx, Smi::FromInt(y_max)); 1105 __ Move(rdx, Smi::FromInt(y_max));
1062 1106
1063 { 1107 {
(...skipping 15 matching lines...) Expand all
1079 __ bind(&overflow_ok); 1123 __ bind(&overflow_ok);
1080 __ incq(rax); 1124 __ incq(rax);
1081 __ cmpq(rcx, r11); 1125 __ cmpq(rcx, r11);
1082 __ j(not_equal, exit); 1126 __ j(not_equal, exit);
1083 } 1127 }
1084 1128
1085 __ movq(rcx, r11); 1129 __ movq(rcx, r11);
1086 { 1130 {
1087 Label overflow_ok; 1131 Label overflow_ok;
1088 __ incq(rax); 1132 __ incq(rax);
1089 __ SmiSubConstant(r9, rcx, Smi::FromInt(y_max), &overflow_ok); 1133 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), mode, &overflow_ok);
1090 __ jmp(exit); 1134 __ jmp(exit);
1091 __ bind(&overflow_ok); 1135 __ bind(&overflow_ok);
1092 __ incq(rax); 1136 __ incq(rax);
1093 __ cmpq(rcx, r11); 1137 __ cmpq(rcx, r11);
1094 __ j(not_equal, exit); 1138 __ j(not_equal, exit);
1095 } 1139 }
1096 1140
1141 mode.RemoveAll();
1142 mode.Add(i::BAILOUT_ON_OVERFLOW);
1143 __ movq(rcx, r11);
1097 { 1144 {
1098 Label overflow_ok; 1145 Label overflow_ok;
1099 __ incq(rax); 1146 __ incq(rax);
1100 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), &overflow_ok); 1147 __ SmiSubConstant(rcx, rcx, Smi::FromInt(y_max), mode, &overflow_ok);
1101 __ jmp(exit); 1148 __ jmp(exit);
1102 __ bind(&overflow_ok); 1149 __ bind(&overflow_ok);
1103 __ incq(rax); 1150 __ incq(rax);
1104 __ cmpq(rcx, r11); 1151 __ cmpq(rcx, r11);
1105 __ j(not_equal, exit); 1152 __ j(equal, exit);
1106 } 1153 }
1107 } 1154 }
1108 1155
1109 1156
1110 TEST(SmiSub) { 1157 TEST(SmiSub) {
1111 v8::internal::V8::Initialize(NULL); 1158 i::V8::Initialize(NULL);
1112 // Allocate an executable page of memory. 1159 // Allocate an executable page of memory.
1113 size_t actual_size; 1160 size_t actual_size;
1114 byte* buffer = 1161 byte* buffer =
1115 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 1162 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2,
1116 &actual_size, 1163 &actual_size,
1117 true)); 1164 true));
1118 CHECK(buffer); 1165 CHECK(buffer);
1119 Isolate* isolate = CcTest::i_isolate(); 1166 Isolate* isolate = CcTest::i_isolate();
1120 HandleScope handles(isolate); 1167 HandleScope handles(isolate);
1121 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
1193 __ bind(&overflow_ok2); 1240 __ bind(&overflow_ok2);
1194 // 31-bit version doesn't preserve rcx on failure. 1241 // 31-bit version doesn't preserve rcx on failure.
1195 // __ incq(rax); 1242 // __ incq(rax);
1196 // __ cmpq(r11, rcx); 1243 // __ cmpq(r11, rcx);
1197 // __ j(not_equal, exit); 1244 // __ j(not_equal, exit);
1198 } 1245 }
1199 } 1246 }
1200 1247
1201 1248
1202 TEST(SmiMul) { 1249 TEST(SmiMul) {
1203 v8::internal::V8::Initialize(NULL); 1250 i::V8::Initialize(NULL);
1204 // Allocate an executable page of memory. 1251 // Allocate an executable page of memory.
1205 size_t actual_size; 1252 size_t actual_size;
1206 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1253 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
1207 &actual_size, 1254 &actual_size,
1208 true)); 1255 true));
1209 CHECK(buffer); 1256 CHECK(buffer);
1210 Isolate* isolate = CcTest::i_isolate(); 1257 Isolate* isolate = CcTest::i_isolate();
1211 HandleScope handles(isolate); 1258 HandleScope handles(isolate);
1212 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 1259 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
1213 1260
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 __ bind(&fail_ok2); 1346 __ bind(&fail_ok2);
1300 1347
1301 __ incq(r15); 1348 __ incq(r15);
1302 __ cmpq(rcx, r11); 1349 __ cmpq(rcx, r11);
1303 __ j(not_equal, exit); 1350 __ j(not_equal, exit);
1304 } 1351 }
1305 } 1352 }
1306 1353
1307 1354
1308 TEST(SmiDiv) { 1355 TEST(SmiDiv) {
1309 v8::internal::V8::Initialize(NULL); 1356 i::V8::Initialize(NULL);
1310 // Allocate an executable page of memory. 1357 // Allocate an executable page of memory.
1311 size_t actual_size; 1358 size_t actual_size;
1312 byte* buffer = 1359 byte* buffer =
1313 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 1360 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2,
1314 &actual_size, 1361 &actual_size,
1315 true)); 1362 true));
1316 CHECK(buffer); 1363 CHECK(buffer);
1317 Isolate* isolate = CcTest::i_isolate(); 1364 Isolate* isolate = CcTest::i_isolate();
1318 HandleScope handles(isolate); 1365 HandleScope handles(isolate);
1319 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
1410 __ bind(&fail_ok2); 1457 __ bind(&fail_ok2);
1411 1458
1412 __ incq(r15); 1459 __ incq(r15);
1413 __ cmpq(rcx, r11); 1460 __ cmpq(rcx, r11);
1414 __ j(not_equal, exit); 1461 __ j(not_equal, exit);
1415 } 1462 }
1416 } 1463 }
1417 1464
1418 1465
1419 TEST(SmiMod) { 1466 TEST(SmiMod) {
1420 v8::internal::V8::Initialize(NULL); 1467 i::V8::Initialize(NULL);
1421 // Allocate an executable page of memory. 1468 // Allocate an executable page of memory.
1422 size_t actual_size; 1469 size_t actual_size;
1423 byte* buffer = 1470 byte* buffer =
1424 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 1471 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2,
1425 &actual_size, 1472 &actual_size,
1426 true)); 1473 true));
1427 CHECK(buffer); 1474 CHECK(buffer);
1428 Isolate* isolate = CcTest::i_isolate(); 1475 Isolate* isolate = CcTest::i_isolate();
1429 HandleScope handles(isolate); 1476 HandleScope handles(isolate);
1430 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
1508 __ shl(rcx, Immediate(index.scale)); 1555 __ shl(rcx, Immediate(index.scale));
1509 __ Set(r8, static_cast<intptr_t>(-x) << i); 1556 __ Set(r8, static_cast<intptr_t>(-x) << i);
1510 __ cmpq(rcx, r8); 1557 __ cmpq(rcx, r8);
1511 __ j(not_equal, exit); 1558 __ j(not_equal, exit);
1512 __ incq(rax); 1559 __ incq(rax);
1513 } 1560 }
1514 } 1561 }
1515 1562
1516 1563
1517 TEST(SmiIndex) { 1564 TEST(SmiIndex) {
1518 v8::internal::V8::Initialize(NULL); 1565 i::V8::Initialize(NULL);
1519 // Allocate an executable page of memory. 1566 // Allocate an executable page of memory.
1520 size_t actual_size; 1567 size_t actual_size;
1521 byte* buffer = 1568 byte* buffer =
1522 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, 1569 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3,
1523 &actual_size, 1570 &actual_size,
1524 true)); 1571 true));
1525 CHECK(buffer); 1572 CHECK(buffer);
1526 Isolate* isolate = CcTest::i_isolate(); 1573 Isolate* isolate = CcTest::i_isolate();
1527 HandleScope handles(isolate); 1574 HandleScope handles(isolate);
1528 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
1578 __ Move(rdx, Smi::FromInt(y)); 1625 __ Move(rdx, Smi::FromInt(y));
1579 __ xor_(rcx, Immediate(kSmiTagMask)); 1626 __ xor_(rcx, Immediate(kSmiTagMask));
1580 __ xor_(rdx, Immediate(kSmiTagMask)); 1627 __ xor_(rdx, Immediate(kSmiTagMask));
1581 __ SelectNonSmi(r9, rcx, rdx, &fail_ok); 1628 __ SelectNonSmi(r9, rcx, rdx, &fail_ok);
1582 __ jmp(exit); 1629 __ jmp(exit);
1583 __ bind(&fail_ok); 1630 __ bind(&fail_ok);
1584 } 1631 }
1585 1632
1586 1633
1587 TEST(SmiSelectNonSmi) { 1634 TEST(SmiSelectNonSmi) {
1588 v8::internal::V8::Initialize(NULL); 1635 i::V8::Initialize(NULL);
1589 // Allocate an executable page of memory. 1636 // Allocate an executable page of memory.
1590 size_t actual_size; 1637 size_t actual_size;
1591 byte* buffer = 1638 byte* buffer =
1592 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1639 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
1593 &actual_size, 1640 &actual_size,
1594 true)); 1641 true));
1595 CHECK(buffer); 1642 CHECK(buffer);
1596 Isolate* isolate = CcTest::i_isolate(); 1643 Isolate* isolate = CcTest::i_isolate();
1597 HandleScope handles(isolate); 1644 HandleScope handles(isolate);
1598 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
1658 __ j(not_equal, exit); 1705 __ j(not_equal, exit);
1659 1706
1660 __ incq(rax); 1707 __ incq(rax);
1661 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y)); 1708 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y));
1662 __ cmpq(r8, rcx); 1709 __ cmpq(r8, rcx);
1663 __ j(not_equal, exit); 1710 __ j(not_equal, exit);
1664 } 1711 }
1665 1712
1666 1713
1667 TEST(SmiAnd) { 1714 TEST(SmiAnd) {
1668 v8::internal::V8::Initialize(NULL); 1715 i::V8::Initialize(NULL);
1669 // Allocate an executable page of memory. 1716 // Allocate an executable page of memory.
1670 size_t actual_size; 1717 size_t actual_size;
1671 byte* buffer = 1718 byte* buffer =
1672 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1719 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
1673 &actual_size, 1720 &actual_size,
1674 true)); 1721 true));
1675 CHECK(buffer); 1722 CHECK(buffer);
1676 Isolate* isolate = CcTest::i_isolate(); 1723 Isolate* isolate = CcTest::i_isolate();
1677 HandleScope handles(isolate); 1724 HandleScope handles(isolate);
1678 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
1740 __ j(not_equal, exit); 1787 __ j(not_equal, exit);
1741 1788
1742 __ incq(rax); 1789 __ incq(rax);
1743 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y)); 1790 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y));
1744 __ cmpq(r8, rcx); 1791 __ cmpq(r8, rcx);
1745 __ j(not_equal, exit); 1792 __ j(not_equal, exit);
1746 } 1793 }
1747 1794
1748 1795
1749 TEST(SmiOr) { 1796 TEST(SmiOr) {
1750 v8::internal::V8::Initialize(NULL); 1797 i::V8::Initialize(NULL);
1751 // Allocate an executable page of memory. 1798 // Allocate an executable page of memory.
1752 size_t actual_size; 1799 size_t actual_size;
1753 byte* buffer = 1800 byte* buffer =
1754 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1801 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
1755 &actual_size, 1802 &actual_size,
1756 true)); 1803 true));
1757 CHECK(buffer); 1804 CHECK(buffer);
1758 Isolate* isolate = CcTest::i_isolate(); 1805 Isolate* isolate = CcTest::i_isolate();
1759 HandleScope handles(isolate); 1806 HandleScope handles(isolate);
1760 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
1824 __ j(not_equal, exit); 1871 __ j(not_equal, exit);
1825 1872
1826 __ incq(rax); 1873 __ incq(rax);
1827 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y)); 1874 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y));
1828 __ cmpq(r8, rcx); 1875 __ cmpq(r8, rcx);
1829 __ j(not_equal, exit); 1876 __ j(not_equal, exit);
1830 } 1877 }
1831 1878
1832 1879
1833 TEST(SmiXor) { 1880 TEST(SmiXor) {
1834 v8::internal::V8::Initialize(NULL); 1881 i::V8::Initialize(NULL);
1835 // Allocate an executable page of memory. 1882 // Allocate an executable page of memory.
1836 size_t actual_size; 1883 size_t actual_size;
1837 byte* buffer = 1884 byte* buffer =
1838 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1885 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
1839 &actual_size, 1886 &actual_size,
1840 true)); 1887 true));
1841 CHECK(buffer); 1888 CHECK(buffer);
1842 Isolate* isolate = CcTest::i_isolate(); 1889 Isolate* isolate = CcTest::i_isolate();
1843 HandleScope handles(isolate); 1890 HandleScope handles(isolate);
1844 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
1892 __ j(not_equal, exit); 1939 __ j(not_equal, exit);
1893 1940
1894 __ incq(rax); 1941 __ incq(rax);
1895 __ SmiNot(rcx, rcx); 1942 __ SmiNot(rcx, rcx);
1896 __ cmpq(rcx, r8); 1943 __ cmpq(rcx, r8);
1897 __ j(not_equal, exit); 1944 __ j(not_equal, exit);
1898 } 1945 }
1899 1946
1900 1947
1901 TEST(SmiNot) { 1948 TEST(SmiNot) {
1902 v8::internal::V8::Initialize(NULL); 1949 i::V8::Initialize(NULL);
1903 // Allocate an executable page of memory. 1950 // Allocate an executable page of memory.
1904 size_t actual_size; 1951 size_t actual_size;
1905 byte* buffer = 1952 byte* buffer =
1906 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1953 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize,
1907 &actual_size, 1954 &actual_size,
1908 true)); 1955 true));
1909 CHECK(buffer); 1956 CHECK(buffer);
1910 Isolate* isolate = CcTest::i_isolate(); 1957 Isolate* isolate = CcTest::i_isolate();
1911 HandleScope handles(isolate); 1958 HandleScope handles(isolate);
1912 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
1989 __ incq(rax); 2036 __ incq(rax);
1990 __ cmpq(rdx, r8); 2037 __ cmpq(rdx, r8);
1991 __ j(not_equal, exit); 2038 __ j(not_equal, exit);
1992 2039
1993 __ incq(rax); 2040 __ incq(rax);
1994 } 2041 }
1995 } 2042 }
1996 2043
1997 2044
1998 TEST(SmiShiftLeft) { 2045 TEST(SmiShiftLeft) {
1999 v8::internal::V8::Initialize(NULL); 2046 i::V8::Initialize(NULL);
2000 // Allocate an executable page of memory. 2047 // Allocate an executable page of memory.
2001 size_t actual_size; 2048 size_t actual_size;
2002 byte* buffer = 2049 byte* buffer =
2003 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, 2050 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4,
2004 &actual_size, 2051 &actual_size,
2005 true)); 2052 true));
2006 CHECK(buffer); 2053 CHECK(buffer);
2007 Isolate* isolate = CcTest::i_isolate(); 2054 Isolate* isolate = CcTest::i_isolate();
2008 HandleScope handles(isolate); 2055 HandleScope handles(isolate);
2009 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
2096 __ cmpq(rcx, r11); 2143 __ cmpq(rcx, r11);
2097 __ j(not_equal, exit); 2144 __ j(not_equal, exit);
2098 2145
2099 __ addq(rax, Immediate(3)); 2146 __ addq(rax, Immediate(3));
2100 } 2147 }
2101 } 2148 }
2102 } 2149 }
2103 2150
2104 2151
2105 TEST(SmiShiftLogicalRight) { 2152 TEST(SmiShiftLogicalRight) {
2106 v8::internal::V8::Initialize(NULL); 2153 i::V8::Initialize(NULL);
2107 // Allocate an executable page of memory. 2154 // Allocate an executable page of memory.
2108 size_t actual_size; 2155 size_t actual_size;
2109 byte* buffer = 2156 byte* buffer =
2110 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, 2157 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3,
2111 &actual_size, 2158 &actual_size,
2112 true)); 2159 true));
2113 CHECK(buffer); 2160 CHECK(buffer);
2114 Isolate* isolate = CcTest::i_isolate(); 2161 Isolate* isolate = CcTest::i_isolate();
2115 HandleScope handles(isolate); 2162 HandleScope handles(isolate);
2116 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
2166 2213
2167 __ cmpq(rdx, r8); 2214 __ cmpq(rdx, r8);
2168 __ j(not_equal, exit); 2215 __ j(not_equal, exit);
2169 2216
2170 __ incq(rax); 2217 __ incq(rax);
2171 } 2218 }
2172 } 2219 }
2173 2220
2174 2221
2175 TEST(SmiShiftArithmeticRight) { 2222 TEST(SmiShiftArithmeticRight) {
2176 v8::internal::V8::Initialize(NULL); 2223 i::V8::Initialize(NULL);
2177 // Allocate an executable page of memory. 2224 // Allocate an executable page of memory.
2178 size_t actual_size; 2225 size_t actual_size;
2179 byte* buffer = 2226 byte* buffer =
2180 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 2227 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2,
2181 &actual_size, 2228 &actual_size,
2182 true)); 2229 true));
2183 CHECK(buffer); 2230 CHECK(buffer);
2184 Isolate* isolate = CcTest::i_isolate(); 2231 Isolate* isolate = CcTest::i_isolate();
2185 HandleScope handles(isolate); 2232 HandleScope handles(isolate);
2186 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
2231 __ incq(rax); 2278 __ incq(rax);
2232 __ PositiveSmiTimesPowerOfTwoToInteger64(rcx, rcx, power); 2279 __ PositiveSmiTimesPowerOfTwoToInteger64(rcx, rcx, power);
2233 __ cmpq(rdx, r8); 2280 __ cmpq(rdx, r8);
2234 __ j(not_equal, exit); 2281 __ j(not_equal, exit);
2235 __ incq(rax); 2282 __ incq(rax);
2236 } 2283 }
2237 } 2284 }
2238 2285
2239 2286
2240 TEST(PositiveSmiTimesPowerOfTwoToInteger64) { 2287 TEST(PositiveSmiTimesPowerOfTwoToInteger64) {
2241 v8::internal::V8::Initialize(NULL); 2288 i::V8::Initialize(NULL);
2242 // Allocate an executable page of memory. 2289 // Allocate an executable page of memory.
2243 size_t actual_size; 2290 size_t actual_size;
2244 byte* buffer = 2291 byte* buffer =
2245 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, 2292 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4,
2246 &actual_size, 2293 &actual_size,
2247 true)); 2294 true));
2248 CHECK(buffer); 2295 CHECK(buffer);
2249 Isolate* isolate = CcTest::i_isolate(); 2296 Isolate* isolate = CcTest::i_isolate();
2250 HandleScope handles(isolate); 2297 HandleScope handles(isolate);
2251 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
2272 2319
2273 CodeDesc desc; 2320 CodeDesc desc;
2274 masm->GetCode(&desc); 2321 masm->GetCode(&desc);
2275 // Call the function from C++. 2322 // Call the function from C++.
2276 int result = FUNCTION_CAST<F0>(buffer)(); 2323 int result = FUNCTION_CAST<F0>(buffer)();
2277 CHECK_EQ(0, result); 2324 CHECK_EQ(0, result);
2278 } 2325 }
2279 2326
2280 2327
2281 TEST(OperandOffset) { 2328 TEST(OperandOffset) {
2282 v8::internal::V8::Initialize(NULL); 2329 i::V8::Initialize(NULL);
2283 int data[256]; 2330 uint32_t data[256];
2284 for (int i = 0; i < 256; i++) { data[i] = i * 0x01010101; } 2331 for (uint32_t i = 0; i < 256; i++) { data[i] = i * 0x01010101; }
2285 2332
2286 // Allocate an executable page of memory. 2333 // Allocate an executable page of memory.
2287 size_t actual_size; 2334 size_t actual_size;
2288 byte* buffer = 2335 byte* buffer =
2289 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 2336 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2,
2290 &actual_size, 2337 &actual_size,
2291 true)); 2338 true));
2292 CHECK(buffer); 2339 CHECK(buffer);
2293 Isolate* isolate = CcTest::i_isolate(); 2340 Isolate* isolate = CcTest::i_isolate();
2294 HandleScope handles(isolate); 2341 HandleScope handles(isolate);
(...skipping 20 matching lines...) Expand all
2315 __ push(Immediate(0x108)); 2362 __ push(Immediate(0x108));
2316 __ push(Immediate(0x109)); // <-- rsp 2363 __ push(Immediate(0x109)); // <-- rsp
2317 // rbp = rsp[9] 2364 // rbp = rsp[9]
2318 // r15 = rsp[3] 2365 // r15 = rsp[3]
2319 // rbx = rsp[5] 2366 // rbx = rsp[5]
2320 // r13 = rsp[7] 2367 // r13 = rsp[7]
2321 __ lea(r14, Operand(rsp, 3 * kPointerSize)); 2368 __ lea(r14, Operand(rsp, 3 * kPointerSize));
2322 __ lea(r13, Operand(rbp, -3 * kPointerSize)); 2369 __ lea(r13, Operand(rbp, -3 * kPointerSize));
2323 __ lea(rbx, Operand(rbp, -5 * kPointerSize)); 2370 __ lea(rbx, Operand(rbp, -5 * kPointerSize));
2324 __ movl(rcx, Immediate(2)); 2371 __ movl(rcx, Immediate(2));
2325 __ movq(r8, reinterpret_cast<uintptr_t>(&data[128]), RelocInfo::NONE64); 2372 __ movq(r8, reinterpret_cast<Address>(&data[128]), RelocInfo::NONE64);
2326 __ movl(rax, Immediate(1)); 2373 __ movl(rax, Immediate(1));
2327 2374
2328 Operand sp0 = Operand(rsp, 0); 2375 Operand sp0 = Operand(rsp, 0);
2329 2376
2330 // Test 1. 2377 // Test 1.
2331 __ movl(rdx, sp0); // Sanity check. 2378 __ movl(rdx, sp0); // Sanity check.
2332 __ cmpl(rdx, Immediate(0x109)); 2379 __ cmpl(rdx, Immediate(0x109));
2333 __ j(not_equal, &exit); 2380 __ j(not_equal, &exit);
2334 __ incq(rax); 2381 __ incq(rax);
2335 2382
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2650 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. 2697 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro.
2651 masm->set_allow_stub_calls(false); 2698 masm->set_allow_stub_calls(false);
2652 EntryCode(masm); 2699 EntryCode(masm);
2653 __ subq(rsp, Immediate(1 * kPointerSize)); 2700 __ subq(rsp, Immediate(1 * kPointerSize));
2654 Label exit; 2701 Label exit;
2655 2702
2656 // Test 1. 2703 // Test 1.
2657 __ movq(rax, Immediate(1)); // Test number. 2704 __ movq(rax, Immediate(1)); // Test number.
2658 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); 2705 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0));
2659 __ movq(rcx, Immediate(-1)); 2706 __ movq(rcx, Immediate(-1));
2660 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Byte()); 2707 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::UInteger8());
2661 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); 2708 __ movq(rcx, Operand(rsp, 0 * kPointerSize));
2662 __ movl(rdx, Immediate(255)); 2709 __ movl(rdx, Immediate(255));
2663 __ cmpq(rcx, rdx); 2710 __ cmpq(rcx, rdx);
2664 __ j(not_equal, &exit); 2711 __ j(not_equal, &exit);
2665 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::Byte()); 2712 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::UInteger8());
2666 __ cmpq(rcx, rdx); 2713 __ cmpq(rcx, rdx);
2667 __ j(not_equal, &exit); 2714 __ j(not_equal, &exit);
2668 2715
2669 // Test 2. 2716 // Test 2.
2670 __ movq(rax, Immediate(2)); // Test number. 2717 __ movq(rax, Immediate(2)); // Test number.
2671 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); 2718 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0));
2672 __ Set(rcx, V8_2PART_UINT64_C(0xdeadbeaf, 12345678)); 2719 __ Set(rcx, V8_2PART_UINT64_C(0xdeadbeaf, 12345678));
2673 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Smi()); 2720 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Smi());
2674 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); 2721 __ movq(rcx, Operand(rsp, 0 * kPointerSize));
2675 __ Set(rdx, V8_2PART_UINT64_C(0xdeadbeaf, 12345678)); 2722 __ Set(rdx, V8_2PART_UINT64_C(0xdeadbeaf, 12345678));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2724 __ Set(rcx, V8_2PART_UINT64_C(0x11223344, 55667788)); 2771 __ Set(rcx, V8_2PART_UINT64_C(0x11223344, 55667788));
2725 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::External()); 2772 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::External());
2726 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); 2773 __ movq(rcx, Operand(rsp, 0 * kPointerSize));
2727 __ Set(rdx, V8_2PART_UINT64_C(0x11223344, 55667788)); 2774 __ Set(rdx, V8_2PART_UINT64_C(0x11223344, 55667788));
2728 __ cmpq(rcx, rdx); 2775 __ cmpq(rcx, rdx);
2729 __ j(not_equal, &exit); 2776 __ j(not_equal, &exit);
2730 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::External()); 2777 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::External());
2731 __ cmpq(rcx, rdx); 2778 __ cmpq(rcx, rdx);
2732 __ j(not_equal, &exit); 2779 __ j(not_equal, &exit);
2733 2780
2781 // Test 7.
2782 __ movq(rax, Immediate(7)); // Test number.
2783 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0));
2784 __ movq(rcx, Immediate(-1));
2785 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Integer8());
2786 __ movq(rcx, Operand(rsp, 0 * kPointerSize));
2787 __ movl(rdx, Immediate(255));
2788 __ cmpq(rcx, rdx);
2789 __ j(not_equal, &exit);
2790 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::Integer8());
2791 __ movq(rcx, Immediate(-1));
2792 __ cmpq(rcx, rdx);
2793 __ j(not_equal, &exit);
2794
2795 // Test 8.
2796 __ movq(rax, Immediate(8)); // Test number.
2797 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0));
2798 __ movq(rcx, Immediate(-1));
2799 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Integer16());
2800 __ movq(rcx, Operand(rsp, 0 * kPointerSize));
2801 __ movl(rdx, Immediate(65535));
2802 __ cmpq(rcx, rdx);
2803 __ j(not_equal, &exit);
2804 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::Integer16());
2805 __ movq(rcx, Immediate(-1));
2806 __ cmpq(rcx, rdx);
2807 __ j(not_equal, &exit);
2808
2809 // Test 9.
2810 __ movq(rax, Immediate(9)); // Test number.
2811 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0));
2812 __ movq(rcx, Immediate(-1));
2813 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::UInteger16());
2814 __ movq(rcx, Operand(rsp, 0 * kPointerSize));
2815 __ movl(rdx, Immediate(65535));
2816 __ cmpq(rcx, rdx);
2817 __ j(not_equal, &exit);
2818 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::UInteger16());
2819 __ cmpq(rcx, rdx);
2820 __ j(not_equal, &exit);
2821
2734 __ xor_(rax, rax); // Success. 2822 __ xor_(rax, rax); // Success.
2735 __ bind(&exit); 2823 __ bind(&exit);
2736 __ addq(rsp, Immediate(1 * kPointerSize)); 2824 __ addq(rsp, Immediate(1 * kPointerSize));
2737 ExitCode(masm); 2825 ExitCode(masm);
2738 __ ret(0); 2826 __ ret(0);
2739 2827
2740 CodeDesc desc; 2828 CodeDesc desc;
2741 masm->GetCode(&desc); 2829 masm->GetCode(&desc);
2742 // Call the function from C++. 2830 // Call the function from C++.
2743 int result = FUNCTION_CAST<F0>(buffer)(); 2831 int result = FUNCTION_CAST<F0>(buffer)();
2744 CHECK_EQ(0, result); 2832 CHECK_EQ(0, result);
2745 } 2833 }
2746 2834
2747 2835
2748 #undef __ 2836 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-macro-assembler-ia32.cc ('k') | test/cctest/test-mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698