| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
| 10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 __ push(eax); | 607 __ push(eax); |
| 608 // Continue loop if not done. | 608 // Continue loop if not done. |
| 609 __ bind(&loop_check); | 609 __ bind(&loop_check); |
| 610 __ sub(ebx, Immediate(kPointerSize)); | 610 __ sub(ebx, Immediate(kPointerSize)); |
| 611 __ j(greater_equal, &loop_header); | 611 __ j(greater_equal, &loop_header); |
| 612 } | 612 } |
| 613 | 613 |
| 614 // Load accumulator, register file, bytecode offset, dispatch table into | 614 // Load accumulator, register file, bytecode offset, dispatch table into |
| 615 // registers. | 615 // registers. |
| 616 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); | 616 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); |
| 617 __ mov(kInterpreterRegisterFileRegister, ebp); | 617 __ mov(edx, ebp); |
| 618 __ add(kInterpreterRegisterFileRegister, | 618 __ add(edx, Immediate(InterpreterFrameConstants::kRegisterFileFromFp)); |
| 619 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp)); | |
| 620 __ mov(kInterpreterBytecodeOffsetRegister, | 619 __ mov(kInterpreterBytecodeOffsetRegister, |
| 621 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); | 620 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); |
| 622 __ mov(kInterpreterDispatchTableRegister, | 621 __ mov(kInterpreterDispatchTableRegister, |
| 623 Immediate(ExternalReference::interpreter_dispatch_table_address( | 622 Immediate(ExternalReference::interpreter_dispatch_table_address( |
| 624 masm->isolate()))); | 623 masm->isolate()))); |
| 625 | 624 |
| 626 // Dispatch to the first bytecode handler for the function. | 625 // Dispatch to the first bytecode handler for the function. |
| 627 __ movzx_b(ebx, Operand(kInterpreterBytecodeArrayRegister, | 626 __ movzx_b(ebx, Operand(kInterpreterBytecodeArrayRegister, |
| 628 kInterpreterBytecodeOffsetRegister, times_1, 0)); | 627 kInterpreterBytecodeOffsetRegister, times_1, 0)); |
| 629 __ mov(ebx, Operand(kInterpreterDispatchTableRegister, ebx, | 628 __ mov(ebx, Operand(kInterpreterDispatchTableRegister, ebx, |
| 630 times_pointer_size, 0)); | 629 times_pointer_size, 0)); |
| 631 __ call(ebx); | 630 __ call(ebx); |
| 632 | 631 |
| 633 // Even though the first bytecode handler was called, we will never return. | 632 // Even though the first bytecode handler was called, we will never return. |
| 634 __ Abort(kUnexpectedReturnFromBytecodeHandler); | 633 __ Abort(kUnexpectedReturnFromBytecodeHandler); |
| 635 | 634 |
| 636 // Load debug copy of the bytecode array. | 635 // Load debug copy of the bytecode array. |
| 637 __ bind(&load_debug_bytecode_array); | 636 __ bind(&load_debug_bytecode_array); |
| 638 Register debug_info = kInterpreterBytecodeArrayRegister; | 637 Register debug_info = kInterpreterBytecodeArrayRegister; |
| 639 __ mov(debug_info, FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset)); | 638 __ mov(debug_info, FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset)); |
| 640 __ mov(kInterpreterBytecodeArrayRegister, | 639 __ mov(kInterpreterBytecodeArrayRegister, |
| 641 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex)); | 640 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex)); |
| 642 __ jmp(&bytecode_array_loaded); | 641 __ jmp(&bytecode_array_loaded); |
| 643 } | 642 } |
| 644 | 643 |
| 645 | 644 |
| 646 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { | 645 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { |
| 647 // TODO(rmcilroy): List of things not currently dealt with here but done in | 646 // The return value is in accumulator, which is already in eax. |
| 648 // fullcodegen's EmitReturnSequence. | |
| 649 // - Supporting FLAG_trace for Runtime::TraceExit. | |
| 650 // - Support profiler (specifically decrementing profiling_counter | |
| 651 // appropriately and calling out to HandleInterrupts if necessary). | |
| 652 | |
| 653 // The return value is in accumulator, which is already in rax. | |
| 654 | 647 |
| 655 // Leave the frame (also dropping the register file). | 648 // Leave the frame (also dropping the register file). |
| 656 __ leave(); | 649 __ leave(); |
| 657 | 650 |
| 658 // Drop receiver + arguments and return. | 651 // Drop receiver + arguments and return. |
| 659 __ mov(ebx, FieldOperand(kInterpreterBytecodeArrayRegister, | 652 __ mov(ebx, FieldOperand(kInterpreterBytecodeArrayRegister, |
| 660 BytecodeArray::kParameterSizeOffset)); | 653 BytecodeArray::kParameterSizeOffset)); |
| 661 __ pop(ecx); | 654 __ pop(ecx); |
| 662 __ add(esp, ebx); | 655 __ add(esp, ebx); |
| 663 __ push(ecx); | 656 __ push(ecx); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 | 739 |
| 747 // Re-push return address. | 740 // Re-push return address. |
| 748 __ Push(ecx); | 741 __ Push(ecx); |
| 749 | 742 |
| 750 // Call the constructor with unmodified eax, edi, ebi values. | 743 // Call the constructor with unmodified eax, edi, ebi values. |
| 751 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 744 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
| 752 } | 745 } |
| 753 | 746 |
| 754 | 747 |
| 755 static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) { | 748 static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) { |
| 756 // Initialize register file register and dispatch table register. | 749 // Initialize the dispatch table register. |
| 757 __ mov(kInterpreterRegisterFileRegister, ebp); | |
| 758 __ add(kInterpreterRegisterFileRegister, | |
| 759 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp)); | |
| 760 __ mov(kInterpreterDispatchTableRegister, | 750 __ mov(kInterpreterDispatchTableRegister, |
| 761 Immediate(ExternalReference::interpreter_dispatch_table_address( | 751 Immediate(ExternalReference::interpreter_dispatch_table_address( |
| 762 masm->isolate()))); | 752 masm->isolate()))); |
| 763 | 753 |
| 764 // Get the bytecode array pointer from the frame. | 754 // Get the bytecode array pointer from the frame. |
| 765 __ mov(kInterpreterBytecodeArrayRegister, | 755 __ mov(kInterpreterBytecodeArrayRegister, |
| 766 Operand(kInterpreterRegisterFileRegister, | 756 Operand(ebp, InterpreterFrameConstants::kBytecodeArrayFromFp)); |
| 767 InterpreterFrameConstants::kBytecodeArrayFromRegisterPointer)); | |
| 768 | 757 |
| 769 if (FLAG_debug_code) { | 758 if (FLAG_debug_code) { |
| 770 // Check function data field is actually a BytecodeArray object. | 759 // Check function data field is actually a BytecodeArray object. |
| 771 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); | 760 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); |
| 772 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, | 761 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, |
| 773 ebx); | 762 ebx); |
| 774 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); | 763 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); |
| 775 } | 764 } |
| 776 | 765 |
| 777 // Get the target bytecode offset from the frame. | 766 // Get the target bytecode offset from the frame. |
| 778 __ mov( | 767 __ mov(kInterpreterBytecodeOffsetRegister, |
| 779 kInterpreterBytecodeOffsetRegister, | 768 Operand(ebp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); |
| 780 Operand(kInterpreterRegisterFileRegister, | |
| 781 InterpreterFrameConstants::kBytecodeOffsetFromRegisterPointer)); | |
| 782 __ SmiUntag(kInterpreterBytecodeOffsetRegister); | 769 __ SmiUntag(kInterpreterBytecodeOffsetRegister); |
| 783 | 770 |
| 784 // Dispatch to the target bytecode. | 771 // Dispatch to the target bytecode. |
| 785 __ movzx_b(ebx, Operand(kInterpreterBytecodeArrayRegister, | 772 __ movzx_b(ebx, Operand(kInterpreterBytecodeArrayRegister, |
| 786 kInterpreterBytecodeOffsetRegister, times_1, 0)); | 773 kInterpreterBytecodeOffsetRegister, times_1, 0)); |
| 787 __ mov(ebx, Operand(kInterpreterDispatchTableRegister, ebx, | 774 __ mov(ebx, Operand(kInterpreterDispatchTableRegister, ebx, |
| 788 times_pointer_size, 0)); | 775 times_pointer_size, 0)); |
| 789 __ jmp(ebx); | 776 __ jmp(ebx); |
| 790 } | 777 } |
| 791 | 778 |
| (...skipping 2104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2896 // And "return" to the OSR entry point of the function. | 2883 // And "return" to the OSR entry point of the function. |
| 2897 __ ret(0); | 2884 __ ret(0); |
| 2898 } | 2885 } |
| 2899 | 2886 |
| 2900 | 2887 |
| 2901 #undef __ | 2888 #undef __ |
| 2902 } // namespace internal | 2889 } // namespace internal |
| 2903 } // namespace v8 | 2890 } // namespace v8 |
| 2904 | 2891 |
| 2905 #endif // V8_TARGET_ARCH_X87 | 2892 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |