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

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

Powered by Google App Engine
This is Rietveld 408576698