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

Side by Side Diff: src/arm64/builtins-arm64.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/arm64/assembler-arm64.h ('k') | src/bailout-reason.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_ARM64 7 #if V8_TARGET_ARCH_ARM64
8 8
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/debug.h" 10 #include "src/debug.h"
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { 886 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
887 Generate_JSEntryTrampolineHelper(masm, false); 887 Generate_JSEntryTrampolineHelper(masm, false);
888 } 888 }
889 889
890 890
891 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { 891 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
892 Generate_JSEntryTrampolineHelper(masm, true); 892 Generate_JSEntryTrampolineHelper(masm, true);
893 } 893 }
894 894
895 895
896 // Generate code for entering a JS function with the interpreter.
897 // On entry to the function the receiver and arguments have been pushed on the
898 // stack left to right. The actual argument count matches the formal parameter
899 // count expected by the function.
900 //
901 // The live registers are:
902 // - x1: the JS function object being called.
903 // - cp: our context.
904 // - fp: our caller's frame pointer.
905 // - jssp: stack pointer.
906 // - lr: return address.
907 //
908 // The function builds a JS frame. Please see JavaScriptFrameConstants in
909 // frames-arm64.h for its layout.
910 // TODO(rmcilroy): We will need to include the current bytecode pointer in the
911 // frame.
912 void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
913 // Open a frame scope to indicate that there is a frame on the stack. The
914 // MANUAL indicates that the scope shouldn't actually generate code to set up
915 // the frame (that is done below).
916 FrameScope frame_scope(masm, StackFrame::MANUAL);
917 __ Push(lr, fp, cp, x1);
918 __ Add(fp, jssp, StandardFrameConstants::kFixedFrameSizeFromFp);
919
920 // Get the bytecode array from the function object and load the pointer to the
921 // first entry into kInterpreterBytecodeRegister.
922 __ Ldr(x0, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset));
923 __ Ldr(kInterpreterBytecodeArrayRegister,
924 FieldMemOperand(x0, SharedFunctionInfo::kFunctionDataOffset));
925
926 if (FLAG_debug_code) {
927 // Check function data field is actually a BytecodeArray object.
928 __ AssertNotSmi(kInterpreterBytecodeArrayRegister,
929 kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry);
930 __ CompareObjectType(kInterpreterBytecodeArrayRegister, x0, x0,
931 BYTECODE_ARRAY_TYPE);
932 __ Assert(eq, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry);
933 }
934
935 // Allocate the local and temporary register file on the stack.
936 {
937 // Load frame size from the BytecodeArray object.
938 __ Ldr(w11, FieldMemOperand(kInterpreterBytecodeArrayRegister,
939 BytecodeArray::kFrameSizeOffset));
940
941 // Do a stack check to ensure we don't go over the limit.
942 Label ok;
943 DCHECK(jssp.Is(__ StackPointer()));
944 __ Sub(x10, jssp, Operand(x11));
945 __ CompareRoot(x10, Heap::kRealStackLimitRootIndex);
946 __ B(hs, &ok);
947 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION);
948 __ Bind(&ok);
949
950 // If ok, push undefined as the initial value for all register file entries.
951 // Note: there should always be at least one stack slot for the return
952 // register in the register file.
953 Label loop_header;
954 __ LoadRoot(x10, Heap::kUndefinedValueRootIndex);
955 // TODO(rmcilroy): Ensure we always have an even number of registers to
956 // allow stack to be 16 bit aligned (and remove need for jssp).
957 __ Lsr(x11, x11, kPointerSizeLog2);
958 __ PushMultipleTimes(x10, x11);
959 __ Bind(&loop_header);
960 }
961
962 // TODO(rmcilroy): List of things not currently dealt with here but done in
963 // fullcodegen's prologue:
964 // - Support profiler (specifically profiling_counter).
965 // - Call ProfileEntryHookStub when isolate has a function_entry_hook.
966 // - Allow simulator stop operations if FLAG_stop_at is set.
967 // - Deal with sloppy mode functions which need to replace the
968 // receiver with the global proxy when called as functions (without an
969 // explicit receiver object).
970 // - Code aging of the BytecodeArray object.
971 // - Supporting FLAG_trace.
972 //
973 // The following items are also not done here, and will probably be done using
974 // explicit bytecodes instead:
975 // - Allocating a new local context if applicable.
976 // - Setting up a local binding to the this function, which is used in
977 // derived constructors with super calls.
978 // - Setting new.target if required.
979 // - Dealing with REST parameters (only if
980 // https://codereview.chromium.org/1235153006 doesn't land by then).
981 // - Dealing with argument objects.
982
983 // Perform stack guard check.
984 {
985 Label ok;
986 __ CompareRoot(jssp, Heap::kStackLimitRootIndex);
987 __ B(hs, &ok);
988 __ CallRuntime(Runtime::kStackGuard, 0);
989 __ Bind(&ok);
990 }
991
992 // Load bytecode offset and dispatch table into registers.
993 __ Mov(kInterpreterBytecodeOffsetRegister,
994 Operand(BytecodeArray::kHeaderSize - kHeapObjectTag));
995 __ LoadRoot(kInterpreterDispatchTableRegister,
996 Heap::kInterpreterTableRootIndex);
997 __ Add(kInterpreterDispatchTableRegister, kInterpreterDispatchTableRegister,
998 Operand(FixedArray::kHeaderSize - kHeapObjectTag));
999
1000 // Dispatch to the first bytecode handler for the function.
1001 __ Ldrb(x0, MemOperand(kInterpreterBytecodeArrayRegister,
1002 kInterpreterBytecodeOffsetRegister));
1003 __ Mov(x0, Operand(x0, LSL, kPointerSizeLog2));
1004 __ Ldr(ip0, MemOperand(kInterpreterDispatchTableRegister, x0));
1005 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging
1006 // and header removal.
1007 __ Add(ip0, ip0, Operand(Code::kHeaderSize - kHeapObjectTag));
1008 __ Jump(ip0);
1009 }
1010
1011
1012 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) {
1013 // TODO(rmcilroy): List of things not currently dealt with here but done in
1014 // fullcodegen's EmitReturnSequence.
1015 // - Supporting FLAG_trace for Runtime::TraceExit.
1016 // - Support profiler (specifically decrementing profiling_counter
1017 // appropriately and calling out to HandleInterrupts if necessary).
1018
1019 // Load return value into x0.
1020 __ ldr(x0, MemOperand(fp, -kPointerSize -
1021 StandardFrameConstants::kFixedFrameSizeFromFp));
1022 // Leave the frame (also dropping the register file).
1023 __ LeaveFrame(StackFrame::JAVA_SCRIPT);
1024 // Drop receiver + arguments.
1025 // TODO(rmcilroy): Get number of arguments from BytecodeArray.
1026 __ Drop(1, kXRegSize);
1027 __ Ret();
1028 }
1029
1030
896 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { 1031 void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
897 CallRuntimePassFunction(masm, Runtime::kCompileLazy); 1032 CallRuntimePassFunction(masm, Runtime::kCompileLazy);
898 GenerateTailCallToReturnedCode(masm); 1033 GenerateTailCallToReturnedCode(masm);
899 } 1034 }
900 1035
901 1036
902 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) { 1037 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) {
903 FrameScope scope(masm, StackFrame::INTERNAL); 1038 FrameScope scope(masm, StackFrame::INTERNAL);
904 Register function = x1; 1039 Register function = x1;
905 1040
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 } 1923 }
1789 } 1924 }
1790 1925
1791 1926
1792 #undef __ 1927 #undef __
1793 1928
1794 } // namespace internal 1929 } // namespace internal
1795 } // namespace v8 1930 } // namespace v8
1796 1931
1797 #endif // V8_TARGET_ARCH_ARM 1932 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm64/assembler-arm64.h ('k') | src/bailout-reason.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698