Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1643)

Side by Side Diff: src/ia32/builtins-ia32.cc

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

Powered by Google App Engine
This is Rietveld 408576698