| 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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 __ push(eax); | 606 __ push(eax); |
| 607 // Continue loop if not done. | 607 // Continue loop if not done. |
| 608 __ bind(&loop_check); | 608 __ bind(&loop_check); |
| 609 __ sub(ebx, Immediate(kPointerSize)); | 609 __ sub(ebx, Immediate(kPointerSize)); |
| 610 __ j(greater_equal, &loop_header); | 610 __ j(greater_equal, &loop_header); |
| 611 } | 611 } |
| 612 | 612 |
| 613 // Load accumulator, register file, bytecode offset, dispatch table into | 613 // Load accumulator, register file, bytecode offset, dispatch table into |
| 614 // registers. | 614 // registers. |
| 615 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); | 615 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); |
| 616 __ mov(kInterpreterRegisterFileRegister, ebp); | 616 __ mov(edx, ebp); |
| 617 __ add(kInterpreterRegisterFileRegister, | 617 __ add(edx, Immediate(InterpreterFrameConstants::kRegisterFileFromFp)); |
| 618 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp)); | |
| 619 __ mov(kInterpreterBytecodeOffsetRegister, | 618 __ mov(kInterpreterBytecodeOffsetRegister, |
| 620 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); | 619 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); |
| 621 __ mov(kInterpreterDispatchTableRegister, | 620 __ mov(kInterpreterDispatchTableRegister, |
| 622 Immediate(ExternalReference::interpreter_dispatch_table_address( | 621 Immediate(ExternalReference::interpreter_dispatch_table_address( |
| 623 masm->isolate()))); | 622 masm->isolate()))); |
| 624 | 623 |
| 625 // Dispatch to the first bytecode handler for the function. | 624 // Dispatch to the first bytecode handler for the function. |
| 626 __ movzx_b(ebx, Operand(kInterpreterBytecodeArrayRegister, | 625 __ movzx_b(ebx, Operand(kInterpreterBytecodeArrayRegister, |
| 627 kInterpreterBytecodeOffsetRegister, times_1, 0)); | 626 kInterpreterBytecodeOffsetRegister, times_1, 0)); |
| 628 __ mov(ebx, Operand(kInterpreterDispatchTableRegister, ebx, | 627 __ mov(ebx, Operand(kInterpreterDispatchTableRegister, ebx, |
| 629 times_pointer_size, 0)); | 628 times_pointer_size, 0)); |
| 630 __ call(ebx); | 629 __ call(ebx); |
| 631 | 630 |
| 632 // Even though the first bytecode handler was called, we will never return. | 631 // Even though the first bytecode handler was called, we will never return. |
| 633 __ Abort(kUnexpectedReturnFromBytecodeHandler); | 632 __ Abort(kUnexpectedReturnFromBytecodeHandler); |
| 634 | 633 |
| 635 // Load debug copy of the bytecode array. | 634 // Load debug copy of the bytecode array. |
| 636 __ bind(&load_debug_bytecode_array); | 635 __ bind(&load_debug_bytecode_array); |
| 637 Register debug_info = kInterpreterBytecodeArrayRegister; | 636 Register debug_info = kInterpreterBytecodeArrayRegister; |
| 638 __ mov(debug_info, FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset)); | 637 __ mov(debug_info, FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset)); |
| 639 __ mov(kInterpreterBytecodeArrayRegister, | 638 __ mov(kInterpreterBytecodeArrayRegister, |
| 640 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex)); | 639 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex)); |
| 641 __ jmp(&bytecode_array_loaded); | 640 __ jmp(&bytecode_array_loaded); |
| 642 } | 641 } |
| 643 | 642 |
| 644 | 643 |
| 645 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { | 644 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { |
| 646 // TODO(rmcilroy): List of things not currently dealt with here but done in | 645 // The return value is in accumulator, which is already in eax. |
| 647 // fullcodegen's EmitReturnSequence. | |
| 648 // - Supporting FLAG_trace for Runtime::TraceExit. | |
| 649 // - Support profiler (specifically decrementing profiling_counter | |
| 650 // appropriately and calling out to HandleInterrupts if necessary). | |
| 651 | |
| 652 // The return value is in accumulator, which is already in rax. | |
| 653 | 646 |
| 654 // Leave the frame (also dropping the register file). | 647 // Leave the frame (also dropping the register file). |
| 655 __ leave(); | 648 __ leave(); |
| 656 | 649 |
| 657 // Drop receiver + arguments and return. | 650 // Drop receiver + arguments and return. |
| 658 __ mov(ebx, FieldOperand(kInterpreterBytecodeArrayRegister, | 651 __ mov(ebx, FieldOperand(kInterpreterBytecodeArrayRegister, |
| 659 BytecodeArray::kParameterSizeOffset)); | 652 BytecodeArray::kParameterSizeOffset)); |
| 660 __ pop(ecx); | 653 __ pop(ecx); |
| 661 __ add(esp, ebx); | 654 __ add(esp, ebx); |
| 662 __ push(ecx); | 655 __ push(ecx); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 | 738 |
| 746 // Re-push return address. | 739 // Re-push return address. |
| 747 __ Push(ecx); | 740 __ Push(ecx); |
| 748 | 741 |
| 749 // Call the constructor with unmodified eax, edi, ebi values. | 742 // Call the constructor with unmodified eax, edi, ebi values. |
| 750 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 743 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
| 751 } | 744 } |
| 752 | 745 |
| 753 | 746 |
| 754 static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) { | 747 static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) { |
| 755 // Initialize register file register and dispatch table register. | 748 // Initialize the dispatch table register. |
| 756 __ mov(kInterpreterRegisterFileRegister, ebp); | |
| 757 __ add(kInterpreterRegisterFileRegister, | |
| 758 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp)); | |
| 759 __ mov(kInterpreterDispatchTableRegister, | 749 __ mov(kInterpreterDispatchTableRegister, |
| 760 Immediate(ExternalReference::interpreter_dispatch_table_address( | 750 Immediate(ExternalReference::interpreter_dispatch_table_address( |
| 761 masm->isolate()))); | 751 masm->isolate()))); |
| 762 | 752 |
| 763 // Get the bytecode array pointer from the frame. | 753 // Get the bytecode array pointer from the frame. |
| 764 __ mov(kInterpreterBytecodeArrayRegister, | 754 __ mov(kInterpreterBytecodeArrayRegister, |
| 765 Operand(kInterpreterRegisterFileRegister, | 755 Operand(ebp, InterpreterFrameConstants::kBytecodeArrayFromFp)); |
| 766 InterpreterFrameConstants::kBytecodeArrayFromRegisterPointer)); | |
| 767 | 756 |
| 768 if (FLAG_debug_code) { | 757 if (FLAG_debug_code) { |
| 769 // Check function data field is actually a BytecodeArray object. | 758 // Check function data field is actually a BytecodeArray object. |
| 770 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); | 759 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); |
| 771 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, | 760 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, |
| 772 ebx); | 761 ebx); |
| 773 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); | 762 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); |
| 774 } | 763 } |
| 775 | 764 |
| 776 // Get the target bytecode offset from the frame. | 765 // Get the target bytecode offset from the frame. |
| 777 __ mov( | 766 __ mov(kInterpreterBytecodeOffsetRegister, |
| 778 kInterpreterBytecodeOffsetRegister, | 767 Operand(ebp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); |
| 779 Operand(kInterpreterRegisterFileRegister, | |
| 780 InterpreterFrameConstants::kBytecodeOffsetFromRegisterPointer)); | |
| 781 __ SmiUntag(kInterpreterBytecodeOffsetRegister); | 768 __ SmiUntag(kInterpreterBytecodeOffsetRegister); |
| 782 | 769 |
| 783 // Dispatch to the target bytecode. | 770 // Dispatch to the target bytecode. |
| 784 __ movzx_b(ebx, Operand(kInterpreterBytecodeArrayRegister, | 771 __ movzx_b(ebx, Operand(kInterpreterBytecodeArrayRegister, |
| 785 kInterpreterBytecodeOffsetRegister, times_1, 0)); | 772 kInterpreterBytecodeOffsetRegister, times_1, 0)); |
| 786 __ mov(ebx, Operand(kInterpreterDispatchTableRegister, ebx, | 773 __ mov(ebx, Operand(kInterpreterDispatchTableRegister, ebx, |
| 787 times_pointer_size, 0)); | 774 times_pointer_size, 0)); |
| 788 __ jmp(ebx); | 775 __ jmp(ebx); |
| 789 } | 776 } |
| 790 | 777 |
| (...skipping 2078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2869 // And "return" to the OSR entry point of the function. | 2856 // And "return" to the OSR entry point of the function. |
| 2870 __ ret(0); | 2857 __ ret(0); |
| 2871 } | 2858 } |
| 2872 | 2859 |
| 2873 | 2860 |
| 2874 #undef __ | 2861 #undef __ |
| 2875 } // namespace internal | 2862 } // namespace internal |
| 2876 } // namespace v8 | 2863 } // namespace v8 |
| 2877 | 2864 |
| 2878 #endif // V8_TARGET_ARCH_IA32 | 2865 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |