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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 // MANUAL indicates that the scope shouldn't actually generate code to set up | 627 // MANUAL indicates that the scope shouldn't actually generate code to set up |
628 // the frame (that is done below). | 628 // the frame (that is done below). |
629 FrameScope frame_scope(masm, StackFrame::MANUAL); | 629 FrameScope frame_scope(masm, StackFrame::MANUAL); |
630 __ push(ebp); // Caller's frame pointer. | 630 __ push(ebp); // Caller's frame pointer. |
631 __ mov(ebp, esp); | 631 __ mov(ebp, esp); |
632 __ push(esi); // Callee's context. | 632 __ push(esi); // Callee's context. |
633 __ push(edi); // Callee's JS function. | 633 __ push(edi); // Callee's JS function. |
634 | 634 |
635 // Get the bytecode array from the function object and load the pointer to the | 635 // Get the bytecode array from the function object and load the pointer to the |
636 // first entry into edi (InterpreterBytecodeRegister). | 636 // first entry into edi (InterpreterBytecodeRegister). |
637 __ mov(edi, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 637 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
638 __ mov(edi, FieldOperand(edi, SharedFunctionInfo::kFunctionDataOffset)); | 638 __ mov(kInterpreterBytecodeArrayRegister, |
| 639 FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset)); |
639 | 640 |
640 if (FLAG_debug_code) { | 641 if (FLAG_debug_code) { |
641 // Check function data field is actually a BytecodeArray object. | 642 // Check function data field is actually a BytecodeArray object. |
642 __ AssertNotSmi(edi); | 643 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); |
643 __ CmpObjectType(edi, BYTECODE_ARRAY_TYPE, eax); | 644 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, |
| 645 eax); |
644 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); | 646 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); |
645 } | 647 } |
646 | 648 |
647 // Allocate the local and temporary register file on the stack. | 649 // Allocate the local and temporary register file on the stack. |
648 { | 650 { |
649 // Load frame size from the BytecodeArray object. | 651 // Load frame size from the BytecodeArray object. |
650 __ mov(ebx, FieldOperand(edi, BytecodeArray::kFrameSizeOffset)); | 652 __ mov(ebx, FieldOperand(kInterpreterBytecodeArrayRegister, |
| 653 BytecodeArray::kFrameSizeOffset)); |
651 | 654 |
652 // Do a stack check to ensure we don't go over the limit. | 655 // Do a stack check to ensure we don't go over the limit. |
653 Label ok; | 656 Label ok; |
654 __ mov(ecx, esp); | 657 __ mov(ecx, esp); |
655 __ sub(ecx, ebx); | 658 __ sub(ecx, ebx); |
656 ExternalReference stack_limit = | 659 ExternalReference stack_limit = |
657 ExternalReference::address_of_real_stack_limit(masm->isolate()); | 660 ExternalReference::address_of_real_stack_limit(masm->isolate()); |
658 __ cmp(ecx, Operand::StaticVariable(stack_limit)); | 661 __ cmp(ecx, Operand::StaticVariable(stack_limit)); |
659 __ j(above_equal, &ok, Label::kNear); | 662 __ j(above_equal, &ok); |
660 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); | 663 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); |
661 __ bind(&ok); | 664 __ bind(&ok); |
662 | 665 |
663 // If ok, push undefined as the initial value for all register file entries. | 666 // If ok, push undefined as the initial value for all register file entries. |
664 // Note: there should always be at least one stack slot for the return | |
665 // register in the register file. | |
666 Label loop_header; | 667 Label loop_header; |
| 668 Label loop_check; |
667 __ mov(eax, Immediate(masm->isolate()->factory()->undefined_value())); | 669 __ mov(eax, Immediate(masm->isolate()->factory()->undefined_value())); |
| 670 __ jmp(&loop_check); |
668 __ bind(&loop_header); | 671 __ bind(&loop_header); |
669 // TODO(rmcilroy): Consider doing more than one push per loop iteration. | 672 // TODO(rmcilroy): Consider doing more than one push per loop iteration. |
670 __ push(eax); | 673 __ push(eax); |
671 // Continue loop if not done. | 674 // Continue loop if not done. |
| 675 __ bind(&loop_check); |
672 __ sub(ebx, Immediate(kPointerSize)); | 676 __ sub(ebx, Immediate(kPointerSize)); |
673 __ j(not_equal, &loop_header, Label::kNear); | 677 __ j(greater_equal, &loop_header); |
674 } | 678 } |
675 | 679 |
676 // TODO(rmcilroy): List of things not currently dealt with here but done in | 680 // TODO(rmcilroy): List of things not currently dealt with here but done in |
677 // fullcodegen's prologue: | 681 // fullcodegen's prologue: |
678 // - Support profiler (specifically profiling_counter). | 682 // - Support profiler (specifically profiling_counter). |
679 // - Call ProfileEntryHookStub when isolate has a function_entry_hook. | 683 // - Call ProfileEntryHookStub when isolate has a function_entry_hook. |
680 // - Allow simulator stop operations if FLAG_stop_at is set. | 684 // - Allow simulator stop operations if FLAG_stop_at is set. |
681 // - Deal with sloppy mode functions which need to replace the | 685 // - Deal with sloppy mode functions which need to replace the |
682 // receiver with the global proxy when called as functions (without an | 686 // receiver with the global proxy when called as functions (without an |
683 // explicit receiver object). | 687 // explicit receiver object). |
684 // - Code aging of the BytecodeArray object. | 688 // - Code aging of the BytecodeArray object. |
685 // - Supporting FLAG_trace. | 689 // - Supporting FLAG_trace. |
686 // | 690 // |
687 // The following items are also not done here, and will probably be done using | 691 // The following items are also not done here, and will probably be done using |
688 // explicit bytecodes instead: | 692 // explicit bytecodes instead: |
689 // - Allocating a new local context if applicable. | 693 // - Allocating a new local context if applicable. |
690 // - Setting up a local binding to the this function, which is used in | 694 // - Setting up a local binding to the this function, which is used in |
691 // derived constructors with super calls. | 695 // derived constructors with super calls. |
692 // - Setting new.target if required. | 696 // - Setting new.target if required. |
693 // - Dealing with REST parameters (only if | 697 // - Dealing with REST parameters (only if |
694 // https://codereview.chromium.org/1235153006 doesn't land by then). | 698 // https://codereview.chromium.org/1235153006 doesn't land by then). |
695 // - Dealing with argument objects. | 699 // - Dealing with argument objects. |
696 | 700 |
697 // Perform stack guard check. | 701 // Perform stack guard check. |
698 { | 702 { |
699 Label ok; | 703 Label ok; |
700 ExternalReference stack_limit = | 704 ExternalReference stack_limit = |
701 ExternalReference::address_of_stack_limit(masm->isolate()); | 705 ExternalReference::address_of_stack_limit(masm->isolate()); |
702 __ cmp(esp, Operand::StaticVariable(stack_limit)); | 706 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
703 __ j(above_equal, &ok, Label::kNear); | 707 __ j(above_equal, &ok); |
704 __ CallRuntime(Runtime::kStackGuard, 0); | 708 __ CallRuntime(Runtime::kStackGuard, 0); |
705 __ bind(&ok); | 709 __ bind(&ok); |
706 } | 710 } |
707 | 711 |
708 // Load bytecode offset and dispatch table into registers. | 712 // Load accumulator, register file, bytecode offset, dispatch table into |
709 __ mov(ecx, Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); | 713 // registers. |
| 714 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); |
| 715 __ mov(kInterpreterRegisterFileRegister, ebp); |
| 716 __ sub( |
| 717 kInterpreterRegisterFileRegister, |
| 718 Immediate(kPointerSize + StandardFrameConstants::kFixedFrameSizeFromFp)); |
| 719 __ mov(kInterpreterBytecodeOffsetRegister, |
| 720 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag)); |
710 // Since the dispatch table root might be set after builtins are generated, | 721 // Since the dispatch table root might be set after builtins are generated, |
711 // load directly from the roots table. | 722 // load directly from the roots table. |
712 __ LoadRoot(ebx, Heap::kInterpreterTableRootIndex); | 723 __ LoadRoot(kInterpreterDispatchTableRegister, |
713 __ add(ebx, Immediate(FixedArray::kHeaderSize - kHeapObjectTag)); | 724 Heap::kInterpreterTableRootIndex); |
| 725 __ add(kInterpreterDispatchTableRegister, |
| 726 Immediate(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 727 |
| 728 // TODO(rmcilroy) Push our context as a stack located parameter of the |
| 729 // bytecode handler. |
714 | 730 |
715 // Dispatch to the first bytecode handler for the function. | 731 // Dispatch to the first bytecode handler for the function. |
716 __ movzx_b(eax, Operand(edi, ecx, times_1, 0)); | 732 __ movzx_b(esi, Operand(kInterpreterBytecodeArrayRegister, |
717 __ mov(eax, Operand(ebx, eax, times_pointer_size, 0)); | 733 kInterpreterBytecodeOffsetRegister, times_1, 0)); |
| 734 __ mov(esi, Operand(kInterpreterDispatchTableRegister, esi, |
| 735 times_pointer_size, 0)); |
718 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging | 736 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging |
719 // and header removal. | 737 // and header removal. |
720 __ add(eax, Immediate(Code::kHeaderSize - kHeapObjectTag)); | 738 __ add(esi, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
721 __ jmp(eax); | 739 __ call(esi); |
722 } | 740 } |
723 | 741 |
724 | 742 |
725 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { | 743 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { |
726 // TODO(rmcilroy): List of things not currently dealt with here but done in | 744 // TODO(rmcilroy): List of things not currently dealt with here but done in |
727 // fullcodegen's EmitReturnSequence. | 745 // fullcodegen's EmitReturnSequence. |
728 // - Supporting FLAG_trace for Runtime::TraceExit. | 746 // - Supporting FLAG_trace for Runtime::TraceExit. |
729 // - Support profiler (specifically decrementing profiling_counter | 747 // - Support profiler (specifically decrementing profiling_counter |
730 // appropriately and calling out to HandleInterrupts if necessary). | 748 // appropriately and calling out to HandleInterrupts if necessary). |
731 | 749 |
732 // Load return value into r0. | 750 // The return value is in accumulator, which is already in rax. |
733 __ mov(eax, Operand(ebp, -kPointerSize - | 751 |
734 StandardFrameConstants::kFixedFrameSizeFromFp)); | |
735 // Leave the frame (also dropping the register file). | 752 // Leave the frame (also dropping the register file). |
736 __ leave(); | 753 __ leave(); |
737 // Return droping receiver + arguments. | 754 // Return droping receiver + arguments. |
738 // TODO(rmcilroy): Get number of arguments from BytecodeArray. | 755 // TODO(rmcilroy): Get number of arguments from BytecodeArray. |
739 __ Ret(1 * kPointerSize, ecx); | 756 __ Ret(1 * kPointerSize, ecx); |
740 } | 757 } |
741 | 758 |
742 | 759 |
743 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 760 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
744 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 761 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 | 1781 |
1765 __ bind(&ok); | 1782 __ bind(&ok); |
1766 __ ret(0); | 1783 __ ret(0); |
1767 } | 1784 } |
1768 | 1785 |
1769 #undef __ | 1786 #undef __ |
1770 } // namespace internal | 1787 } // namespace internal |
1771 } // namespace v8 | 1788 } // namespace v8 |
1772 | 1789 |
1773 #endif // V8_TARGET_ARCH_X87 | 1790 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |