| 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 2631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 size_t actual_size; | 2642 size_t actual_size; |
| 2643 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, | 2643 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 2644 &actual_size, | 2644 &actual_size, |
| 2645 true)); | 2645 true)); |
| 2646 CHECK(buffer); | 2646 CHECK(buffer); |
| 2647 Isolate* isolate = CcTest::i_isolate(); | 2647 Isolate* isolate = CcTest::i_isolate(); |
| 2648 HandleScope handles(isolate); | 2648 HandleScope handles(isolate); |
| 2649 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); | 2649 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 2650 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. | 2650 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. |
| 2651 masm->set_allow_stub_calls(false); | 2651 masm->set_allow_stub_calls(false); |
| 2652 __ push(rbp); | 2652 EntryCode(masm); |
| 2653 __ movq(rbp, rsp); | |
| 2654 __ subq(rsp, Immediate(1 * kPointerSize)); | 2653 __ subq(rsp, Immediate(1 * kPointerSize)); |
| 2655 EntryCode(masm); | |
| 2656 Label exit; | 2654 Label exit; |
| 2657 | 2655 |
| 2658 // Test 1. | 2656 // Test 1. |
| 2659 __ movq(rax, Immediate(1)); // Test number. | 2657 __ movq(rax, Immediate(1)); // Test number. |
| 2660 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); | 2658 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); |
| 2661 __ movq(rcx, Immediate(-1)); | 2659 __ movq(rcx, Immediate(-1)); |
| 2662 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Byte()); | 2660 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Byte()); |
| 2663 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); | 2661 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); |
| 2664 __ movl(rdx, Immediate(255)); | 2662 __ movl(rdx, Immediate(255)); |
| 2665 __ cmpq(rcx, rdx); | 2663 __ cmpq(rcx, rdx); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2728 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); | 2726 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); |
| 2729 __ Set(rdx, V8_2PART_UINT64_C(0x11223344, 55667788)); | 2727 __ Set(rdx, V8_2PART_UINT64_C(0x11223344, 55667788)); |
| 2730 __ cmpq(rcx, rdx); | 2728 __ cmpq(rcx, rdx); |
| 2731 __ j(not_equal, &exit); | 2729 __ j(not_equal, &exit); |
| 2732 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::External()); | 2730 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::External()); |
| 2733 __ cmpq(rcx, rdx); | 2731 __ cmpq(rcx, rdx); |
| 2734 __ j(not_equal, &exit); | 2732 __ j(not_equal, &exit); |
| 2735 | 2733 |
| 2736 __ xor_(rax, rax); // Success. | 2734 __ xor_(rax, rax); // Success. |
| 2737 __ bind(&exit); | 2735 __ bind(&exit); |
| 2736 __ addq(rsp, Immediate(1 * kPointerSize)); |
| 2738 ExitCode(masm); | 2737 ExitCode(masm); |
| 2739 __ movq(rsp, rbp); | |
| 2740 __ pop(rbp); | |
| 2741 __ ret(0); | 2738 __ ret(0); |
| 2742 | 2739 |
| 2743 CodeDesc desc; | 2740 CodeDesc desc; |
| 2744 masm->GetCode(&desc); | 2741 masm->GetCode(&desc); |
| 2745 // Call the function from C++.A | 2742 // Call the function from C++. |
| 2746 int result = FUNCTION_CAST<F0>(buffer)(); | 2743 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2747 CHECK_EQ(0, result); | 2744 CHECK_EQ(0, result); |
| 2748 } | 2745 } |
| 2749 | 2746 |
| 2750 | 2747 |
| 2751 #undef __ | 2748 #undef __ |
| OLD | NEW |