| OLD | NEW |
| 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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 __ movq(rax, Immediate(13)); | 568 __ movq(rax, Immediate(13)); |
| 569 __ popq(rsi); | 569 __ popq(rsi); |
| 570 __ popq(rdi); | 570 __ popq(rdi); |
| 571 __ popq(rdx); | 571 __ popq(rdx); |
| 572 __ popq(rcx); | 572 __ popq(rcx); |
| 573 __ popq(rbx); | 573 __ popq(rbx); |
| 574 __ ret(0); | 574 __ ret(0); |
| 575 | 575 |
| 576 CodeDesc desc; | 576 CodeDesc desc; |
| 577 assm.GetCode(&desc); | 577 assm.GetCode(&desc); |
| 578 Code* code = Code::cast(isolate->heap()->CreateCode( | 578 Handle<Code> code = isolate->factory()->NewCode( |
| 579 desc, | 579 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 580 Code::ComputeFlags(Code::STUB), | |
| 581 Handle<Code>())->ToObjectChecked()); | |
| 582 CHECK(code->IsCode()); | |
| 583 | 580 |
| 584 F0 f = FUNCTION_CAST<F0>(code->entry()); | 581 F0 f = FUNCTION_CAST<F0>(code->entry()); |
| 585 int res = f(); | 582 int res = f(); |
| 586 CHECK_EQ(42, res); | 583 CHECK_EQ(42, res); |
| 587 } | 584 } |
| 588 | 585 |
| 589 | 586 |
| 590 #ifdef __GNUC__ | 587 #ifdef __GNUC__ |
| 591 #define ELEMENT_COUNT 4 | 588 #define ELEMENT_COUNT 4 |
| 592 | 589 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 620 | 617 |
| 621 // Remove unused data from the stack. | 618 // Remove unused data from the stack. |
| 622 __ addq(rsp, Immediate(ELEMENT_COUNT * sizeof(int32_t))); | 619 __ addq(rsp, Immediate(ELEMENT_COUNT * sizeof(int32_t))); |
| 623 // Restore return address. | 620 // Restore return address. |
| 624 __ pushq(rcx); | 621 __ pushq(rcx); |
| 625 | 622 |
| 626 __ ret(0); | 623 __ ret(0); |
| 627 | 624 |
| 628 CodeDesc desc; | 625 CodeDesc desc; |
| 629 assm.GetCode(&desc); | 626 assm.GetCode(&desc); |
| 630 Code* code = Code::cast(isolate->heap()->CreateCode( | 627 Handle<Code> code = isolate->factory()->NewCode( |
| 631 desc, | 628 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 632 Code::ComputeFlags(Code::STUB), | |
| 633 Handle<Code>())->ToObjectChecked()); | |
| 634 CHECK(code->IsCode()); | |
| 635 | 629 |
| 636 F0 f = FUNCTION_CAST<F0>(code->entry()); | 630 F0 f = FUNCTION_CAST<F0>(code->entry()); |
| 637 int res = f(); | 631 int res = f(); |
| 638 args.GetReturnValue().Set(v8::Integer::New(CcTest::isolate(), res)); | 632 args.GetReturnValue().Set(v8::Integer::New(CcTest::isolate(), res)); |
| 639 } | 633 } |
| 640 | 634 |
| 641 | 635 |
| 642 TEST(StackAlignmentForSSE2) { | 636 TEST(StackAlignmentForSSE2) { |
| 643 CcTest::InitializeVM(); | 637 CcTest::InitializeVM(); |
| 644 CHECK_EQ(0, OS::ActivationFrameAlignment() % 16); | 638 CHECK_EQ(0, OS::ActivationFrameAlignment() % 16); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 byte buffer[256]; | 679 byte buffer[256]; |
| 686 Isolate* isolate = CcTest::i_isolate(); | 680 Isolate* isolate = CcTest::i_isolate(); |
| 687 Assembler assm(isolate, buffer, sizeof(buffer)); | 681 Assembler assm(isolate, buffer, sizeof(buffer)); |
| 688 { CpuFeatureScope fscope2(&assm, SSE4_1); | 682 { CpuFeatureScope fscope2(&assm, SSE4_1); |
| 689 __ extractps(rax, xmm0, 0x1); | 683 __ extractps(rax, xmm0, 0x1); |
| 690 __ ret(0); | 684 __ ret(0); |
| 691 } | 685 } |
| 692 | 686 |
| 693 CodeDesc desc; | 687 CodeDesc desc; |
| 694 assm.GetCode(&desc); | 688 assm.GetCode(&desc); |
| 695 Code* code = Code::cast(isolate->heap()->CreateCode( | 689 Handle<Code> code = isolate->factory()->NewCode( |
| 696 desc, | 690 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 697 Code::ComputeFlags(Code::STUB), | |
| 698 Handle<Code>())->ToObjectChecked()); | |
| 699 CHECK(code->IsCode()); | |
| 700 #ifdef OBJECT_PRINT | 691 #ifdef OBJECT_PRINT |
| 701 Code::cast(code)->Print(); | 692 code->Print(); |
| 702 #endif | 693 #endif |
| 703 | 694 |
| 704 F3 f = FUNCTION_CAST<F3>(Code::cast(code)->entry()); | 695 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 705 uint64_t value1 = V8_2PART_UINT64_C(0x12345678, 87654321); | 696 uint64_t value1 = V8_2PART_UINT64_C(0x12345678, 87654321); |
| 706 CHECK_EQ(0x12345678, f(uint64_to_double(value1))); | 697 CHECK_EQ(0x12345678, f(uint64_to_double(value1))); |
| 707 uint64_t value2 = V8_2PART_UINT64_C(0x87654321, 12345678); | 698 uint64_t value2 = V8_2PART_UINT64_C(0x87654321, 12345678); |
| 708 CHECK_EQ(0x87654321, f(uint64_to_double(value2))); | 699 CHECK_EQ(0x87654321, f(uint64_to_double(value2))); |
| 709 } | 700 } |
| 710 | 701 |
| 711 | 702 |
| 712 typedef int (*F6)(float x, float y); | 703 typedef int (*F6)(float x, float y); |
| 713 TEST(AssemblerX64SSE) { | 704 TEST(AssemblerX64SSE) { |
| 714 CcTest::InitializeVM(); | 705 CcTest::InitializeVM(); |
| 715 | 706 |
| 716 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 707 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 717 HandleScope scope(isolate); | 708 HandleScope scope(isolate); |
| 718 v8::internal::byte buffer[256]; | 709 v8::internal::byte buffer[256]; |
| 719 MacroAssembler assm(isolate, buffer, sizeof buffer); | 710 MacroAssembler assm(isolate, buffer, sizeof buffer); |
| 720 { | 711 { |
| 721 __ shufps(xmm0, xmm0, 0x0); // brocast first argument | 712 __ shufps(xmm0, xmm0, 0x0); // brocast first argument |
| 722 __ shufps(xmm1, xmm1, 0x0); // brocast second argument | 713 __ shufps(xmm1, xmm1, 0x0); // brocast second argument |
| 723 __ movaps(xmm2, xmm1); | 714 __ movaps(xmm2, xmm1); |
| 724 __ addps(xmm2, xmm0); | 715 __ addps(xmm2, xmm0); |
| 725 __ mulps(xmm2, xmm1); | 716 __ mulps(xmm2, xmm1); |
| 726 __ subps(xmm2, xmm0); | 717 __ subps(xmm2, xmm0); |
| 727 __ divps(xmm2, xmm1); | 718 __ divps(xmm2, xmm1); |
| 728 __ cvttss2si(rax, xmm2); | 719 __ cvttss2si(rax, xmm2); |
| 729 __ ret(0); | 720 __ ret(0); |
| 730 } | 721 } |
| 731 | 722 |
| 732 CodeDesc desc; | 723 CodeDesc desc; |
| 733 assm.GetCode(&desc); | 724 assm.GetCode(&desc); |
| 734 Code* code = Code::cast(isolate->heap()->CreateCode( | 725 Handle<Code> code = isolate->factory()->NewCode( |
| 735 desc, | 726 desc, |
| 736 Code::ComputeFlags(Code::STUB), | 727 Code::ComputeFlags(Code::STUB), |
| 737 Handle<Code>())->ToObjectChecked()); | 728 Handle<Code>()); |
| 738 CHECK(code->IsCode()); | |
| 739 #ifdef OBJECT_PRINT | 729 #ifdef OBJECT_PRINT |
| 740 Code::cast(code)->Print(); | 730 code->Print(); |
| 741 #endif | 731 #endif |
| 742 | 732 |
| 743 F6 f = FUNCTION_CAST<F6>(Code::cast(code)->entry()); | 733 F6 f = FUNCTION_CAST<F6>(code->entry()); |
| 744 CHECK_EQ(2, f(1.0, 2.0)); | 734 CHECK_EQ(2, f(1.0, 2.0)); |
| 745 } | 735 } |
| 746 #undef __ | 736 #undef __ |
| OLD | NEW |