OLD | NEW |
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 #if V8_TARGET_ARCH_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 // TODO(rmcilroy): Ensure we always have an even number of registers to | 1045 // TODO(rmcilroy): Ensure we always have an even number of registers to |
1046 // allow stack to be 16 bit aligned (and remove need for jssp). | 1046 // allow stack to be 16 bit aligned (and remove need for jssp). |
1047 __ Lsr(x11, x11, kPointerSizeLog2); | 1047 __ Lsr(x11, x11, kPointerSizeLog2); |
1048 __ PushMultipleTimes(x10, x11); | 1048 __ PushMultipleTimes(x10, x11); |
1049 __ Bind(&loop_header); | 1049 __ Bind(&loop_header); |
1050 } | 1050 } |
1051 | 1051 |
1052 // Load accumulator, register file, bytecode offset, dispatch table into | 1052 // Load accumulator, register file, bytecode offset, dispatch table into |
1053 // registers. | 1053 // registers. |
1054 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); | 1054 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); |
1055 __ Add(kInterpreterRegisterFileRegister, fp, | 1055 __ Add(x18, fp, Operand(InterpreterFrameConstants::kRegisterFileFromFp)); |
1056 Operand(InterpreterFrameConstants::kRegisterFilePointerFromFp)); | |
1057 __ Mov(kInterpreterBytecodeOffsetRegister, | 1056 __ Mov(kInterpreterBytecodeOffsetRegister, |
1058 Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); | 1057 Operand(BytecodeArray::kHeaderSize - kHeapObjectTag)); |
1059 __ Mov(kInterpreterDispatchTableRegister, | 1058 __ Mov(kInterpreterDispatchTableRegister, |
1060 Operand(ExternalReference::interpreter_dispatch_table_address( | 1059 Operand(ExternalReference::interpreter_dispatch_table_address( |
1061 masm->isolate()))); | 1060 masm->isolate()))); |
1062 | 1061 |
1063 // Dispatch to the first bytecode handler for the function. | 1062 // Dispatch to the first bytecode handler for the function. |
1064 __ Ldrb(x1, MemOperand(kInterpreterBytecodeArrayRegister, | 1063 __ Ldrb(x1, MemOperand(kInterpreterBytecodeArrayRegister, |
1065 kInterpreterBytecodeOffsetRegister)); | 1064 kInterpreterBytecodeOffsetRegister)); |
1066 __ Mov(x1, Operand(x1, LSL, kPointerSizeLog2)); | 1065 __ Mov(x1, Operand(x1, LSL, kPointerSizeLog2)); |
1067 __ Ldr(ip0, MemOperand(kInterpreterDispatchTableRegister, x1)); | 1066 __ Ldr(ip0, MemOperand(kInterpreterDispatchTableRegister, x1)); |
1068 __ Call(ip0); | 1067 __ Call(ip0); |
1069 | 1068 |
1070 // Even though the first bytecode handler was called, we will never return. | 1069 // Even though the first bytecode handler was called, we will never return. |
1071 __ Abort(kUnexpectedReturnFromBytecodeHandler); | 1070 __ Abort(kUnexpectedReturnFromBytecodeHandler); |
1072 | 1071 |
1073 // Load debug copy of the bytecode array. | 1072 // Load debug copy of the bytecode array. |
1074 __ Bind(&load_debug_bytecode_array); | 1073 __ Bind(&load_debug_bytecode_array); |
1075 __ Ldr(kInterpreterBytecodeArrayRegister, | 1074 __ Ldr(kInterpreterBytecodeArrayRegister, |
1076 FieldMemOperand(debug_info, DebugInfo::kAbstractCodeIndex)); | 1075 FieldMemOperand(debug_info, DebugInfo::kAbstractCodeIndex)); |
1077 __ B(&bytecode_array_loaded); | 1076 __ B(&bytecode_array_loaded); |
1078 } | 1077 } |
1079 | 1078 |
1080 | 1079 |
1081 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { | 1080 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { |
1082 // TODO(rmcilroy): List of things not currently dealt with here but done in | |
1083 // fullcodegen's EmitReturnSequence. | |
1084 // - Supporting FLAG_trace for Runtime::TraceExit. | |
1085 // - Support profiler (specifically decrementing profiling_counter | |
1086 // appropriately and calling out to HandleInterrupts if necessary). | |
1087 | |
1088 // The return value is in accumulator, which is already in x0. | 1081 // The return value is in accumulator, which is already in x0. |
1089 | 1082 |
1090 // Leave the frame (also dropping the register file). | 1083 // Leave the frame (also dropping the register file). |
1091 __ LeaveFrame(StackFrame::JAVA_SCRIPT); | 1084 __ LeaveFrame(StackFrame::JAVA_SCRIPT); |
1092 | 1085 |
1093 // Drop receiver + arguments and return. | 1086 // Drop receiver + arguments and return. |
1094 __ Ldr(w1, FieldMemOperand(kInterpreterBytecodeArrayRegister, | 1087 __ Ldr(w1, FieldMemOperand(kInterpreterBytecodeArrayRegister, |
1095 BytecodeArray::kParameterSizeOffset)); | 1088 BytecodeArray::kParameterSizeOffset)); |
1096 __ Drop(x1, 1); | 1089 __ Drop(x1, 1); |
1097 __ Ret(); | 1090 __ Ret(); |
1098 } | 1091 } |
1099 | 1092 |
1100 | 1093 |
1101 static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) { | 1094 static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) { |
1102 // Initialize register file register and dispatch table register. | 1095 // Initialize the dispatch table register. |
1103 __ Add(kInterpreterRegisterFileRegister, fp, | |
1104 Operand(InterpreterFrameConstants::kRegisterFilePointerFromFp)); | |
1105 __ Mov(kInterpreterDispatchTableRegister, | 1096 __ Mov(kInterpreterDispatchTableRegister, |
1106 Operand(ExternalReference::interpreter_dispatch_table_address( | 1097 Operand(ExternalReference::interpreter_dispatch_table_address( |
1107 masm->isolate()))); | 1098 masm->isolate()))); |
1108 | 1099 |
1109 // Get the bytecode array pointer from the frame. | 1100 // Get the bytecode array pointer from the frame. |
1110 __ Ldr( | 1101 __ Ldr(kInterpreterBytecodeArrayRegister, |
1111 kInterpreterBytecodeArrayRegister, | 1102 MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); |
1112 MemOperand(kInterpreterRegisterFileRegister, | |
1113 InterpreterFrameConstants::kBytecodeArrayFromRegisterPointer)); | |
1114 | 1103 |
1115 if (FLAG_debug_code) { | 1104 if (FLAG_debug_code) { |
1116 // Check function data field is actually a BytecodeArray object. | 1105 // Check function data field is actually a BytecodeArray object. |
1117 __ AssertNotSmi(kInterpreterBytecodeArrayRegister, | 1106 __ AssertNotSmi(kInterpreterBytecodeArrayRegister, |
1118 kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); | 1107 kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); |
1119 __ CompareObjectType(kInterpreterBytecodeArrayRegister, x1, x1, | 1108 __ CompareObjectType(kInterpreterBytecodeArrayRegister, x1, x1, |
1120 BYTECODE_ARRAY_TYPE); | 1109 BYTECODE_ARRAY_TYPE); |
1121 __ Assert(eq, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); | 1110 __ Assert(eq, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); |
1122 } | 1111 } |
1123 | 1112 |
1124 // Get the target bytecode offset from the frame. | 1113 // Get the target bytecode offset from the frame. |
1125 __ Ldr(kInterpreterBytecodeOffsetRegister, | 1114 __ Ldr(kInterpreterBytecodeOffsetRegister, |
1126 MemOperand( | 1115 MemOperand(fp, InterpreterFrameConstants::kBytecodeOffsetFromFp)); |
1127 kInterpreterRegisterFileRegister, | |
1128 InterpreterFrameConstants::kBytecodeOffsetFromRegisterPointer)); | |
1129 __ SmiUntag(kInterpreterBytecodeOffsetRegister); | 1116 __ SmiUntag(kInterpreterBytecodeOffsetRegister); |
1130 | 1117 |
1131 // Dispatch to the target bytecode. | 1118 // Dispatch to the target bytecode. |
1132 __ Ldrb(x1, MemOperand(kInterpreterBytecodeArrayRegister, | 1119 __ Ldrb(x1, MemOperand(kInterpreterBytecodeArrayRegister, |
1133 kInterpreterBytecodeOffsetRegister)); | 1120 kInterpreterBytecodeOffsetRegister)); |
1134 __ Mov(x1, Operand(x1, LSL, kPointerSizeLog2)); | 1121 __ Mov(x1, Operand(x1, LSL, kPointerSizeLog2)); |
1135 __ Ldr(ip0, MemOperand(kInterpreterDispatchTableRegister, x1)); | 1122 __ Ldr(ip0, MemOperand(kInterpreterDispatchTableRegister, x1)); |
1136 __ Jump(ip0); | 1123 __ Jump(ip0); |
1137 } | 1124 } |
1138 | 1125 |
(...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2899 } | 2886 } |
2900 } | 2887 } |
2901 | 2888 |
2902 | 2889 |
2903 #undef __ | 2890 #undef __ |
2904 | 2891 |
2905 } // namespace internal | 2892 } // namespace internal |
2906 } // namespace v8 | 2893 } // namespace v8 |
2907 | 2894 |
2908 #endif // V8_TARGET_ARCH_ARM | 2895 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |