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

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

Issue 23641009: Refactor and cleanup VirtualMemory. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed nits. Created 7 years, 3 months 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-code-stubs-x64.cc ('k') | test/cctest/test-platform-linux.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 using namespace v8::internal;
39 using v8::internal::CodeDesc;
40 using v8::internal::Condition;
41 using v8::internal::FUNCTION_CAST;
42 using v8::internal::HandleScope;
43 using v8::internal::Immediate;
44 using v8::internal::Isolate;
45 using v8::internal::Label;
46 using v8::internal::MacroAssembler;
47 using v8::internal::OS;
48 using v8::internal::Operand;
49 using v8::internal::RelocInfo;
50 using v8::internal::Smi;
51 using v8::internal::SmiIndex;
52 using v8::internal::byte;
53 using v8::internal::carry;
54 using v8::internal::greater;
55 using v8::internal::greater_equal;
56 using v8::internal::kIntSize;
57 using v8::internal::kPointerSize;
58 using v8::internal::kSmiTagMask;
59 using v8::internal::kSmiValueSize;
60 using v8::internal::less_equal;
61 using v8::internal::negative;
62 using v8::internal::not_carry;
63 using v8::internal::not_equal;
64 using v8::internal::not_zero;
65 using v8::internal::positive;
66 using v8::internal::r11;
67 using v8::internal::r13;
68 using v8::internal::r14;
69 using v8::internal::r15;
70 using v8::internal::r8;
71 using v8::internal::r9;
72 using v8::internal::rax;
73 using v8::internal::rbp;
74 using v8::internal::rbx;
75 using v8::internal::rcx;
76 using v8::internal::rdi;
77 using v8::internal::rdx;
78 using v8::internal::rsi;
79 using v8::internal::rsp;
80 using v8::internal::times_pointer_size;
81 39
82 // Test the x64 assembler by compiling some simple functions into 40 // Test the x64 assembler by compiling some simple functions into
83 // a buffer and executing them. These tests do not initialize the 41 // a buffer and executing them. These tests do not initialize the
84 // V8 library, create a context, or use any V8 objects. 42 // V8 library, create a context, or use any V8 objects.
85 // The AMD64 calling convention is used, with the first five arguments 43 // The AMD64 calling convention is used, with the first five arguments
86 // in RSI, RDI, RDX, RCX, R8, and R9, and floating point arguments in 44 // in RSI, RDI, RDX, RCX, R8, and R9, and floating point arguments in
87 // the XMM registers. The return value is in RAX. 45 // the XMM registers. The return value is in RAX.
88 // This calling convention is used on Linux, with GCC, and on Mac OS, 46 // This calling convention is used on Linux, with GCC, and on Mac OS,
89 // with GCC. A different convention is used on 64-bit windows. 47 // with GCC. A different convention is used on 64-bit windows.
90 48
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 __ cmpq(rcx, rdx); 104 __ cmpq(rcx, rdx);
147 __ j(not_equal, exit); 105 __ j(not_equal, exit);
148 } 106 }
149 107
150 108
151 // Test that we can move a Smi value literally into a register. 109 // Test that we can move a Smi value literally into a register.
152 TEST(SmiMove) { 110 TEST(SmiMove) {
153 v8::internal::V8::Initialize(NULL); 111 v8::internal::V8::Initialize(NULL);
154 // Allocate an executable page of memory. 112 // Allocate an executable page of memory.
155 size_t actual_size; 113 size_t actual_size;
156 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 114 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
157 &actual_size, 115 Assembler::kMinimalBufferSize,
158 true)); 116 &actual_size,
117 VirtualMemory::EXECUTABLE));
159 CHECK(buffer); 118 CHECK(buffer);
160 Isolate* isolate = Isolate::Current(); 119 Isolate* isolate = Isolate::Current();
161 HandleScope handles(isolate); 120 HandleScope handles(isolate);
162 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 121 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
163 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. 122 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro.
164 masm->set_allow_stub_calls(false); 123 masm->set_allow_stub_calls(false);
165 EntryCode(masm); 124 EntryCode(masm);
166 Label exit; 125 Label exit;
167 126
168 TestMoveSmi(masm, &exit, 1, Smi::FromInt(0)); 127 TestMoveSmi(masm, &exit, 1, Smi::FromInt(0));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 __ j(not_equal, exit); 193 __ j(not_equal, exit);
235 } 194 }
236 } 195 }
237 196
238 197
239 // Test that we can compare smis for equality (and more). 198 // Test that we can compare smis for equality (and more).
240 TEST(SmiCompare) { 199 TEST(SmiCompare) {
241 v8::internal::V8::Initialize(NULL); 200 v8::internal::V8::Initialize(NULL);
242 // Allocate an executable page of memory. 201 // Allocate an executable page of memory.
243 size_t actual_size; 202 size_t actual_size;
244 byte* buffer = 203 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
245 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 204 Assembler::kMinimalBufferSize * 2,
246 &actual_size, 205 &actual_size,
247 true)); 206 VirtualMemory::EXECUTABLE));
248 CHECK(buffer); 207 CHECK(buffer);
249 Isolate* isolate = Isolate::Current(); 208 Isolate* isolate = Isolate::Current();
250 HandleScope handles(isolate); 209 HandleScope handles(isolate);
251 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 210 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
252 211
253 MacroAssembler* masm = &assembler; 212 MacroAssembler* masm = &assembler;
254 masm->set_allow_stub_calls(false); 213 masm->set_allow_stub_calls(false);
255 EntryCode(masm); 214 EntryCode(masm);
256 Label exit; 215 Label exit;
257 216
(...skipping 28 matching lines...) Expand all
286 int result = FUNCTION_CAST<F0>(buffer)(); 245 int result = FUNCTION_CAST<F0>(buffer)();
287 CHECK_EQ(0, result); 246 CHECK_EQ(0, result);
288 } 247 }
289 248
290 249
291 250
292 TEST(Integer32ToSmi) { 251 TEST(Integer32ToSmi) {
293 v8::internal::V8::Initialize(NULL); 252 v8::internal::V8::Initialize(NULL);
294 // Allocate an executable page of memory. 253 // Allocate an executable page of memory.
295 size_t actual_size; 254 size_t actual_size;
296 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 255 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
297 &actual_size, 256 Assembler::kMinimalBufferSize,
298 true)); 257 &actual_size,
258 VirtualMemory::EXECUTABLE));
299 CHECK(buffer); 259 CHECK(buffer);
300 Isolate* isolate = Isolate::Current(); 260 Isolate* isolate = Isolate::Current();
301 HandleScope handles(isolate); 261 HandleScope handles(isolate);
302 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 262 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
303 263
304 MacroAssembler* masm = &assembler; 264 MacroAssembler* masm = &assembler;
305 masm->set_allow_stub_calls(false); 265 masm->set_allow_stub_calls(false);
306 EntryCode(masm); 266 EntryCode(masm);
307 Label exit; 267 Label exit;
308 268
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 __ Integer64PlusConstantToSmi(rcx, rcx, y); 375 __ Integer64PlusConstantToSmi(rcx, rcx, y);
416 __ cmpq(rcx, r8); 376 __ cmpq(rcx, r8);
417 __ j(not_equal, exit); 377 __ j(not_equal, exit);
418 } 378 }
419 379
420 380
421 TEST(Integer64PlusConstantToSmi) { 381 TEST(Integer64PlusConstantToSmi) {
422 v8::internal::V8::Initialize(NULL); 382 v8::internal::V8::Initialize(NULL);
423 // Allocate an executable page of memory. 383 // Allocate an executable page of memory.
424 size_t actual_size; 384 size_t actual_size;
425 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 385 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
426 &actual_size, 386 Assembler::kMinimalBufferSize,
427 true)); 387 &actual_size,
388 VirtualMemory::EXECUTABLE));
428 CHECK(buffer); 389 CHECK(buffer);
429 Isolate* isolate = Isolate::Current(); 390 Isolate* isolate = Isolate::Current();
430 HandleScope handles(isolate); 391 HandleScope handles(isolate);
431 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 392 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
432 393
433 MacroAssembler* masm = &assembler; 394 MacroAssembler* masm = &assembler;
434 masm->set_allow_stub_calls(false); 395 masm->set_allow_stub_calls(false);
435 EntryCode(masm); 396 EntryCode(masm);
436 Label exit; 397 Label exit;
437 398
(...skipping 22 matching lines...) Expand all
460 // Call the function from C++. 421 // Call the function from C++.
461 int result = FUNCTION_CAST<F0>(buffer)(); 422 int result = FUNCTION_CAST<F0>(buffer)();
462 CHECK_EQ(0, result); 423 CHECK_EQ(0, result);
463 } 424 }
464 425
465 426
466 TEST(SmiCheck) { 427 TEST(SmiCheck) {
467 v8::internal::V8::Initialize(NULL); 428 v8::internal::V8::Initialize(NULL);
468 // Allocate an executable page of memory. 429 // Allocate an executable page of memory.
469 size_t actual_size; 430 size_t actual_size;
470 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 431 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
471 &actual_size, 432 Assembler::kMinimalBufferSize,
472 true)); 433 &actual_size,
434 VirtualMemory::EXECUTABLE));
473 CHECK(buffer); 435 CHECK(buffer);
474 Isolate* isolate = Isolate::Current(); 436 Isolate* isolate = Isolate::Current();
475 HandleScope handles(isolate); 437 HandleScope handles(isolate);
476 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 438 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
477 439
478 MacroAssembler* masm = &assembler; 440 MacroAssembler* masm = &assembler;
479 masm->set_allow_stub_calls(false); 441 masm->set_allow_stub_calls(false);
480 EntryCode(masm); 442 EntryCode(masm);
481 Label exit; 443 Label exit;
482 Condition cond; 444 Condition cond;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 __ cmpq(rcx, r8); 670 __ cmpq(rcx, r8);
709 __ j(not_equal, exit); 671 __ j(not_equal, exit);
710 } 672 }
711 } 673 }
712 674
713 675
714 TEST(SmiNeg) { 676 TEST(SmiNeg) {
715 v8::internal::V8::Initialize(NULL); 677 v8::internal::V8::Initialize(NULL);
716 // Allocate an executable page of memory. 678 // Allocate an executable page of memory.
717 size_t actual_size; 679 size_t actual_size;
718 byte* buffer = 680 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
719 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 681 Assembler::kMinimalBufferSize,
720 &actual_size, 682 &actual_size,
721 true)); 683 VirtualMemory::EXECUTABLE));
722 CHECK(buffer); 684 CHECK(buffer);
723 Isolate* isolate = Isolate::Current(); 685 Isolate* isolate = Isolate::Current();
724 HandleScope handles(isolate); 686 HandleScope handles(isolate);
725 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 687 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
726 688
727 MacroAssembler* masm = &assembler; 689 MacroAssembler* masm = &assembler;
728 masm->set_allow_stub_calls(false); 690 masm->set_allow_stub_calls(false);
729 EntryCode(masm); 691 EntryCode(masm);
730 Label exit; 692 Label exit;
731 693
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), exit); 761 __ SmiAddConstant(rcx, rcx, Smi::FromInt(second), exit);
800 __ cmpq(rcx, r8); 762 __ cmpq(rcx, r8);
801 __ j(not_equal, exit); 763 __ j(not_equal, exit);
802 } 764 }
803 765
804 766
805 TEST(SmiAdd) { 767 TEST(SmiAdd) {
806 v8::internal::V8::Initialize(NULL); 768 v8::internal::V8::Initialize(NULL);
807 // Allocate an executable page of memory. 769 // Allocate an executable page of memory.
808 size_t actual_size; 770 size_t actual_size;
809 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 771 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
810 &actual_size, 772 Assembler::kMinimalBufferSize,
811 true)); 773 &actual_size,
774 VirtualMemory::EXECUTABLE));
812 CHECK(buffer); 775 CHECK(buffer);
813 Isolate* isolate = Isolate::Current(); 776 Isolate* isolate = Isolate::Current();
814 HandleScope handles(isolate); 777 HandleScope handles(isolate);
815 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 778 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
816 779
817 MacroAssembler* masm = &assembler; 780 MacroAssembler* masm = &assembler;
818 masm->set_allow_stub_calls(false); 781 masm->set_allow_stub_calls(false);
819 EntryCode(masm); 782 EntryCode(masm);
820 Label exit; 783 Label exit;
821 784
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 __ cmpq(rcx, r11); 952 __ cmpq(rcx, r11);
990 __ j(not_equal, exit); 953 __ j(not_equal, exit);
991 } 954 }
992 } 955 }
993 956
994 957
995 TEST(SmiSub) { 958 TEST(SmiSub) {
996 v8::internal::V8::Initialize(NULL); 959 v8::internal::V8::Initialize(NULL);
997 // Allocate an executable page of memory. 960 // Allocate an executable page of memory.
998 size_t actual_size; 961 size_t actual_size;
999 byte* buffer = 962 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
1000 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 963 Assembler::kMinimalBufferSize * 2,
1001 &actual_size, 964 &actual_size,
1002 true)); 965 VirtualMemory::EXECUTABLE));
1003 CHECK(buffer); 966 CHECK(buffer);
1004 Isolate* isolate = Isolate::Current(); 967 Isolate* isolate = Isolate::Current();
1005 HandleScope handles(isolate); 968 HandleScope handles(isolate);
1006 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 969 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
1007 970
1008 MacroAssembler* masm = &assembler; 971 MacroAssembler* masm = &assembler;
1009 masm->set_allow_stub_calls(false); 972 masm->set_allow_stub_calls(false);
1010 EntryCode(masm); 973 EntryCode(masm);
1011 Label exit; 974 Label exit;
1012 975
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 // __ cmpq(r11, rcx); 1044 // __ cmpq(r11, rcx);
1082 // __ j(not_equal, exit); 1045 // __ j(not_equal, exit);
1083 } 1046 }
1084 } 1047 }
1085 1048
1086 1049
1087 TEST(SmiMul) { 1050 TEST(SmiMul) {
1088 v8::internal::V8::Initialize(NULL); 1051 v8::internal::V8::Initialize(NULL);
1089 // Allocate an executable page of memory. 1052 // Allocate an executable page of memory.
1090 size_t actual_size; 1053 size_t actual_size;
1091 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1054 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
1092 &actual_size, 1055 Assembler::kMinimalBufferSize,
1093 true)); 1056 &actual_size,
1057 VirtualMemory::EXECUTABLE));
1094 CHECK(buffer); 1058 CHECK(buffer);
1095 Isolate* isolate = Isolate::Current(); 1059 Isolate* isolate = Isolate::Current();
1096 HandleScope handles(isolate); 1060 HandleScope handles(isolate);
1097 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 1061 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
1098 1062
1099 MacroAssembler* masm = &assembler; 1063 MacroAssembler* masm = &assembler;
1100 masm->set_allow_stub_calls(false); 1064 masm->set_allow_stub_calls(false);
1101 EntryCode(masm); 1065 EntryCode(masm);
1102 Label exit; 1066 Label exit;
1103 1067
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 __ cmpq(rcx, r11); 1151 __ cmpq(rcx, r11);
1188 __ j(not_equal, exit); 1152 __ j(not_equal, exit);
1189 } 1153 }
1190 } 1154 }
1191 1155
1192 1156
1193 TEST(SmiDiv) { 1157 TEST(SmiDiv) {
1194 v8::internal::V8::Initialize(NULL); 1158 v8::internal::V8::Initialize(NULL);
1195 // Allocate an executable page of memory. 1159 // Allocate an executable page of memory.
1196 size_t actual_size; 1160 size_t actual_size;
1197 byte* buffer = 1161 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
1198 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 1162 Assembler::kMinimalBufferSize * 2,
1199 &actual_size, 1163 &actual_size,
1200 true)); 1164 VirtualMemory::EXECUTABLE));
1201 CHECK(buffer); 1165 CHECK(buffer);
1202 Isolate* isolate = Isolate::Current(); 1166 Isolate* isolate = Isolate::Current();
1203 HandleScope handles(isolate); 1167 HandleScope handles(isolate);
1204 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 1168 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
1205 1169
1206 MacroAssembler* masm = &assembler; 1170 MacroAssembler* masm = &assembler;
1207 masm->set_allow_stub_calls(false); 1171 masm->set_allow_stub_calls(false);
1208 EntryCode(masm); 1172 EntryCode(masm);
1209 Label exit; 1173 Label exit;
1210 1174
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 __ cmpq(rcx, r11); 1262 __ cmpq(rcx, r11);
1299 __ j(not_equal, exit); 1263 __ j(not_equal, exit);
1300 } 1264 }
1301 } 1265 }
1302 1266
1303 1267
1304 TEST(SmiMod) { 1268 TEST(SmiMod) {
1305 v8::internal::V8::Initialize(NULL); 1269 v8::internal::V8::Initialize(NULL);
1306 // Allocate an executable page of memory. 1270 // Allocate an executable page of memory.
1307 size_t actual_size; 1271 size_t actual_size;
1308 byte* buffer = 1272 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
1309 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 1273 Assembler::kMinimalBufferSize * 2,
1310 &actual_size, 1274 &actual_size,
1311 true)); 1275 VirtualMemory::EXECUTABLE));
1312 CHECK(buffer); 1276 CHECK(buffer);
1313 Isolate* isolate = Isolate::Current(); 1277 Isolate* isolate = Isolate::Current();
1314 HandleScope handles(isolate); 1278 HandleScope handles(isolate);
1315 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 1279 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
1316 1280
1317 MacroAssembler* masm = &assembler; 1281 MacroAssembler* masm = &assembler;
1318 masm->set_allow_stub_calls(false); 1282 masm->set_allow_stub_calls(false);
1319 EntryCode(masm); 1283 EntryCode(masm);
1320 Label exit; 1284 Label exit;
1321 1285
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 __ j(not_equal, exit); 1360 __ j(not_equal, exit);
1397 __ incq(rax); 1361 __ incq(rax);
1398 } 1362 }
1399 } 1363 }
1400 1364
1401 1365
1402 TEST(SmiIndex) { 1366 TEST(SmiIndex) {
1403 v8::internal::V8::Initialize(NULL); 1367 v8::internal::V8::Initialize(NULL);
1404 // Allocate an executable page of memory. 1368 // Allocate an executable page of memory.
1405 size_t actual_size; 1369 size_t actual_size;
1406 byte* buffer = 1370 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
1407 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, 1371 Assembler::kMinimalBufferSize * 3,
1408 &actual_size, 1372 &actual_size,
1409 true)); 1373 VirtualMemory::EXECUTABLE));
1410 CHECK(buffer); 1374 CHECK(buffer);
1411 Isolate* isolate = Isolate::Current(); 1375 Isolate* isolate = Isolate::Current();
1412 HandleScope handles(isolate); 1376 HandleScope handles(isolate);
1413 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 1377 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
1414 1378
1415 MacroAssembler* masm = &assembler; 1379 MacroAssembler* masm = &assembler;
1416 masm->set_allow_stub_calls(false); 1380 masm->set_allow_stub_calls(false);
1417 EntryCode(masm); 1381 EntryCode(masm);
1418 Label exit; 1382 Label exit;
1419 1383
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 __ SelectNonSmi(r9, rcx, rdx, &fail_ok); 1430 __ SelectNonSmi(r9, rcx, rdx, &fail_ok);
1467 __ jmp(exit); 1431 __ jmp(exit);
1468 __ bind(&fail_ok); 1432 __ bind(&fail_ok);
1469 } 1433 }
1470 1434
1471 1435
1472 TEST(SmiSelectNonSmi) { 1436 TEST(SmiSelectNonSmi) {
1473 v8::internal::V8::Initialize(NULL); 1437 v8::internal::V8::Initialize(NULL);
1474 // Allocate an executable page of memory. 1438 // Allocate an executable page of memory.
1475 size_t actual_size; 1439 size_t actual_size;
1476 byte* buffer = 1440 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
1477 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1441 Assembler::kMinimalBufferSize,
1478 &actual_size, 1442 &actual_size,
1479 true)); 1443 VirtualMemory::EXECUTABLE));
1480 CHECK(buffer); 1444 CHECK(buffer);
1481 Isolate* isolate = Isolate::Current(); 1445 Isolate* isolate = Isolate::Current();
1482 HandleScope handles(isolate); 1446 HandleScope handles(isolate);
1483 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 1447 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
1484 1448
1485 MacroAssembler* masm = &assembler; 1449 MacroAssembler* masm = &assembler;
1486 masm->set_allow_stub_calls(false); // Avoid inline checks. 1450 masm->set_allow_stub_calls(false); // Avoid inline checks.
1487 EntryCode(masm); 1451 EntryCode(masm);
1488 Label exit; 1452 Label exit;
1489 1453
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y)); 1510 __ SmiAndConstant(rcx, rcx, Smi::FromInt(y));
1547 __ cmpq(r8, rcx); 1511 __ cmpq(r8, rcx);
1548 __ j(not_equal, exit); 1512 __ j(not_equal, exit);
1549 } 1513 }
1550 1514
1551 1515
1552 TEST(SmiAnd) { 1516 TEST(SmiAnd) {
1553 v8::internal::V8::Initialize(NULL); 1517 v8::internal::V8::Initialize(NULL);
1554 // Allocate an executable page of memory. 1518 // Allocate an executable page of memory.
1555 size_t actual_size; 1519 size_t actual_size;
1556 byte* buffer = 1520 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
1557 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1521 Assembler::kMinimalBufferSize,
1558 &actual_size, 1522 &actual_size,
1559 true)); 1523 VirtualMemory::EXECUTABLE));
1560 CHECK(buffer); 1524 CHECK(buffer);
1561 Isolate* isolate = Isolate::Current(); 1525 Isolate* isolate = Isolate::Current();
1562 HandleScope handles(isolate); 1526 HandleScope handles(isolate);
1563 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 1527 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
1564 1528
1565 MacroAssembler* masm = &assembler; 1529 MacroAssembler* masm = &assembler;
1566 masm->set_allow_stub_calls(false); 1530 masm->set_allow_stub_calls(false);
1567 EntryCode(masm); 1531 EntryCode(masm);
1568 Label exit; 1532 Label exit;
1569 1533
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y)); 1592 __ SmiOrConstant(rcx, rcx, Smi::FromInt(y));
1629 __ cmpq(r8, rcx); 1593 __ cmpq(r8, rcx);
1630 __ j(not_equal, exit); 1594 __ j(not_equal, exit);
1631 } 1595 }
1632 1596
1633 1597
1634 TEST(SmiOr) { 1598 TEST(SmiOr) {
1635 v8::internal::V8::Initialize(NULL); 1599 v8::internal::V8::Initialize(NULL);
1636 // Allocate an executable page of memory. 1600 // Allocate an executable page of memory.
1637 size_t actual_size; 1601 size_t actual_size;
1638 byte* buffer = 1602 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
1639 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1603 Assembler::kMinimalBufferSize,
1640 &actual_size, 1604 &actual_size,
1641 true)); 1605 VirtualMemory::EXECUTABLE));
1642 CHECK(buffer); 1606 CHECK(buffer);
1643 Isolate* isolate = Isolate::Current(); 1607 Isolate* isolate = Isolate::Current();
1644 HandleScope handles(isolate); 1608 HandleScope handles(isolate);
1645 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 1609 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
1646 1610
1647 MacroAssembler* masm = &assembler; 1611 MacroAssembler* masm = &assembler;
1648 masm->set_allow_stub_calls(false); 1612 masm->set_allow_stub_calls(false);
1649 EntryCode(masm); 1613 EntryCode(masm);
1650 Label exit; 1614 Label exit;
1651 1615
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y)); 1676 __ SmiXorConstant(rcx, rcx, Smi::FromInt(y));
1713 __ cmpq(r8, rcx); 1677 __ cmpq(r8, rcx);
1714 __ j(not_equal, exit); 1678 __ j(not_equal, exit);
1715 } 1679 }
1716 1680
1717 1681
1718 TEST(SmiXor) { 1682 TEST(SmiXor) {
1719 v8::internal::V8::Initialize(NULL); 1683 v8::internal::V8::Initialize(NULL);
1720 // Allocate an executable page of memory. 1684 // Allocate an executable page of memory.
1721 size_t actual_size; 1685 size_t actual_size;
1722 byte* buffer = 1686 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
1723 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1687 Assembler::kMinimalBufferSize,
1724 &actual_size, 1688 &actual_size,
1725 true)); 1689 VirtualMemory::EXECUTABLE));
1726 CHECK(buffer); 1690 CHECK(buffer);
1727 Isolate* isolate = Isolate::Current(); 1691 Isolate* isolate = Isolate::Current();
1728 HandleScope handles(isolate); 1692 HandleScope handles(isolate);
1729 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 1693 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
1730 1694
1731 MacroAssembler* masm = &assembler; 1695 MacroAssembler* masm = &assembler;
1732 masm->set_allow_stub_calls(false); 1696 masm->set_allow_stub_calls(false);
1733 EntryCode(masm); 1697 EntryCode(masm);
1734 Label exit; 1698 Label exit;
1735 1699
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 __ SmiNot(rcx, rcx); 1744 __ SmiNot(rcx, rcx);
1781 __ cmpq(rcx, r8); 1745 __ cmpq(rcx, r8);
1782 __ j(not_equal, exit); 1746 __ j(not_equal, exit);
1783 } 1747 }
1784 1748
1785 1749
1786 TEST(SmiNot) { 1750 TEST(SmiNot) {
1787 v8::internal::V8::Initialize(NULL); 1751 v8::internal::V8::Initialize(NULL);
1788 // Allocate an executable page of memory. 1752 // Allocate an executable page of memory.
1789 size_t actual_size; 1753 size_t actual_size;
1790 byte* buffer = 1754 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
1791 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, 1755 Assembler::kMinimalBufferSize,
1792 &actual_size, 1756 &actual_size,
1793 true)); 1757 VirtualMemory::EXECUTABLE));
1794 CHECK(buffer); 1758 CHECK(buffer);
1795 Isolate* isolate = Isolate::Current(); 1759 Isolate* isolate = Isolate::Current();
1796 HandleScope handles(isolate); 1760 HandleScope handles(isolate);
1797 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 1761 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
1798 1762
1799 MacroAssembler* masm = &assembler; 1763 MacroAssembler* masm = &assembler;
1800 masm->set_allow_stub_calls(false); 1764 masm->set_allow_stub_calls(false);
1801 EntryCode(masm); 1765 EntryCode(masm);
1802 Label exit; 1766 Label exit;
1803 1767
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 1841
1878 __ incq(rax); 1842 __ incq(rax);
1879 } 1843 }
1880 } 1844 }
1881 1845
1882 1846
1883 TEST(SmiShiftLeft) { 1847 TEST(SmiShiftLeft) {
1884 v8::internal::V8::Initialize(NULL); 1848 v8::internal::V8::Initialize(NULL);
1885 // Allocate an executable page of memory. 1849 // Allocate an executable page of memory.
1886 size_t actual_size; 1850 size_t actual_size;
1887 byte* buffer = 1851 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
1888 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, 1852 Assembler::kMinimalBufferSize * 4,
1889 &actual_size, 1853 &actual_size,
1890 true)); 1854 VirtualMemory::EXECUTABLE));
1891 CHECK(buffer); 1855 CHECK(buffer);
1892 Isolate* isolate = Isolate::Current(); 1856 Isolate* isolate = Isolate::Current();
1893 HandleScope handles(isolate); 1857 HandleScope handles(isolate);
1894 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 1858 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
1895 1859
1896 MacroAssembler* masm = &assembler; 1860 MacroAssembler* masm = &assembler;
1897 masm->set_allow_stub_calls(false); 1861 masm->set_allow_stub_calls(false);
1898 EntryCode(masm); 1862 EntryCode(masm);
1899 Label exit; 1863 Label exit;
1900 1864
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 __ addq(rax, Immediate(3)); 1948 __ addq(rax, Immediate(3));
1985 } 1949 }
1986 } 1950 }
1987 } 1951 }
1988 1952
1989 1953
1990 TEST(SmiShiftLogicalRight) { 1954 TEST(SmiShiftLogicalRight) {
1991 v8::internal::V8::Initialize(NULL); 1955 v8::internal::V8::Initialize(NULL);
1992 // Allocate an executable page of memory. 1956 // Allocate an executable page of memory.
1993 size_t actual_size; 1957 size_t actual_size;
1994 byte* buffer = 1958 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
1995 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, 1959 Assembler::kMinimalBufferSize * 3,
1996 &actual_size, 1960 &actual_size,
1997 true)); 1961 VirtualMemory::EXECUTABLE));
1998 CHECK(buffer); 1962 CHECK(buffer);
1999 Isolate* isolate = Isolate::Current(); 1963 Isolate* isolate = Isolate::Current();
2000 HandleScope handles(isolate); 1964 HandleScope handles(isolate);
2001 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 1965 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
2002 1966
2003 MacroAssembler* masm = &assembler; 1967 MacroAssembler* masm = &assembler;
2004 masm->set_allow_stub_calls(false); 1968 masm->set_allow_stub_calls(false);
2005 EntryCode(masm); 1969 EntryCode(masm);
2006 Label exit; 1970 Label exit;
2007 1971
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 2018
2055 __ incq(rax); 2019 __ incq(rax);
2056 } 2020 }
2057 } 2021 }
2058 2022
2059 2023
2060 TEST(SmiShiftArithmeticRight) { 2024 TEST(SmiShiftArithmeticRight) {
2061 v8::internal::V8::Initialize(NULL); 2025 v8::internal::V8::Initialize(NULL);
2062 // Allocate an executable page of memory. 2026 // Allocate an executable page of memory.
2063 size_t actual_size; 2027 size_t actual_size;
2064 byte* buffer = 2028 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
2065 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 2029 Assembler::kMinimalBufferSize * 2,
2066 &actual_size, 2030 &actual_size,
2067 true)); 2031 VirtualMemory::EXECUTABLE));
2068 CHECK(buffer); 2032 CHECK(buffer);
2069 Isolate* isolate = Isolate::Current(); 2033 Isolate* isolate = Isolate::Current();
2070 HandleScope handles(isolate); 2034 HandleScope handles(isolate);
2071 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 2035 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
2072 2036
2073 MacroAssembler* masm = &assembler; 2037 MacroAssembler* masm = &assembler;
2074 masm->set_allow_stub_calls(false); 2038 masm->set_allow_stub_calls(false);
2075 EntryCode(masm); 2039 EntryCode(masm);
2076 Label exit; 2040 Label exit;
2077 2041
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 __ j(not_equal, exit); 2083 __ j(not_equal, exit);
2120 __ incq(rax); 2084 __ incq(rax);
2121 } 2085 }
2122 } 2086 }
2123 2087
2124 2088
2125 TEST(PositiveSmiTimesPowerOfTwoToInteger64) { 2089 TEST(PositiveSmiTimesPowerOfTwoToInteger64) {
2126 v8::internal::V8::Initialize(NULL); 2090 v8::internal::V8::Initialize(NULL);
2127 // Allocate an executable page of memory. 2091 // Allocate an executable page of memory.
2128 size_t actual_size; 2092 size_t actual_size;
2129 byte* buffer = 2093 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
2130 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 4, 2094 Assembler::kMinimalBufferSize * 4,
2131 &actual_size, 2095 &actual_size,
2132 true)); 2096 VirtualMemory::EXECUTABLE));
2133 CHECK(buffer); 2097 CHECK(buffer);
2134 Isolate* isolate = Isolate::Current(); 2098 Isolate* isolate = Isolate::Current();
2135 HandleScope handles(isolate); 2099 HandleScope handles(isolate);
2136 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 2100 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
2137 2101
2138 MacroAssembler* masm = &assembler; 2102 MacroAssembler* masm = &assembler;
2139 masm->set_allow_stub_calls(false); 2103 masm->set_allow_stub_calls(false);
2140 EntryCode(masm); 2104 EntryCode(masm);
2141 Label exit; 2105 Label exit;
2142 2106
(...skipping 20 matching lines...) Expand all
2163 } 2127 }
2164 2128
2165 2129
2166 TEST(OperandOffset) { 2130 TEST(OperandOffset) {
2167 v8::internal::V8::Initialize(NULL); 2131 v8::internal::V8::Initialize(NULL);
2168 int data[256]; 2132 int data[256];
2169 for (int i = 0; i < 256; i++) { data[i] = i * 0x01010101; } 2133 for (int i = 0; i < 256; i++) { data[i] = i * 0x01010101; }
2170 2134
2171 // Allocate an executable page of memory. 2135 // Allocate an executable page of memory.
2172 size_t actual_size; 2136 size_t actual_size;
2173 byte* buffer = 2137 byte* buffer = static_cast<byte*>(VirtualMemory::AllocateRegion(
2174 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 2, 2138 Assembler::kMinimalBufferSize * 2,
2175 &actual_size, 2139 &actual_size,
2176 true)); 2140 VirtualMemory::EXECUTABLE));
2177 CHECK(buffer); 2141 CHECK(buffer);
2178 Isolate* isolate = Isolate::Current(); 2142 Isolate* isolate = Isolate::Current();
2179 HandleScope handles(isolate); 2143 HandleScope handles(isolate);
2180 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); 2144 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size));
2181 2145
2182 MacroAssembler* masm = &assembler; 2146 MacroAssembler* masm = &assembler;
2183 masm->set_allow_stub_calls(false); 2147 masm->set_allow_stub_calls(false);
2184 Label exit; 2148 Label exit;
2185 2149
2186 EntryCode(masm); 2150 EntryCode(masm);
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 CodeDesc desc; 2479 CodeDesc desc;
2516 masm->GetCode(&desc); 2480 masm->GetCode(&desc);
2517 // Call the function from C++. 2481 // Call the function from C++.
2518 int result = FUNCTION_CAST<F0>(buffer)(); 2482 int result = FUNCTION_CAST<F0>(buffer)();
2519 CHECK_EQ(0, result); 2483 CHECK_EQ(0, result);
2520 } 2484 }
2521 2485
2522 2486
2523 2487
2524 #undef __ 2488 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-code-stubs-x64.cc ('k') | test/cctest/test-platform-linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698