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

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

Issue 1245133002: [interpreter] Add Interpreter{Entry,Exit}Trampoline builtins. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@oth_bytecode_array
Patch Set: Adding MIPS based on https://codereview.chromium.org/1257953002/ 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/heap/heap.cc ('k') | src/interpreter/interpreter.cc » ('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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { 598 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
599 Generate_JSEntryTrampolineHelper(masm, false); 599 Generate_JSEntryTrampolineHelper(masm, false);
600 } 600 }
601 601
602 602
603 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { 603 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
604 Generate_JSEntryTrampolineHelper(masm, true); 604 Generate_JSEntryTrampolineHelper(masm, true);
605 } 605 }
606 606
607 607
608 // Generate code for entering a JS function with the interpreter.
609 // On entry to the function the receiver and arguments have been pushed on the
610 // stack left to right. The actual argument count matches the formal parameter
611 // count expected by the function.
612 //
613 // The live registers are:
614 // o edi: the JS function object being called
615 // o esi: our context
616 // o ebp: the caller's frame pointer
617 // o esp: stack pointer (pointing to return address)
618 //
619 // The function builds a JS frame. Please see JavaScriptFrameConstants in
620 // frames-ia32.h for its layout.
621 // TODO(rmcilroy): We will need to include the current bytecode pointer in the
622 // frame.
623 void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
624 // Open a frame scope to indicate that there is a frame on the stack. The
625 // MANUAL indicates that the scope shouldn't actually generate code to set up
626 // the frame (that is done below).
627 FrameScope frame_scope(masm, StackFrame::MANUAL);
628 __ push(ebp); // Caller's frame pointer.
629 __ mov(ebp, esp);
630 __ push(esi); // Callee's context.
631 __ push(edi); // Callee's JS function.
632
633 // Get the bytecode array from the function object and load the pointer to the
634 // first entry into edi (InterpreterBytecodeRegister).
635 __ mov(edi, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
636 __ mov(edi, FieldOperand(edi, SharedFunctionInfo::kFunctionDataOffset));
637
638 if (FLAG_debug_code) {
639 // Check function data field is actually a BytecodeArray object.
640 __ AssertNotSmi(edi);
641 __ CmpObjectType(edi, BYTECODE_ARRAY_TYPE, eax);
642 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry);
643 }
644
645 // Allocate the local and temporary register file on the stack.
646 {
647 // Load frame size from the BytecodeArray object.
648 __ mov(ebx, FieldOperand(edi, BytecodeArray::kFrameSizeOffset));
649
650 // Do a stack check to ensure we don't go over the limit.
651 Label ok;
652 __ mov(ecx, esp);
653 __ sub(ecx, ebx);
654 ExternalReference stack_limit =
655 ExternalReference::address_of_real_stack_limit(masm->isolate());
656 __ cmp(ecx, Operand::StaticVariable(stack_limit));
657 __ j(above_equal, &ok, Label::kNear);
658 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION);
659 __ bind(&ok);
660
661 // If ok, push undefined as the initial value for all register file entries.
662 // Note: there should always be at least one stack slot for the return
663 // register in the register file.
664 Label loop_header;
665 __ mov(eax, Immediate(masm->isolate()->factory()->undefined_value()));
666 __ bind(&loop_header);
667 // TODO(rmcilroy): Consider doing more than one push per loop iteration.
668 __ push(eax);
669 // Continue loop if not done.
670 __ sub(ebx, Immediate(kPointerSize));
671 __ j(not_equal, &loop_header, Label::kNear);
672 }
673
674 // TODO(rmcilroy): List of things not currently dealt with here but done in
675 // fullcodegen's prologue:
676 // - Support profiler (specifically profiling_counter).
677 // - Call ProfileEntryHookStub when isolate has a function_entry_hook.
678 // - Allow simulator stop operations if FLAG_stop_at is set.
679 // - Deal with sloppy mode functions which need to replace the
680 // receiver with the global proxy when called as functions (without an
681 // explicit receiver object).
682 // - Code aging of the BytecodeArray object.
683 // - Supporting FLAG_trace.
684 //
685 // The following items are also not done here, and will probably be done using
686 // explicit bytecodes instead:
687 // - Allocating a new local context if applicable.
688 // - Setting up a local binding to the this function, which is used in
689 // derived constructors with super calls.
690 // - Setting new.target if required.
691 // - Dealing with REST parameters (only if
692 // https://codereview.chromium.org/1235153006 doesn't land by then).
693 // - Dealing with argument objects.
694
695 // Perform stack guard check.
696 {
697 Label ok;
698 ExternalReference stack_limit =
699 ExternalReference::address_of_stack_limit(masm->isolate());
700 __ cmp(esp, Operand::StaticVariable(stack_limit));
701 __ j(above_equal, &ok, Label::kNear);
702 __ CallRuntime(Runtime::kStackGuard, 0);
703 __ bind(&ok);
704 }
705
706 // Load bytecode offset and dispatch table into registers.
707 __ mov(ecx, Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag));
708 // Since the dispatch table root might be set after builtins are generated,
709 // load directly from the roots table.
710 __ LoadRoot(ebx, Heap::kInterpreterTableRootIndex);
711 __ add(ebx, Immediate(FixedArray::kHeaderSize - kHeapObjectTag));
712
713 // Dispatch to the first bytecode handler for the function.
714 __ movzx_b(eax, Operand(edi, ecx, times_1, 0));
715 __ mov(eax, Operand(ebx, eax, times_pointer_size, 0));
716 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging
717 // and header removal.
718 __ add(eax, Immediate(Code::kHeaderSize - kHeapObjectTag));
719 __ jmp(eax);
720 }
721
722
723 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) {
724 // TODO(rmcilroy): List of things not currently dealt with here but done in
725 // fullcodegen's EmitReturnSequence.
726 // - Supporting FLAG_trace for Runtime::TraceExit.
727 // - Support profiler (specifically decrementing profiling_counter
728 // appropriately and calling out to HandleInterrupts if necessary).
729
730 // Load return value into r0.
731 __ mov(eax, Operand(ebp, -kPointerSize -
732 StandardFrameConstants::kFixedFrameSizeFromFp));
733 // Leave the frame (also dropping the register file).
734 __ leave();
735 // Return droping receiver + arguments.
736 // TODO(rmcilroy): Get number of arguments from BytecodeArray.
737 __ Ret(1 * kPointerSize, ecx);
738 }
739
740
608 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { 741 void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
609 CallRuntimePassFunction(masm, Runtime::kCompileLazy); 742 CallRuntimePassFunction(masm, Runtime::kCompileLazy);
610 GenerateTailCallToReturnedCode(masm); 743 GenerateTailCallToReturnedCode(masm);
611 } 744 }
612 745
613 746
614 747
615 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) { 748 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) {
616 FrameScope scope(masm, StackFrame::INTERNAL); 749 FrameScope scope(masm, StackFrame::INTERNAL);
617 // Push a copy of the function. 750 // Push a copy of the function.
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 1759
1627 __ bind(&ok); 1760 __ bind(&ok);
1628 __ ret(0); 1761 __ ret(0);
1629 } 1762 }
1630 1763
1631 #undef __ 1764 #undef __
1632 } // namespace internal 1765 } // namespace internal
1633 } // namespace v8 1766 } // namespace v8
1634 1767
1635 #endif // V8_TARGET_ARCH_IA32 1768 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/interpreter/interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698