OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 | 45 |
46 static void DummyStaticFunction(Object* result) { | 46 static void DummyStaticFunction(Object* result) { |
47 } | 47 } |
48 | 48 |
49 | 49 |
50 TEST(DisasmX64) { | 50 TEST(DisasmX64) { |
51 CcTest::InitializeVM(); | 51 CcTest::InitializeVM(); |
52 Isolate* isolate = CcTest::i_isolate(); | 52 Isolate* isolate = CcTest::i_isolate(); |
53 HandleScope scope(isolate); | 53 HandleScope scope(isolate); |
54 v8::internal::byte buffer[2048]; | 54 v8::internal::byte buffer[4096]; |
55 Assembler assm(isolate, buffer, sizeof buffer); | 55 Assembler assm(isolate, buffer, sizeof buffer); |
56 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) | 56 DummyStaticFunction(NULL); // just bloody use it (DELETE; debugging) |
57 | 57 |
58 // Short immediate instructions | 58 // Short immediate instructions |
59 __ addq(rax, Immediate(12345678)); | 59 __ addq(rax, Immediate(12345678)); |
60 __ orq(rax, Immediate(12345678)); | 60 __ orq(rax, Immediate(12345678)); |
61 __ subq(rax, Immediate(12345678)); | 61 __ subq(rax, Immediate(12345678)); |
62 __ xorq(rax, Immediate(12345678)); | 62 __ xorq(rax, Immediate(12345678)); |
63 __ andq(rax, Immediate(12345678)); | 63 __ andq(rax, Immediate(12345678)); |
64 | 64 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 | 387 |
388 // logic operation | 388 // logic operation |
389 __ andps(xmm0, xmm1); | 389 __ andps(xmm0, xmm1); |
390 __ andps(xmm0, Operand(rbx, rcx, times_4, 10000)); | 390 __ andps(xmm0, Operand(rbx, rcx, times_4, 10000)); |
391 __ orps(xmm0, xmm1); | 391 __ orps(xmm0, xmm1); |
392 __ orps(xmm0, Operand(rbx, rcx, times_4, 10000)); | 392 __ orps(xmm0, Operand(rbx, rcx, times_4, 10000)); |
393 __ xorps(xmm0, xmm1); | 393 __ xorps(xmm0, xmm1); |
394 __ xorps(xmm0, Operand(rbx, rcx, times_4, 10000)); | 394 __ xorps(xmm0, Operand(rbx, rcx, times_4, 10000)); |
395 | 395 |
396 // Arithmetic operation | 396 // Arithmetic operation |
| 397 __ addss(xmm1, xmm0); |
| 398 __ addss(xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 399 __ mulss(xmm1, xmm0); |
| 400 __ mulss(xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 401 __ subss(xmm1, xmm0); |
| 402 __ subss(xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 403 __ divss(xmm1, xmm0); |
| 404 __ divss(xmm1, Operand(rbx, rcx, times_4, 10000)); |
397 __ addps(xmm1, xmm0); | 405 __ addps(xmm1, xmm0); |
398 __ addps(xmm1, Operand(rbx, rcx, times_4, 10000)); | 406 __ addps(xmm1, Operand(rbx, rcx, times_4, 10000)); |
399 __ subps(xmm1, xmm0); | 407 __ subps(xmm1, xmm0); |
400 __ subps(xmm1, Operand(rbx, rcx, times_4, 10000)); | 408 __ subps(xmm1, Operand(rbx, rcx, times_4, 10000)); |
401 __ mulps(xmm1, xmm0); | 409 __ mulps(xmm1, xmm0); |
402 __ mulps(xmm1, Operand(rbx, rcx, times_4, 10000)); | 410 __ mulps(xmm1, Operand(rbx, rcx, times_4, 10000)); |
403 __ divps(xmm1, xmm0); | 411 __ divps(xmm1, xmm0); |
404 __ divps(xmm1, Operand(rbx, rcx, times_4, 10000)); | 412 __ divps(xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 413 |
| 414 __ ucomiss(xmm0, xmm1); |
| 415 __ ucomiss(xmm0, Operand(rbx, rcx, times_4, 10000)); |
405 } | 416 } |
406 // SSE 2 instructions | 417 // SSE 2 instructions |
407 { | 418 { |
408 __ cvttsd2si(rdx, Operand(rbx, rcx, times_4, 10000)); | 419 __ cvttsd2si(rdx, Operand(rbx, rcx, times_4, 10000)); |
409 __ cvttsd2si(rdx, xmm1); | 420 __ cvttsd2si(rdx, xmm1); |
410 __ cvttsd2siq(rdx, xmm1); | 421 __ cvttsd2siq(rdx, xmm1); |
411 __ cvttsd2siq(rdx, Operand(rbx, rcx, times_4, 10000)); | 422 __ cvttsd2siq(rdx, Operand(rbx, rcx, times_4, 10000)); |
412 __ cvtqsi2sd(xmm1, Operand(rbx, rcx, times_4, 10000)); | 423 __ cvtqsi2sd(xmm1, Operand(rbx, rcx, times_4, 10000)); |
413 __ cvtqsi2sd(xmm1, rdx); | 424 __ cvtqsi2sd(xmm1, rdx); |
414 __ movsd(xmm1, Operand(rbx, rcx, times_4, 10000)); | 425 __ movsd(xmm1, Operand(rbx, rcx, times_4, 10000)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 __ cmovq(greater, rax, Operand(rdx, 3)); | 468 __ cmovq(greater, rax, Operand(rdx, 3)); |
458 } | 469 } |
459 | 470 |
460 { | 471 { |
461 if (CpuFeatures::IsSupported(SSE4_1)) { | 472 if (CpuFeatures::IsSupported(SSE4_1)) { |
462 CpuFeatureScope scope(&assm, SSE4_1); | 473 CpuFeatureScope scope(&assm, SSE4_1); |
463 __ extractps(rax, xmm1, 0); | 474 __ extractps(rax, xmm1, 0); |
464 } | 475 } |
465 } | 476 } |
466 | 477 |
| 478 // FMA3 instruction |
| 479 { |
| 480 if (CpuFeatures::IsSupported(FMA3)) { |
| 481 CpuFeatureScope scope(&assm, FMA3); |
| 482 __ vfmadd132sd(xmm0, xmm1, xmm2); |
| 483 __ vfmadd132sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 484 __ vfmadd213sd(xmm0, xmm1, xmm2); |
| 485 __ vfmadd213sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 486 __ vfmadd231sd(xmm0, xmm1, xmm2); |
| 487 __ vfmadd231sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 488 |
| 489 __ vfmadd132sd(xmm9, xmm10, xmm11); |
| 490 __ vfmadd132sd(xmm9, xmm10, Operand(r9, r11, times_4, 10000)); |
| 491 __ vfmadd213sd(xmm9, xmm10, xmm11); |
| 492 __ vfmadd213sd(xmm9, xmm10, Operand(r9, r11, times_4, 10000)); |
| 493 __ vfmadd231sd(xmm9, xmm10, xmm11); |
| 494 __ vfmadd231sd(xmm9, xmm10, Operand(r9, r11, times_4, 10000)); |
| 495 |
| 496 __ vfmsub132sd(xmm0, xmm1, xmm2); |
| 497 __ vfmsub132sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 498 __ vfmsub213sd(xmm0, xmm1, xmm2); |
| 499 __ vfmsub213sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 500 __ vfmsub231sd(xmm0, xmm1, xmm2); |
| 501 __ vfmsub231sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 502 |
| 503 __ vfnmadd132sd(xmm0, xmm1, xmm2); |
| 504 __ vfnmadd132sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 505 __ vfnmadd213sd(xmm0, xmm1, xmm2); |
| 506 __ vfnmadd213sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 507 __ vfnmadd231sd(xmm0, xmm1, xmm2); |
| 508 __ vfnmadd231sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 509 |
| 510 __ vfnmsub132sd(xmm0, xmm1, xmm2); |
| 511 __ vfnmsub132sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 512 __ vfnmsub213sd(xmm0, xmm1, xmm2); |
| 513 __ vfnmsub213sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 514 __ vfnmsub231sd(xmm0, xmm1, xmm2); |
| 515 __ vfnmsub231sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 516 |
| 517 __ vfmadd132ss(xmm0, xmm1, xmm2); |
| 518 __ vfmadd132ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 519 __ vfmadd213ss(xmm0, xmm1, xmm2); |
| 520 __ vfmadd213ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 521 __ vfmadd231ss(xmm0, xmm1, xmm2); |
| 522 __ vfmadd231ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 523 |
| 524 __ vfmsub132ss(xmm0, xmm1, xmm2); |
| 525 __ vfmsub132ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 526 __ vfmsub213ss(xmm0, xmm1, xmm2); |
| 527 __ vfmsub213ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 528 __ vfmsub231ss(xmm0, xmm1, xmm2); |
| 529 __ vfmsub231ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 530 |
| 531 __ vfnmadd132ss(xmm0, xmm1, xmm2); |
| 532 __ vfnmadd132ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 533 __ vfnmadd213ss(xmm0, xmm1, xmm2); |
| 534 __ vfnmadd213ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 535 __ vfnmadd231ss(xmm0, xmm1, xmm2); |
| 536 __ vfnmadd231ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 537 |
| 538 __ vfnmsub132ss(xmm0, xmm1, xmm2); |
| 539 __ vfnmsub132ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 540 __ vfnmsub213ss(xmm0, xmm1, xmm2); |
| 541 __ vfnmsub213ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 542 __ vfnmsub231ss(xmm0, xmm1, xmm2); |
| 543 __ vfnmsub231ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000)); |
| 544 } |
| 545 } |
467 // xchg. | 546 // xchg. |
468 { | 547 { |
469 __ xchgq(rax, rax); | 548 __ xchgq(rax, rax); |
470 __ xchgq(rax, rbx); | 549 __ xchgq(rax, rbx); |
471 __ xchgq(rbx, rbx); | 550 __ xchgq(rbx, rbx); |
472 __ xchgq(rbx, Operand(rsp, 12)); | 551 __ xchgq(rbx, Operand(rsp, 12)); |
473 } | 552 } |
474 | 553 |
475 // Nop instructions | 554 // Nop instructions |
476 for (int i = 0; i < 16; i++) { | 555 for (int i = 0; i < 16; i++) { |
(...skipping 10 matching lines...) Expand all Loading... |
487 #ifdef OBJECT_PRINT | 566 #ifdef OBJECT_PRINT |
488 OFStream os(stdout); | 567 OFStream os(stdout); |
489 code->Print(os); | 568 code->Print(os); |
490 byte* begin = code->instruction_start(); | 569 byte* begin = code->instruction_start(); |
491 byte* end = begin + code->instruction_size(); | 570 byte* end = begin + code->instruction_size(); |
492 disasm::Disassembler::Disassemble(stdout, begin, end); | 571 disasm::Disassembler::Disassemble(stdout, begin, end); |
493 #endif | 572 #endif |
494 } | 573 } |
495 | 574 |
496 #undef __ | 575 #undef __ |
OLD | NEW |