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

Side by Side Diff: src/mips/builtins-mips.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/mips/assembler-mips.h ('k') | src/mips64/assembler-mips64.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 5
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #if V8_TARGET_ARCH_MIPS 9 #if V8_TARGET_ARCH_MIPS
10 10
11 #include "src/codegen.h" 11 #include "src/codegen.h"
12 #include "src/debug.h" 12 #include "src/debug.h"
13 #include "src/deoptimizer.h" 13 #include "src/deoptimizer.h"
14 #include "src/full-codegen/full-codegen.h" 14 #include "src/full-codegen/full-codegen.h"
15 #include "src/interpreter/bytecodes.h"
15 #include "src/runtime/runtime.h" 16 #include "src/runtime/runtime.h"
16 17
17 18
18 namespace v8 { 19 namespace v8 {
19 namespace internal { 20 namespace internal {
20 21
21 22
22 #define __ ACCESS_MASM(masm) 23 #define __ ACCESS_MASM(masm)
23 24
24 25
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { 854 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
854 Generate_JSEntryTrampolineHelper(masm, false); 855 Generate_JSEntryTrampolineHelper(masm, false);
855 } 856 }
856 857
857 858
858 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { 859 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
859 Generate_JSEntryTrampolineHelper(masm, true); 860 Generate_JSEntryTrampolineHelper(masm, true);
860 } 861 }
861 862
862 863
864 // Generate code for entering a JS function with the interpreter.
865 // On entry to the function the receiver and arguments have been pushed on the
866 // stack left to right. The actual argument count matches the formal parameter
867 // count expected by the function.
868 //
869 // The live registers are:
870 // o a1: the JS function object being called.
871 // o cp: our context
872 // o fp: the caller's frame pointer
873 // o sp: stack pointer
874 // o ra: return address
875 //
876 // The function builds a JS frame. Please see JavaScriptFrameConstants in
877 // frames-mips.h for its layout.
878 // TODO(rmcilroy): We will need to include the current bytecode pointer in the
879 // frame.
880 void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
881 // Open a frame scope to indicate that there is a frame on the stack. The
882 // MANUAL indicates that the scope shouldn't actually generate code to set up
883 // the frame (that is done below).
884 FrameScope frame_scope(masm, StackFrame::MANUAL);
885
886 __ Push(ra, fp, cp, a1);
887 __ Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
888
889 // Get the bytecode array from the function object and load the pointer to the
890 // first entry into kInterpreterBytecodeRegister.
891 __ lw(a0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
892 __ lw(kInterpreterBytecodeArrayRegister,
893 FieldMemOperand(a0, SharedFunctionInfo::kFunctionDataOffset));
894
895 if (FLAG_debug_code) {
896 // Check function data field is actually a BytecodeArray object.
897 __ SmiTst(kInterpreterBytecodeArrayRegister, t0);
898 __ Assert(ne, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, t0,
899 Operand(zero_reg));
900 __ GetObjectType(kInterpreterBytecodeArrayRegister, t0, t0);
901 __ Assert(eq, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, t0,
902 Operand(BYTECODE_ARRAY_TYPE));
903 }
904
905 // Allocate the local and temporary register file on the stack.
906 {
907 // Load frame size from the BytecodeArray object.
908 __ lw(t0, FieldMemOperand(kInterpreterBytecodeArrayRegister,
909 BytecodeArray::kFrameSizeOffset));
910
911 // Do a stack check to ensure we don't go over the limit.
912 Label ok;
913 __ Subu(t1, sp, Operand(t0));
914 __ LoadRoot(a2, Heap::kRealStackLimitRootIndex);
915 __ Branch(&ok, hs, t1, Operand(a2));
916 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION);
917 __ bind(&ok);
918
919 // If ok, push undefined as the initial value for all register file entries.
920 // Note: there should always be at least one stack slot for the return
921 // register in the register file.
922 Label loop_header;
923 __ LoadRoot(t1, Heap::kUndefinedValueRootIndex);
924 __ bind(&loop_header);
925 // TODO(rmcilroy): Consider doing more than one push per loop iteration.
926 __ push(t1);
927 // Continue loop if not done.
928 __ Subu(t0, t0, Operand(kPointerSize));
929 __ Branch(&loop_header, ge, t0, Operand(zero_reg));
930 }
931
932 // TODO(rmcilroy): List of things not currently dealt with here but done in
933 // fullcodegen's prologue:
934 // - Support profiler (specifically profiling_counter).
935 // - Call ProfileEntryHookStub when isolate has a function_entry_hook.
936 // - Allow simulator stop operations if FLAG_stop_at is set.
937 // - Deal with sloppy mode functions which need to replace the
938 // receiver with the global proxy when called as functions (without an
939 // explicit receiver object).
940 // - Code aging of the BytecodeArray object.
941 // - Supporting FLAG_trace.
942 //
943 // The following items are also not done here, and will probably be done using
944 // explicit bytecodes instead:
945 // - Allocating a new local context if applicable.
946 // - Setting up a local binding to the this function, which is used in
947 // derived constructors with super calls.
948 // - Setting new.target if required.
949 // - Dealing with REST parameters (only if
950 // https://codereview.chromium.org/1235153006 doesn't land by then).
951 // - Dealing with argument objects.
952
953 // Perform stack guard check.
954 {
955 Label ok;
956 __ LoadRoot(at, Heap::kStackLimitRootIndex);
957 __ Branch(&ok, hs, sp, Operand(at));
958 __ CallRuntime(Runtime::kStackGuard, 0);
959 __ bind(&ok);
960 }
961
962 // Load bytecode offset and dispatch table into registers.
963 __ li(kInterpreterBytecodeOffsetRegister,
964 Operand(BytecodeArray::kHeaderSize - kHeapObjectTag));
965 __ LoadRoot(kInterpreterDispatchTableRegister,
966 Heap::kInterpreterTableRootIndex);
967 __ Addu(kInterpreterDispatchTableRegister, kInterpreterDispatchTableRegister,
968 Operand(FixedArray::kHeaderSize - kHeapObjectTag));
969
970 // Dispatch to the first bytecode handler for the function.
971 __ Addu(a0, kInterpreterBytecodeArrayRegister,
972 kInterpreterBytecodeOffsetRegister);
973 __ lbu(a0, MemOperand(a0));
974 __ sll(at, a0, kPointerSizeLog2);
975 __ Addu(at, kInterpreterDispatchTableRegister, at);
976 __ lw(at, MemOperand(at));
977 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging
978 // and header removal.
979 __ Addu(at, at, Operand(Code::kHeaderSize - kHeapObjectTag));
980 __ Jump(at);
981 }
982
983
984 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) {
985 // TODO(rmcilroy): List of things not currently dealt with here but done in
986 // fullcodegen's EmitReturnSequence.
987 // - Supporting FLAG_trace for Runtime::TraceExit.
988 // - Support profiler (specifically decrementing profiling_counter
989 // appropriately and calling out to HandleInterrupts if necessary).
990
991 // Load return value into v0.
992 __ lw(v0, MemOperand(fp, -kPointerSize -
993 StandardFrameConstants::kFixedFrameSizeFromFp));
994 // Leave the frame (also dropping the register file).
995 __ LeaveFrame(StackFrame::JAVA_SCRIPT);
996 // Drop receiver + arguments.
997 __ Drop(1); // TODO(rmcilroy): Get number of arguments from BytecodeArray.
998 __ Jump(ra);
999 }
1000
1001
863 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { 1002 void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
864 CallRuntimePassFunction(masm, Runtime::kCompileLazy); 1003 CallRuntimePassFunction(masm, Runtime::kCompileLazy);
865 GenerateTailCallToReturnedCode(masm); 1004 GenerateTailCallToReturnedCode(masm);
866 } 1005 }
867 1006
868 1007
869 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) { 1008 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) {
870 FrameScope scope(masm, StackFrame::INTERNAL); 1009 FrameScope scope(masm, StackFrame::INTERNAL);
871 // Push a copy of the function onto the stack. 1010 // Push a copy of the function onto the stack.
872 // Push function as parameter to the runtime call. 1011 // Push function as parameter to the runtime call.
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 } 1870 }
1732 } 1871 }
1733 1872
1734 1873
1735 #undef __ 1874 #undef __
1736 1875
1737 } // namespace internal 1876 } // namespace internal
1738 } // namespace v8 1877 } // namespace v8
1739 1878
1740 #endif // V8_TARGET_ARCH_MIPS 1879 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/assembler-mips.h ('k') | src/mips64/assembler-mips64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698