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

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

Issue 2900683002: [compiler] Delay allocation of code-embedded heap numbers. (Closed)
Patch Set: Fix rebase. Created 3 years, 6 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
« no previous file with comments | « test/cctest/test-assembler-mips64.cc ('k') | test/cctest/test-code-stubs-arm.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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 Assembler::kMinimalBufferSize, &actual_size, true)); 77 Assembler::kMinimalBufferSize, &actual_size, true));
78 CHECK(buffer); 78 CHECK(buffer);
79 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 79 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
80 80
81 // Assemble a simple function that copies argument 2 and returns it. 81 // Assemble a simple function that copies argument 2 and returns it.
82 __ movq(rax, arg2); 82 __ movq(rax, arg2);
83 __ nop(); 83 __ nop();
84 __ ret(0); 84 __ ret(0);
85 85
86 CodeDesc desc; 86 CodeDesc desc;
87 assm.GetCode(&desc); 87 assm.GetCode(CcTest::i_isolate(), &desc);
88 // Call the function from C++. 88 // Call the function from C++.
89 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 89 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
90 CHECK_EQ(2, result); 90 CHECK_EQ(2, result);
91 } 91 }
92 92
93 93
94 TEST(AssemblerX64StackOperations) { 94 TEST(AssemblerX64StackOperations) {
95 CcTest::InitializeVM(); 95 CcTest::InitializeVM();
96 // Allocate an executable page of memory. 96 // Allocate an executable page of memory.
97 size_t actual_size; 97 size_t actual_size;
(...skipping 11 matching lines...) Expand all
109 __ pushq(arg2); // Value at (rbp - 16) 109 __ pushq(arg2); // Value at (rbp - 16)
110 __ pushq(arg1); // Value at (rbp - 24) 110 __ pushq(arg1); // Value at (rbp - 24)
111 __ popq(rax); 111 __ popq(rax);
112 __ popq(rax); 112 __ popq(rax);
113 __ popq(rax); 113 __ popq(rax);
114 __ popq(rbp); 114 __ popq(rbp);
115 __ nop(); 115 __ nop();
116 __ ret(0); 116 __ ret(0);
117 117
118 CodeDesc desc; 118 CodeDesc desc;
119 assm.GetCode(&desc); 119 assm.GetCode(CcTest::i_isolate(), &desc);
120 // Call the function from C++. 120 // Call the function from C++.
121 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 121 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
122 CHECK_EQ(2, result); 122 CHECK_EQ(2, result);
123 } 123 }
124 124
125 125
126 TEST(AssemblerX64ArithmeticOperations) { 126 TEST(AssemblerX64ArithmeticOperations) {
127 CcTest::InitializeVM(); 127 CcTest::InitializeVM();
128 // Allocate an executable page of memory. 128 // Allocate an executable page of memory.
129 size_t actual_size; 129 size_t actual_size;
130 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( 130 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
131 Assembler::kMinimalBufferSize, &actual_size, true)); 131 Assembler::kMinimalBufferSize, &actual_size, true));
132 CHECK(buffer); 132 CHECK(buffer);
133 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 133 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
134 134
135 // Assemble a simple function that adds arguments returning the sum. 135 // Assemble a simple function that adds arguments returning the sum.
136 __ movq(rax, arg2); 136 __ movq(rax, arg2);
137 __ addq(rax, arg1); 137 __ addq(rax, arg1);
138 __ ret(0); 138 __ ret(0);
139 139
140 CodeDesc desc; 140 CodeDesc desc;
141 assm.GetCode(&desc); 141 assm.GetCode(CcTest::i_isolate(), &desc);
142 // Call the function from C++. 142 // Call the function from C++.
143 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 143 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
144 CHECK_EQ(5, result); 144 CHECK_EQ(5, result);
145 } 145 }
146 146
147 147
148 TEST(AssemblerX64CmpbOperation) { 148 TEST(AssemblerX64CmpbOperation) {
149 CcTest::InitializeVM(); 149 CcTest::InitializeVM();
150 // Allocate an executable page of memory. 150 // Allocate an executable page of memory.
151 size_t actual_size; 151 size_t actual_size;
152 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( 152 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
153 Assembler::kMinimalBufferSize, &actual_size, true)); 153 Assembler::kMinimalBufferSize, &actual_size, true));
154 CHECK(buffer); 154 CHECK(buffer);
155 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 155 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
156 156
157 // Assemble a function that compare argument byte returing 1 if equal else 0. 157 // Assemble a function that compare argument byte returing 1 if equal else 0.
158 // On Windows, it compares rcx with rdx which does not require REX prefix; 158 // On Windows, it compares rcx with rdx which does not require REX prefix;
159 // on Linux, it compares rdi with rsi which requires REX prefix. 159 // on Linux, it compares rdi with rsi which requires REX prefix.
160 160
161 Label done; 161 Label done;
162 __ movq(rax, Immediate(1)); 162 __ movq(rax, Immediate(1));
163 __ cmpb(arg1, arg2); 163 __ cmpb(arg1, arg2);
164 __ j(equal, &done); 164 __ j(equal, &done);
165 __ movq(rax, Immediate(0)); 165 __ movq(rax, Immediate(0));
166 __ bind(&done); 166 __ bind(&done);
167 __ ret(0); 167 __ ret(0);
168 168
169 CodeDesc desc; 169 CodeDesc desc;
170 assm.GetCode(&desc); 170 assm.GetCode(CcTest::i_isolate(), &desc);
171 // Call the function from C++. 171 // Call the function from C++.
172 int result = FUNCTION_CAST<F2>(buffer)(0x1002, 0x2002); 172 int result = FUNCTION_CAST<F2>(buffer)(0x1002, 0x2002);
173 CHECK_EQ(1, result); 173 CHECK_EQ(1, result);
174 result = FUNCTION_CAST<F2>(buffer)(0x1002, 0x2003); 174 result = FUNCTION_CAST<F2>(buffer)(0x1002, 0x2003);
175 CHECK_EQ(0, result); 175 CHECK_EQ(0, result);
176 } 176 }
177 177
178 TEST(Regression684407) { 178 TEST(Regression684407) {
179 CcTest::InitializeVM(); 179 CcTest::InitializeVM();
180 // Allocate an executable page of memory. 180 // Allocate an executable page of memory.
(...skipping 21 matching lines...) Expand all
202 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 202 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
203 203
204 // Assemble a simple function that multiplies arguments returning the high 204 // Assemble a simple function that multiplies arguments returning the high
205 // word. 205 // word.
206 __ movq(rax, arg2); 206 __ movq(rax, arg2);
207 __ imulq(arg1); 207 __ imulq(arg1);
208 __ movq(rax, rdx); 208 __ movq(rax, rdx);
209 __ ret(0); 209 __ ret(0);
210 210
211 CodeDesc desc; 211 CodeDesc desc;
212 assm.GetCode(&desc); 212 assm.GetCode(CcTest::i_isolate(), &desc);
213 // Call the function from C++. 213 // Call the function from C++.
214 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 214 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
215 CHECK_EQ(0, result); 215 CHECK_EQ(0, result);
216 result = FUNCTION_CAST<F2>(buffer)(0x100000000l, 0x100000000l); 216 result = FUNCTION_CAST<F2>(buffer)(0x100000000l, 0x100000000l);
217 CHECK_EQ(1, result); 217 CHECK_EQ(1, result);
218 result = FUNCTION_CAST<F2>(buffer)(-0x100000000l, 0x100000000l); 218 result = FUNCTION_CAST<F2>(buffer)(-0x100000000l, 0x100000000l);
219 CHECK_EQ(-1, result); 219 CHECK_EQ(-1, result);
220 } 220 }
221 221
222 TEST(AssemblerX64testbwqOperation) { 222 TEST(AssemblerX64testbwqOperation) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 __ popq(r14); 374 __ popq(r14);
375 __ popq(r13); 375 __ popq(r13);
376 __ popq(r12); 376 __ popq(r12);
377 __ popq(rsi); 377 __ popq(rsi);
378 __ popq(rdi); 378 __ popq(rdi);
379 __ popq(rbx); 379 __ popq(rbx);
380 380
381 __ ret(0); 381 __ ret(0);
382 382
383 CodeDesc desc; 383 CodeDesc desc;
384 assm.GetCode(&desc); 384 assm.GetCode(CcTest::i_isolate(), &desc);
385 // Call the function from C++. 385 // Call the function from C++.
386 int result = FUNCTION_CAST<F2>(buffer)(0, 0); 386 int result = FUNCTION_CAST<F2>(buffer)(0, 0);
387 CHECK_EQ(1, result); 387 CHECK_EQ(1, result);
388 } 388 }
389 389
390 TEST(AssemblerX64XchglOperations) { 390 TEST(AssemblerX64XchglOperations) {
391 CcTest::InitializeVM(); 391 CcTest::InitializeVM();
392 // Allocate an executable page of memory. 392 // Allocate an executable page of memory.
393 size_t actual_size; 393 size_t actual_size;
394 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( 394 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
395 Assembler::kMinimalBufferSize, &actual_size, true)); 395 Assembler::kMinimalBufferSize, &actual_size, true));
396 CHECK(buffer); 396 CHECK(buffer);
397 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 397 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
398 398
399 __ movq(rax, Operand(arg1, 0)); 399 __ movq(rax, Operand(arg1, 0));
400 __ movq(r11, Operand(arg2, 0)); 400 __ movq(r11, Operand(arg2, 0));
401 __ xchgl(rax, r11); 401 __ xchgl(rax, r11);
402 __ movq(Operand(arg1, 0), rax); 402 __ movq(Operand(arg1, 0), rax);
403 __ movq(Operand(arg2, 0), r11); 403 __ movq(Operand(arg2, 0), r11);
404 __ ret(0); 404 __ ret(0);
405 405
406 CodeDesc desc; 406 CodeDesc desc;
407 assm.GetCode(&desc); 407 assm.GetCode(CcTest::i_isolate(), &desc);
408 // Call the function from C++. 408 // Call the function from C++.
409 uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000); 409 uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000);
410 uint64_t right = V8_2PART_UINT64_C(0x30000000, 40000000); 410 uint64_t right = V8_2PART_UINT64_C(0x30000000, 40000000);
411 uint64_t result = FUNCTION_CAST<F4>(buffer)(&left, &right); 411 uint64_t result = FUNCTION_CAST<F4>(buffer)(&left, &right);
412 CHECK_EQ(V8_2PART_UINT64_C(0x00000000, 40000000), left); 412 CHECK_EQ(V8_2PART_UINT64_C(0x00000000, 40000000), left);
413 CHECK_EQ(V8_2PART_UINT64_C(0x00000000, 20000000), right); 413 CHECK_EQ(V8_2PART_UINT64_C(0x00000000, 20000000), right);
414 USE(result); 414 USE(result);
415 } 415 }
416 416
417 417
418 TEST(AssemblerX64OrlOperations) { 418 TEST(AssemblerX64OrlOperations) {
419 CcTest::InitializeVM(); 419 CcTest::InitializeVM();
420 // Allocate an executable page of memory. 420 // Allocate an executable page of memory.
421 size_t actual_size; 421 size_t actual_size;
422 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( 422 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
423 Assembler::kMinimalBufferSize, &actual_size, true)); 423 Assembler::kMinimalBufferSize, &actual_size, true));
424 CHECK(buffer); 424 CHECK(buffer);
425 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 425 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
426 426
427 __ movq(rax, Operand(arg2, 0)); 427 __ movq(rax, Operand(arg2, 0));
428 __ orl(Operand(arg1, 0), rax); 428 __ orl(Operand(arg1, 0), rax);
429 __ ret(0); 429 __ ret(0);
430 430
431 CodeDesc desc; 431 CodeDesc desc;
432 assm.GetCode(&desc); 432 assm.GetCode(CcTest::i_isolate(), &desc);
433 // Call the function from C++. 433 // Call the function from C++.
434 uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000); 434 uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000);
435 uint64_t right = V8_2PART_UINT64_C(0x30000000, 40000000); 435 uint64_t right = V8_2PART_UINT64_C(0x30000000, 40000000);
436 uint64_t result = FUNCTION_CAST<F4>(buffer)(&left, &right); 436 uint64_t result = FUNCTION_CAST<F4>(buffer)(&left, &right);
437 CHECK_EQ(V8_2PART_UINT64_C(0x10000000, 60000000), left); 437 CHECK_EQ(V8_2PART_UINT64_C(0x10000000, 60000000), left);
438 USE(result); 438 USE(result);
439 } 439 }
440 440
441 441
442 TEST(AssemblerX64RollOperations) { 442 TEST(AssemblerX64RollOperations) {
443 CcTest::InitializeVM(); 443 CcTest::InitializeVM();
444 // Allocate an executable page of memory. 444 // Allocate an executable page of memory.
445 size_t actual_size; 445 size_t actual_size;
446 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( 446 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
447 Assembler::kMinimalBufferSize, &actual_size, true)); 447 Assembler::kMinimalBufferSize, &actual_size, true));
448 CHECK(buffer); 448 CHECK(buffer);
449 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 449 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
450 450
451 __ movq(rax, arg1); 451 __ movq(rax, arg1);
452 __ roll(rax, Immediate(1)); 452 __ roll(rax, Immediate(1));
453 __ ret(0); 453 __ ret(0);
454 454
455 CodeDesc desc; 455 CodeDesc desc;
456 assm.GetCode(&desc); 456 assm.GetCode(CcTest::i_isolate(), &desc);
457 // Call the function from C++. 457 // Call the function from C++.
458 uint64_t src = V8_2PART_UINT64_C(0x10000000, C0000000); 458 uint64_t src = V8_2PART_UINT64_C(0x10000000, C0000000);
459 uint64_t result = FUNCTION_CAST<F5>(buffer)(src); 459 uint64_t result = FUNCTION_CAST<F5>(buffer)(src);
460 CHECK_EQ(V8_2PART_UINT64_C(0x00000000, 80000001), result); 460 CHECK_EQ(V8_2PART_UINT64_C(0x00000000, 80000001), result);
461 } 461 }
462 462
463 463
464 TEST(AssemblerX64SublOperations) { 464 TEST(AssemblerX64SublOperations) {
465 CcTest::InitializeVM(); 465 CcTest::InitializeVM();
466 // Allocate an executable page of memory. 466 // Allocate an executable page of memory.
467 size_t actual_size; 467 size_t actual_size;
468 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( 468 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
469 Assembler::kMinimalBufferSize, &actual_size, true)); 469 Assembler::kMinimalBufferSize, &actual_size, true));
470 CHECK(buffer); 470 CHECK(buffer);
471 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 471 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
472 472
473 __ movq(rax, Operand(arg2, 0)); 473 __ movq(rax, Operand(arg2, 0));
474 __ subl(Operand(arg1, 0), rax); 474 __ subl(Operand(arg1, 0), rax);
475 __ ret(0); 475 __ ret(0);
476 476
477 CodeDesc desc; 477 CodeDesc desc;
478 assm.GetCode(&desc); 478 assm.GetCode(CcTest::i_isolate(), &desc);
479 // Call the function from C++. 479 // Call the function from C++.
480 uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000); 480 uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000);
481 uint64_t right = V8_2PART_UINT64_C(0x30000000, 40000000); 481 uint64_t right = V8_2PART_UINT64_C(0x30000000, 40000000);
482 uint64_t result = FUNCTION_CAST<F4>(buffer)(&left, &right); 482 uint64_t result = FUNCTION_CAST<F4>(buffer)(&left, &right);
483 CHECK_EQ(V8_2PART_UINT64_C(0x10000000, e0000000), left); 483 CHECK_EQ(V8_2PART_UINT64_C(0x10000000, e0000000), left);
484 USE(result); 484 USE(result);
485 } 485 }
486 486
487 487
488 TEST(AssemblerX64TestlOperations) { 488 TEST(AssemblerX64TestlOperations) {
489 CcTest::InitializeVM(); 489 CcTest::InitializeVM();
490 // Allocate an executable page of memory. 490 // Allocate an executable page of memory.
491 size_t actual_size; 491 size_t actual_size;
492 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( 492 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
493 Assembler::kMinimalBufferSize, &actual_size, true)); 493 Assembler::kMinimalBufferSize, &actual_size, true));
494 CHECK(buffer); 494 CHECK(buffer);
495 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 495 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
496 496
497 // Set rax with the ZF flag of the testl instruction. 497 // Set rax with the ZF flag of the testl instruction.
498 Label done; 498 Label done;
499 __ movq(rax, Immediate(1)); 499 __ movq(rax, Immediate(1));
500 __ movq(r11, Operand(arg2, 0)); 500 __ movq(r11, Operand(arg2, 0));
501 __ testl(Operand(arg1, 0), r11); 501 __ testl(Operand(arg1, 0), r11);
502 __ j(zero, &done, Label::kNear); 502 __ j(zero, &done, Label::kNear);
503 __ movq(rax, Immediate(0)); 503 __ movq(rax, Immediate(0));
504 __ bind(&done); 504 __ bind(&done);
505 __ ret(0); 505 __ ret(0);
506 506
507 CodeDesc desc; 507 CodeDesc desc;
508 assm.GetCode(&desc); 508 assm.GetCode(CcTest::i_isolate(), &desc);
509 // Call the function from C++. 509 // Call the function from C++.
510 uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000); 510 uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000);
511 uint64_t right = V8_2PART_UINT64_C(0x30000000, 00000000); 511 uint64_t right = V8_2PART_UINT64_C(0x30000000, 00000000);
512 uint64_t result = FUNCTION_CAST<F4>(buffer)(&left, &right); 512 uint64_t result = FUNCTION_CAST<F4>(buffer)(&left, &right);
513 CHECK_EQ(1u, result); 513 CHECK_EQ(1u, result);
514 } 514 }
515 515
516 TEST(AssemblerX64TestwOperations) { 516 TEST(AssemblerX64TestwOperations) {
517 typedef uint16_t (*F)(uint16_t * x); 517 typedef uint16_t (*F)(uint16_t * x);
518 CcTest::InitializeVM(); 518 CcTest::InitializeVM();
519 // Allocate an executable page of memory. 519 // Allocate an executable page of memory.
520 size_t actual_size; 520 size_t actual_size;
521 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( 521 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
522 Assembler::kMinimalBufferSize, &actual_size, true)); 522 Assembler::kMinimalBufferSize, &actual_size, true));
523 CHECK(buffer); 523 CHECK(buffer);
524 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 524 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
525 525
526 // Set rax with the ZF flag of the testl instruction. 526 // Set rax with the ZF flag of the testl instruction.
527 Label done; 527 Label done;
528 __ movq(rax, Immediate(1)); 528 __ movq(rax, Immediate(1));
529 __ testw(Operand(arg1, 0), Immediate(0xf0f0)); 529 __ testw(Operand(arg1, 0), Immediate(0xf0f0));
530 __ j(not_zero, &done, Label::kNear); 530 __ j(not_zero, &done, Label::kNear);
531 __ movq(rax, Immediate(0)); 531 __ movq(rax, Immediate(0));
532 __ bind(&done); 532 __ bind(&done);
533 __ ret(0); 533 __ ret(0);
534 534
535 CodeDesc desc; 535 CodeDesc desc;
536 assm.GetCode(&desc); 536 assm.GetCode(CcTest::i_isolate(), &desc);
537 // Call the function from C++. 537 // Call the function from C++.
538 uint16_t operand = 0x8000; 538 uint16_t operand = 0x8000;
539 uint16_t result = FUNCTION_CAST<F>(buffer)(&operand); 539 uint16_t result = FUNCTION_CAST<F>(buffer)(&operand);
540 CHECK_EQ(1u, result); 540 CHECK_EQ(1u, result);
541 } 541 }
542 542
543 TEST(AssemblerX64XorlOperations) { 543 TEST(AssemblerX64XorlOperations) {
544 CcTest::InitializeVM(); 544 CcTest::InitializeVM();
545 // Allocate an executable page of memory. 545 // Allocate an executable page of memory.
546 size_t actual_size; 546 size_t actual_size;
547 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( 547 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
548 Assembler::kMinimalBufferSize, &actual_size, true)); 548 Assembler::kMinimalBufferSize, &actual_size, true));
549 CHECK(buffer); 549 CHECK(buffer);
550 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 550 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
551 551
552 __ movq(rax, Operand(arg2, 0)); 552 __ movq(rax, Operand(arg2, 0));
553 __ xorl(Operand(arg1, 0), rax); 553 __ xorl(Operand(arg1, 0), rax);
554 __ ret(0); 554 __ ret(0);
555 555
556 CodeDesc desc; 556 CodeDesc desc;
557 assm.GetCode(&desc); 557 assm.GetCode(CcTest::i_isolate(), &desc);
558 // Call the function from C++. 558 // Call the function from C++.
559 uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000); 559 uint64_t left = V8_2PART_UINT64_C(0x10000000, 20000000);
560 uint64_t right = V8_2PART_UINT64_C(0x30000000, 60000000); 560 uint64_t right = V8_2PART_UINT64_C(0x30000000, 60000000);
561 uint64_t result = FUNCTION_CAST<F4>(buffer)(&left, &right); 561 uint64_t result = FUNCTION_CAST<F4>(buffer)(&left, &right);
562 CHECK_EQ(V8_2PART_UINT64_C(0x10000000, 40000000), left); 562 CHECK_EQ(V8_2PART_UINT64_C(0x10000000, 40000000), left);
563 USE(result); 563 USE(result);
564 } 564 }
565 565
566 566
567 TEST(AssemblerX64MemoryOperands) { 567 TEST(AssemblerX64MemoryOperands) {
(...skipping 16 matching lines...) Expand all
584 const int kStackElementSize = 8; 584 const int kStackElementSize = 8;
585 __ movq(rax, Operand(rbp, -3 * kStackElementSize)); 585 __ movq(rax, Operand(rbp, -3 * kStackElementSize));
586 __ popq(arg2); 586 __ popq(arg2);
587 __ popq(arg2); 587 __ popq(arg2);
588 __ popq(arg2); 588 __ popq(arg2);
589 __ popq(rbp); 589 __ popq(rbp);
590 __ nop(); 590 __ nop();
591 __ ret(0); 591 __ ret(0);
592 592
593 CodeDesc desc; 593 CodeDesc desc;
594 assm.GetCode(&desc); 594 assm.GetCode(CcTest::i_isolate(), &desc);
595 // Call the function from C++. 595 // Call the function from C++.
596 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 596 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
597 CHECK_EQ(3, result); 597 CHECK_EQ(3, result);
598 } 598 }
599 599
600 600
601 TEST(AssemblerX64ControlFlow) { 601 TEST(AssemblerX64ControlFlow) {
602 CcTest::InitializeVM(); 602 CcTest::InitializeVM();
603 // Allocate an executable page of memory. 603 // Allocate an executable page of memory.
604 size_t actual_size; 604 size_t actual_size;
605 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( 605 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
606 Assembler::kMinimalBufferSize, &actual_size, true)); 606 Assembler::kMinimalBufferSize, &actual_size, true));
607 CHECK(buffer); 607 CHECK(buffer);
608 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 608 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
609 609
610 // Assemble a simple function that copies argument 1 and returns it. 610 // Assemble a simple function that copies argument 1 and returns it.
611 __ pushq(rbp); 611 __ pushq(rbp);
612 612
613 __ movq(rbp, rsp); 613 __ movq(rbp, rsp);
614 __ movq(rax, arg1); 614 __ movq(rax, arg1);
615 Label target; 615 Label target;
616 __ jmp(&target); 616 __ jmp(&target);
617 __ movq(rax, arg2); 617 __ movq(rax, arg2);
618 __ bind(&target); 618 __ bind(&target);
619 __ popq(rbp); 619 __ popq(rbp);
620 __ ret(0); 620 __ ret(0);
621 621
622 CodeDesc desc; 622 CodeDesc desc;
623 assm.GetCode(&desc); 623 assm.GetCode(CcTest::i_isolate(), &desc);
624 // Call the function from C++. 624 // Call the function from C++.
625 int result = FUNCTION_CAST<F2>(buffer)(3, 2); 625 int result = FUNCTION_CAST<F2>(buffer)(3, 2);
626 CHECK_EQ(3, result); 626 CHECK_EQ(3, result);
627 } 627 }
628 628
629 629
630 TEST(AssemblerX64LoopImmediates) { 630 TEST(AssemblerX64LoopImmediates) {
631 CcTest::InitializeVM(); 631 CcTest::InitializeVM();
632 // Allocate an executable page of memory. 632 // Allocate an executable page of memory.
633 size_t actual_size; 633 size_t actual_size;
(...skipping 29 matching lines...) Expand all
663 __ cmpq(rax, Immediate(0x11FE7600)); 663 __ cmpq(rax, Immediate(0x11FE7600));
664 __ j(not_equal, &Fail); 664 __ j(not_equal, &Fail);
665 665
666 __ movq(rax, Immediate(1)); 666 __ movq(rax, Immediate(1));
667 __ ret(0); 667 __ ret(0);
668 __ bind(&Fail); 668 __ bind(&Fail);
669 __ movq(rax, Immediate(0)); 669 __ movq(rax, Immediate(0));
670 __ ret(0); 670 __ ret(0);
671 671
672 CodeDesc desc; 672 CodeDesc desc;
673 assm.GetCode(&desc); 673 assm.GetCode(CcTest::i_isolate(), &desc);
674 // Call the function from C++. 674 // Call the function from C++.
675 int result = FUNCTION_CAST<F0>(buffer)(); 675 int result = FUNCTION_CAST<F0>(buffer)();
676 CHECK_EQ(1, result); 676 CHECK_EQ(1, result);
677 } 677 }
678 678
679 679
680 TEST(OperandRegisterDependency) { 680 TEST(OperandRegisterDependency) {
681 int offsets[4] = {0, 1, 0xfed, 0xbeefcad}; 681 int offsets[4] = {0, 1, 0xfed, 0xbeefcad};
682 for (int i = 0; i < 4; i++) { 682 for (int i = 0; i < 4; i++) {
683 int offset = offsets[i]; 683 int offset = offsets[i];
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 __ bind(&fail); 780 __ bind(&fail);
781 __ movq(rax, Immediate(13)); 781 __ movq(rax, Immediate(13));
782 __ popq(rsi); 782 __ popq(rsi);
783 __ popq(rdi); 783 __ popq(rdi);
784 __ popq(rdx); 784 __ popq(rdx);
785 __ popq(rcx); 785 __ popq(rcx);
786 __ popq(rbx); 786 __ popq(rbx);
787 __ ret(0); 787 __ ret(0);
788 788
789 CodeDesc desc; 789 CodeDesc desc;
790 assm.GetCode(&desc); 790 assm.GetCode(isolate, &desc);
791 Handle<Code> code = isolate->factory()->NewCode( 791 Handle<Code> code = isolate->factory()->NewCode(
792 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 792 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
793 793
794 F0 f = FUNCTION_CAST<F0>(code->entry()); 794 F0 f = FUNCTION_CAST<F0>(code->entry());
795 int res = f(); 795 int res = f();
796 CHECK_EQ(42, res); 796 CHECK_EQ(42, res);
797 } 797 }
798 798
799 799
800 #ifdef __GNUC__ 800 #ifdef __GNUC__
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 __ movmskps(rax, xmm0); 836 __ movmskps(rax, xmm0);
837 837
838 // Remove unused data from the stack. 838 // Remove unused data from the stack.
839 __ addq(rsp, Immediate(ELEMENT_COUNT * sizeof(int32_t))); 839 __ addq(rsp, Immediate(ELEMENT_COUNT * sizeof(int32_t)));
840 // Restore return address. 840 // Restore return address.
841 __ pushq(rcx); 841 __ pushq(rcx);
842 842
843 __ ret(0); 843 __ ret(0);
844 844
845 CodeDesc desc; 845 CodeDesc desc;
846 assm.GetCode(&desc); 846 assm.GetCode(isolate, &desc);
847 Handle<Code> code = isolate->factory()->NewCode( 847 Handle<Code> code = isolate->factory()->NewCode(
848 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 848 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
849 849
850 F0 f = FUNCTION_CAST<F0>(code->entry()); 850 F0 f = FUNCTION_CAST<F0>(code->entry());
851 int res = f(); 851 int res = f();
852 args.GetReturnValue().Set(v8::Integer::New(CcTest::isolate(), res)); 852 args.GetReturnValue().Set(v8::Integer::New(CcTest::isolate(), res));
853 } 853 }
854 854
855 855
856 TEST(StackAlignmentForSSE2) { 856 TEST(StackAlignmentForSSE2) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 v8::HandleScope scope(CcTest::isolate()); 899 v8::HandleScope scope(CcTest::isolate());
900 byte buffer[256]; 900 byte buffer[256];
901 Isolate* isolate = CcTest::i_isolate(); 901 Isolate* isolate = CcTest::i_isolate();
902 Assembler assm(isolate, buffer, sizeof(buffer)); 902 Assembler assm(isolate, buffer, sizeof(buffer));
903 { CpuFeatureScope fscope2(&assm, SSE4_1); 903 { CpuFeatureScope fscope2(&assm, SSE4_1);
904 __ extractps(rax, xmm0, 0x1); 904 __ extractps(rax, xmm0, 0x1);
905 __ ret(0); 905 __ ret(0);
906 } 906 }
907 907
908 CodeDesc desc; 908 CodeDesc desc;
909 assm.GetCode(&desc); 909 assm.GetCode(isolate, &desc);
910 Handle<Code> code = isolate->factory()->NewCode( 910 Handle<Code> code = isolate->factory()->NewCode(
911 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 911 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
912 #ifdef OBJECT_PRINT 912 #ifdef OBJECT_PRINT
913 OFStream os(stdout); 913 OFStream os(stdout);
914 code->Print(os); 914 code->Print(os);
915 #endif 915 #endif
916 916
917 F3 f = FUNCTION_CAST<F3>(code->entry()); 917 F3 f = FUNCTION_CAST<F3>(code->entry());
918 uint64_t value1 = V8_2PART_UINT64_C(0x12345678, 87654321); 918 uint64_t value1 = V8_2PART_UINT64_C(0x12345678, 87654321);
919 CHECK_EQ(0x12345678u, f(uint64_to_double(value1))); 919 CHECK_EQ(0x12345678u, f(uint64_to_double(value1)));
(...skipping 17 matching lines...) Expand all
937 __ movaps(xmm2, xmm1); 937 __ movaps(xmm2, xmm1);
938 __ addps(xmm2, xmm0); 938 __ addps(xmm2, xmm0);
939 __ mulps(xmm2, xmm1); 939 __ mulps(xmm2, xmm1);
940 __ subps(xmm2, xmm0); 940 __ subps(xmm2, xmm0);
941 __ divps(xmm2, xmm1); 941 __ divps(xmm2, xmm1);
942 __ cvttss2si(rax, xmm2); 942 __ cvttss2si(rax, xmm2);
943 __ ret(0); 943 __ ret(0);
944 } 944 }
945 945
946 CodeDesc desc; 946 CodeDesc desc;
947 assm.GetCode(&desc); 947 assm.GetCode(isolate, &desc);
948 Handle<Code> code = isolate->factory()->NewCode( 948 Handle<Code> code = isolate->factory()->NewCode(
949 desc, 949 desc,
950 Code::ComputeFlags(Code::STUB), 950 Code::ComputeFlags(Code::STUB),
951 Handle<Code>()); 951 Handle<Code>());
952 #ifdef OBJECT_PRINT 952 #ifdef OBJECT_PRINT
953 OFStream os(stdout); 953 OFStream os(stdout);
954 code->Print(os); 954 code->Print(os);
955 #endif 955 #endif
956 956
957 F6 f = FUNCTION_CAST<F6>(code->entry()); 957 F6 f = FUNCTION_CAST<F6>(code->entry());
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 __ j(not_equal, &exit); 1165 __ j(not_equal, &exit);
1166 1166
1167 1167
1168 __ xorl(rax, rax); 1168 __ xorl(rax, rax);
1169 __ bind(&exit); 1169 __ bind(&exit);
1170 __ addq(rsp, Immediate(kDoubleSize)); 1170 __ addq(rsp, Immediate(kDoubleSize));
1171 __ ret(0); 1171 __ ret(0);
1172 } 1172 }
1173 1173
1174 CodeDesc desc; 1174 CodeDesc desc;
1175 assm.GetCode(&desc); 1175 assm.GetCode(isolate, &desc);
1176 Handle<Code> code = isolate->factory()->NewCode( 1176 Handle<Code> code = isolate->factory()->NewCode(
1177 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 1177 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1178 #ifdef OBJECT_PRINT 1178 #ifdef OBJECT_PRINT
1179 OFStream os(stdout); 1179 OFStream os(stdout);
1180 code->Print(os); 1180 code->Print(os);
1181 #endif 1181 #endif
1182 1182
1183 F7 f = FUNCTION_CAST<F7>(code->entry()); 1183 F7 f = FUNCTION_CAST<F7>(code->entry());
1184 CHECK_EQ(0, f(0.000092662107262076, -2.460774966188315, -1.0958787393627414)); 1184 CHECK_EQ(0, f(0.000092662107262076, -2.460774966188315, -1.0958787393627414));
1185 } 1185 }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 __ j(not_equal, &exit); 1391 __ j(not_equal, &exit);
1392 1392
1393 1393
1394 __ xorl(rax, rax); 1394 __ xorl(rax, rax);
1395 __ bind(&exit); 1395 __ bind(&exit);
1396 __ addq(rsp, Immediate(kDoubleSize)); 1396 __ addq(rsp, Immediate(kDoubleSize));
1397 __ ret(0); 1397 __ ret(0);
1398 } 1398 }
1399 1399
1400 CodeDesc desc; 1400 CodeDesc desc;
1401 assm.GetCode(&desc); 1401 assm.GetCode(isolate, &desc);
1402 Handle<Code> code = isolate->factory()->NewCode( 1402 Handle<Code> code = isolate->factory()->NewCode(
1403 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 1403 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1404 #ifdef OBJECT_PRINT 1404 #ifdef OBJECT_PRINT
1405 OFStream os(stdout); 1405 OFStream os(stdout);
1406 code->Print(os); 1406 code->Print(os);
1407 #endif 1407 #endif
1408 1408
1409 F8 f = FUNCTION_CAST<F8>(code->entry()); 1409 F8 f = FUNCTION_CAST<F8>(code->entry());
1410 CHECK_EQ(0, f(9.26621069e-05f, -2.4607749f, -1.09587872f)); 1410 CHECK_EQ(0, f(9.26621069e-05f, -2.4607749f, -1.09587872f));
1411 } 1411 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 __ j(parity_even, &exit); 1466 __ j(parity_even, &exit);
1467 __ j(not_equal, &exit); 1467 __ j(not_equal, &exit);
1468 __ movl(rax, Immediate(6)); 1468 __ movl(rax, Immediate(6));
1469 1469
1470 // result in eax 1470 // result in eax
1471 __ bind(&exit); 1471 __ bind(&exit);
1472 __ ret(0); 1472 __ ret(0);
1473 } 1473 }
1474 1474
1475 CodeDesc desc; 1475 CodeDesc desc;
1476 assm.GetCode(&desc); 1476 assm.GetCode(isolate, &desc);
1477 Handle<Code> code = isolate->factory()->NewCode( 1477 Handle<Code> code = isolate->factory()->NewCode(
1478 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 1478 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1479 #ifdef OBJECT_PRINT 1479 #ifdef OBJECT_PRINT
1480 OFStream os(stdout); 1480 OFStream os(stdout);
1481 code->Print(os); 1481 code->Print(os);
1482 #endif 1482 #endif
1483 1483
1484 F8 f = FUNCTION_CAST<F8>(code->entry()); 1484 F8 f = FUNCTION_CAST<F8>(code->entry());
1485 int res = f(1.0f, 2.0f, 3.0f); 1485 int res = f(1.0f, 2.0f, 3.0f);
1486 PrintF("f(1,2,3) = %d\n", res); 1486 PrintF("f(1,2,3) = %d\n", res);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 __ j(not_equal, &exit); 1551 __ j(not_equal, &exit);
1552 __ movl(rax, Immediate(6)); 1552 __ movl(rax, Immediate(6));
1553 1553
1554 // result in eax 1554 // result in eax
1555 __ bind(&exit); 1555 __ bind(&exit);
1556 __ addq(rsp, Immediate(kDoubleSize * 2)); 1556 __ addq(rsp, Immediate(kDoubleSize * 2));
1557 __ ret(0); 1557 __ ret(0);
1558 } 1558 }
1559 1559
1560 CodeDesc desc; 1560 CodeDesc desc;
1561 assm.GetCode(&desc); 1561 assm.GetCode(isolate, &desc);
1562 Handle<Code> code = isolate->factory()->NewCode( 1562 Handle<Code> code = isolate->factory()->NewCode(
1563 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 1563 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1564 #ifdef OBJECT_PRINT 1564 #ifdef OBJECT_PRINT
1565 OFStream os(stdout); 1565 OFStream os(stdout);
1566 code->Print(os); 1566 code->Print(os);
1567 #endif 1567 #endif
1568 1568
1569 F8 f = FUNCTION_CAST<F8>(code->entry()); 1569 F8 f = FUNCTION_CAST<F8>(code->entry());
1570 int res = f(1.0f, 2.0f, 3.0f); 1570 int res = f(1.0f, 2.0f, 3.0f);
1571 PrintF("f(1,2,3) = %d\n", res); 1571 PrintF("f(1,2,3) = %d\n", res);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 __ j(not_equal, &exit); 1790 __ j(not_equal, &exit);
1791 __ movl(rax, Immediate(6)); 1791 __ movl(rax, Immediate(6));
1792 1792
1793 // result in eax 1793 // result in eax
1794 __ bind(&exit); 1794 __ bind(&exit);
1795 __ addq(rsp, Immediate(kDoubleSize * 2)); 1795 __ addq(rsp, Immediate(kDoubleSize * 2));
1796 __ ret(0); 1796 __ ret(0);
1797 } 1797 }
1798 1798
1799 CodeDesc desc; 1799 CodeDesc desc;
1800 assm.GetCode(&desc); 1800 assm.GetCode(isolate, &desc);
1801 Handle<Code> code = isolate->factory()->NewCode( 1801 Handle<Code> code = isolate->factory()->NewCode(
1802 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 1802 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1803 #ifdef OBJECT_PRINT 1803 #ifdef OBJECT_PRINT
1804 OFStream os(stdout); 1804 OFStream os(stdout);
1805 code->Print(os); 1805 code->Print(os);
1806 #endif 1806 #endif
1807 1807
1808 F7 f = FUNCTION_CAST<F7>(code->entry()); 1808 F7 f = FUNCTION_CAST<F7>(code->entry());
1809 int res = f(1.0, 2.0, 3.0); 1809 int res = f(1.0, 2.0, 3.0);
1810 PrintF("f(1,2,3) = %d\n", res); 1810 PrintF("f(1,2,3) = %d\n", res);
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 __ cmpq(r8, r9); 1982 __ cmpq(r8, r9);
1983 __ j(not_equal, &exit); 1983 __ j(not_equal, &exit);
1984 1984
1985 __ xorl(rax, rax); 1985 __ xorl(rax, rax);
1986 __ bind(&exit); 1986 __ bind(&exit);
1987 __ popq(rcx); 1987 __ popq(rcx);
1988 __ ret(0); 1988 __ ret(0);
1989 } 1989 }
1990 1990
1991 CodeDesc desc; 1991 CodeDesc desc;
1992 assm.GetCode(&desc); 1992 assm.GetCode(isolate, &desc);
1993 Handle<Code> code = isolate->factory()->NewCode( 1993 Handle<Code> code = isolate->factory()->NewCode(
1994 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 1994 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1995 #ifdef OBJECT_PRINT 1995 #ifdef OBJECT_PRINT
1996 OFStream os(stdout); 1996 OFStream os(stdout);
1997 code->Print(os); 1997 code->Print(os);
1998 #endif 1998 #endif
1999 1999
2000 F0 f = FUNCTION_CAST<F0>(code->entry()); 2000 F0 f = FUNCTION_CAST<F0>(code->entry());
2001 CHECK_EQ(0, f()); 2001 CHECK_EQ(0, f());
2002 } 2002 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 __ cmpq(r8, r9); 2042 __ cmpq(r8, r9);
2043 __ j(not_equal, &exit); 2043 __ j(not_equal, &exit);
2044 2044
2045 __ xorl(rax, rax); 2045 __ xorl(rax, rax);
2046 __ bind(&exit); 2046 __ bind(&exit);
2047 __ popq(rcx); 2047 __ popq(rcx);
2048 __ ret(0); 2048 __ ret(0);
2049 } 2049 }
2050 2050
2051 CodeDesc desc; 2051 CodeDesc desc;
2052 assm.GetCode(&desc); 2052 assm.GetCode(isolate, &desc);
2053 Handle<Code> code = isolate->factory()->NewCode( 2053 Handle<Code> code = isolate->factory()->NewCode(
2054 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 2054 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
2055 #ifdef OBJECT_PRINT 2055 #ifdef OBJECT_PRINT
2056 OFStream os(stdout); 2056 OFStream os(stdout);
2057 code->Print(os); 2057 code->Print(os);
2058 #endif 2058 #endif
2059 2059
2060 F0 f = FUNCTION_CAST<F0>(code->entry()); 2060 F0 f = FUNCTION_CAST<F0>(code->entry());
2061 CHECK_EQ(0, f()); 2061 CHECK_EQ(0, f());
2062 } 2062 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2102 __ cmpq(r8, r9); 2102 __ cmpq(r8, r9);
2103 __ j(not_equal, &exit); 2103 __ j(not_equal, &exit);
2104 2104
2105 __ xorl(rax, rax); 2105 __ xorl(rax, rax);
2106 __ bind(&exit); 2106 __ bind(&exit);
2107 __ popq(rcx); 2107 __ popq(rcx);
2108 __ ret(0); 2108 __ ret(0);
2109 } 2109 }
2110 2110
2111 CodeDesc desc; 2111 CodeDesc desc;
2112 assm.GetCode(&desc); 2112 assm.GetCode(isolate, &desc);
2113 Handle<Code> code = isolate->factory()->NewCode( 2113 Handle<Code> code = isolate->factory()->NewCode(
2114 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 2114 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
2115 #ifdef OBJECT_PRINT 2115 #ifdef OBJECT_PRINT
2116 OFStream os(stdout); 2116 OFStream os(stdout);
2117 code->Print(os); 2117 code->Print(os);
2118 #endif 2118 #endif
2119 2119
2120 F0 f = FUNCTION_CAST<F0>(code->entry()); 2120 F0 f = FUNCTION_CAST<F0>(code->entry());
2121 CHECK_EQ(0, f()); 2121 CHECK_EQ(0, f());
2122 } 2122 }
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 __ j(not_equal, &exit); 2365 __ j(not_equal, &exit);
2366 2366
2367 __ xorl(rax, rax); 2367 __ xorl(rax, rax);
2368 __ bind(&exit); 2368 __ bind(&exit);
2369 __ popq(rcx); 2369 __ popq(rcx);
2370 __ popq(rbx); 2370 __ popq(rbx);
2371 __ ret(0); 2371 __ ret(0);
2372 } 2372 }
2373 2373
2374 CodeDesc desc; 2374 CodeDesc desc;
2375 assm.GetCode(&desc); 2375 assm.GetCode(isolate, &desc);
2376 Handle<Code> code = isolate->factory()->NewCode( 2376 Handle<Code> code = isolate->factory()->NewCode(
2377 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 2377 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
2378 #ifdef OBJECT_PRINT 2378 #ifdef OBJECT_PRINT
2379 OFStream os(stdout); 2379 OFStream os(stdout);
2380 code->Print(os); 2380 code->Print(os);
2381 #endif 2381 #endif
2382 2382
2383 F0 f = FUNCTION_CAST<F0>(code->entry()); 2383 F0 f = FUNCTION_CAST<F0>(code->entry());
2384 CHECK_EQ(0, f()); 2384 CHECK_EQ(0, f());
2385 } 2385 }
(...skipping 24 matching lines...) Expand all
2410 for (int i = 0; i < kNumCases; ++i) { 2410 for (int i = 0; i < kNumCases; ++i) {
2411 __ bind(&labels[i]); 2411 __ bind(&labels[i]);
2412 __ movq(rax, Immediate(values[i])); 2412 __ movq(rax, Immediate(values[i]));
2413 __ jmp(&done); 2413 __ jmp(&done);
2414 } 2414 }
2415 2415
2416 __ bind(&done); 2416 __ bind(&done);
2417 __ ret(0); 2417 __ ret(0);
2418 2418
2419 CodeDesc desc; 2419 CodeDesc desc;
2420 assm.GetCode(&desc); 2420 assm.GetCode(isolate, &desc);
2421 Handle<Code> code = isolate->factory()->NewCode( 2421 Handle<Code> code = isolate->factory()->NewCode(
2422 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 2422 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
2423 #ifdef OBJECT_PRINT 2423 #ifdef OBJECT_PRINT
2424 code->Print(std::cout); 2424 code->Print(std::cout);
2425 #endif 2425 #endif
2426 2426
2427 F1 f = FUNCTION_CAST<F1>(code->entry()); 2427 F1 f = FUNCTION_CAST<F1>(code->entry());
2428 for (int i = 0; i < kNumCases; ++i) { 2428 for (int i = 0; i < kNumCases; ++i) {
2429 int res = f(i); 2429 int res = f(i);
2430 PrintF("f(%d) = %d\n", i, res); 2430 PrintF("f(%d) = %d\n", i, res);
(...skipping 28 matching lines...) Expand all
2459 2459
2460 __ bind(&done); 2460 __ bind(&done);
2461 __ ret(0); 2461 __ ret(0);
2462 2462
2463 __ bind(&table); 2463 __ bind(&table);
2464 for (int i = 0; i < kNumCases; ++i) { 2464 for (int i = 0; i < kNumCases; ++i) {
2465 __ dq(&labels[i]); 2465 __ dq(&labels[i]);
2466 } 2466 }
2467 2467
2468 CodeDesc desc; 2468 CodeDesc desc;
2469 assm.GetCode(&desc); 2469 assm.GetCode(isolate, &desc);
2470 Handle<Code> code = isolate->factory()->NewCode( 2470 Handle<Code> code = isolate->factory()->NewCode(
2471 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 2471 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
2472 #ifdef OBJECT_PRINT 2472 #ifdef OBJECT_PRINT
2473 code->Print(std::cout); 2473 code->Print(std::cout);
2474 #endif 2474 #endif
2475 2475
2476 F1 f = FUNCTION_CAST<F1>(code->entry()); 2476 F1 f = FUNCTION_CAST<F1>(code->entry());
2477 for (int i = 0; i < kNumCases; ++i) { 2477 for (int i = 0; i < kNumCases; ++i) {
2478 int res = f(i); 2478 int res = f(i);
2479 PrintF("f(%d) = %d\n", i, res); 2479 PrintF("f(%d) = %d\n", i, res);
2480 CHECK_EQ(values[i], res); 2480 CHECK_EQ(values[i], res);
2481 } 2481 }
2482 } 2482 }
2483 2483
2484 TEST(AssemblerX64PslldWithXmm15) { 2484 TEST(AssemblerX64PslldWithXmm15) {
2485 CcTest::InitializeVM(); 2485 CcTest::InitializeVM();
2486 // Allocate an executable page of memory. 2486 // Allocate an executable page of memory.
2487 size_t actual_size; 2487 size_t actual_size;
2488 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate( 2488 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
2489 Assembler::kMinimalBufferSize, &actual_size, true)); 2489 Assembler::kMinimalBufferSize, &actual_size, true));
2490 CHECK(buffer); 2490 CHECK(buffer);
2491 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size)); 2491 Assembler assm(CcTest::i_isolate(), buffer, static_cast<int>(actual_size));
2492 2492
2493 __ movq(xmm15, arg1); 2493 __ movq(xmm15, arg1);
2494 __ pslld(xmm15, 1); 2494 __ pslld(xmm15, 1);
2495 __ movq(rax, xmm15); 2495 __ movq(rax, xmm15);
2496 __ ret(0); 2496 __ ret(0);
2497 2497
2498 CodeDesc desc; 2498 CodeDesc desc;
2499 assm.GetCode(&desc); 2499 assm.GetCode(CcTest::i_isolate(), &desc);
2500 uint64_t result = FUNCTION_CAST<F5>(buffer)(V8_UINT64_C(0x1122334455667788)); 2500 uint64_t result = FUNCTION_CAST<F5>(buffer)(V8_UINT64_C(0x1122334455667788));
2501 CHECK_EQ(V8_UINT64_C(0x22446688aaccef10), result); 2501 CHECK_EQ(V8_UINT64_C(0x22446688aaccef10), result);
2502 } 2502 }
2503 2503
2504 typedef float (*F9)(float x, float y); 2504 typedef float (*F9)(float x, float y);
2505 TEST(AssemblerX64vmovups) { 2505 TEST(AssemblerX64vmovups) {
2506 CcTest::InitializeVM(); 2506 CcTest::InitializeVM();
2507 if (!CpuFeatures::IsSupported(AVX)) return; 2507 if (!CpuFeatures::IsSupported(AVX)) return;
2508 2508
2509 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 2509 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
2510 HandleScope scope(isolate); 2510 HandleScope scope(isolate);
2511 v8::internal::byte buffer[256]; 2511 v8::internal::byte buffer[256];
2512 MacroAssembler assm(isolate, buffer, sizeof(buffer), 2512 MacroAssembler assm(isolate, buffer, sizeof(buffer),
2513 v8::internal::CodeObjectRequired::kYes); 2513 v8::internal::CodeObjectRequired::kYes);
2514 { 2514 {
2515 CpuFeatureScope avx_scope(&assm, AVX); 2515 CpuFeatureScope avx_scope(&assm, AVX);
2516 __ shufps(xmm0, xmm0, 0x0); // brocast first argument 2516 __ shufps(xmm0, xmm0, 0x0); // brocast first argument
2517 __ shufps(xmm1, xmm1, 0x0); // brocast second argument 2517 __ shufps(xmm1, xmm1, 0x0); // brocast second argument
2518 // copy xmm1 to xmm0 through the stack to test the "vmovups reg, mem". 2518 // copy xmm1 to xmm0 through the stack to test the "vmovups reg, mem".
2519 __ subq(rsp, Immediate(kSimd128Size)); 2519 __ subq(rsp, Immediate(kSimd128Size));
2520 __ vmovups(Operand(rsp, 0), xmm1); 2520 __ vmovups(Operand(rsp, 0), xmm1);
2521 __ vmovups(xmm0, Operand(rsp, 0)); 2521 __ vmovups(xmm0, Operand(rsp, 0));
2522 __ addq(rsp, Immediate(kSimd128Size)); 2522 __ addq(rsp, Immediate(kSimd128Size));
2523 2523
2524 __ ret(0); 2524 __ ret(0);
2525 } 2525 }
2526 2526
2527 CodeDesc desc; 2527 CodeDesc desc;
2528 assm.GetCode(&desc); 2528 assm.GetCode(isolate, &desc);
2529 Handle<Code> code = isolate->factory()->NewCode( 2529 Handle<Code> code = isolate->factory()->NewCode(
2530 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 2530 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
2531 #ifdef OBJECT_PRINT 2531 #ifdef OBJECT_PRINT
2532 OFStream os(stdout); 2532 OFStream os(stdout);
2533 code->Print(os); 2533 code->Print(os);
2534 #endif 2534 #endif
2535 2535
2536 F9 f = FUNCTION_CAST<F9>(code->entry()); 2536 F9 f = FUNCTION_CAST<F9>(code->entry());
2537 CHECK_EQ(-1.5, f(1.5, -1.5)); 2537 CHECK_EQ(-1.5, f(1.5, -1.5));
2538 } 2538 }
2539 2539
2540 #undef __ 2540 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-assembler-mips64.cc ('k') | test/cctest/test-code-stubs-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698