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

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

Powered by Google App Engine
This is Rietveld 408576698