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 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 | 956 |
957 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { | 957 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { |
958 Generate_JSEntryTrampolineHelper(masm, false); | 958 Generate_JSEntryTrampolineHelper(masm, false); |
959 } | 959 } |
960 | 960 |
961 | 961 |
962 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { | 962 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { |
963 Generate_JSEntryTrampolineHelper(masm, true); | 963 Generate_JSEntryTrampolineHelper(masm, true); |
964 } | 964 } |
965 | 965 |
| 966 static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch) { |
| 967 Register args_count = scratch; |
| 968 |
| 969 // Get the arguments + receiver count. |
| 970 __ ldr(args_count, |
| 971 MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); |
| 972 __ Ldr(args_count.W(), |
| 973 FieldMemOperand(args_count, BytecodeArray::kParameterSizeOffset)); |
| 974 |
| 975 // Leave the frame (also dropping the register file). |
| 976 __ LeaveFrame(StackFrame::JAVA_SCRIPT); |
| 977 |
| 978 // Drop receiver + arguments. |
| 979 __ Drop(args_count, 1); |
| 980 } |
| 981 |
966 // Generate code for entering a JS function with the interpreter. | 982 // Generate code for entering a JS function with the interpreter. |
967 // On entry to the function the receiver and arguments have been pushed on the | 983 // On entry to the function the receiver and arguments have been pushed on the |
968 // stack left to right. The actual argument count matches the formal parameter | 984 // stack left to right. The actual argument count matches the formal parameter |
969 // count expected by the function. | 985 // count expected by the function. |
970 // | 986 // |
971 // The live registers are: | 987 // The live registers are: |
972 // - x1: the JS function object being called. | 988 // - x1: the JS function object being called. |
973 // - x3: the new target | 989 // - x3: the new target |
974 // - cp: our context. | 990 // - cp: our context. |
975 // - fp: our caller's frame pointer. | 991 // - fp: our caller's frame pointer. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 | 1073 |
1058 // Dispatch to the first bytecode handler for the function. | 1074 // Dispatch to the first bytecode handler for the function. |
1059 __ Ldrb(x1, MemOperand(kInterpreterBytecodeArrayRegister, | 1075 __ Ldrb(x1, MemOperand(kInterpreterBytecodeArrayRegister, |
1060 kInterpreterBytecodeOffsetRegister)); | 1076 kInterpreterBytecodeOffsetRegister)); |
1061 __ Mov(x1, Operand(x1, LSL, kPointerSizeLog2)); | 1077 __ Mov(x1, Operand(x1, LSL, kPointerSizeLog2)); |
1062 __ Ldr(ip0, MemOperand(kInterpreterDispatchTableRegister, x1)); | 1078 __ Ldr(ip0, MemOperand(kInterpreterDispatchTableRegister, x1)); |
1063 __ Call(ip0); | 1079 __ Call(ip0); |
1064 masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset()); | 1080 masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset()); |
1065 | 1081 |
1066 // The return value is in x0. | 1082 // The return value is in x0. |
1067 | 1083 LeaveInterpreterFrame(masm, x2); |
1068 // Get the arguments + reciever count. | |
1069 __ ldr(x1, MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); | |
1070 __ Ldr(w1, FieldMemOperand(x1, BytecodeArray::kParameterSizeOffset)); | |
1071 | |
1072 // Leave the frame (also dropping the register file). | |
1073 __ LeaveFrame(StackFrame::JAVA_SCRIPT); | |
1074 | |
1075 // Drop receiver + arguments and return. | |
1076 __ Drop(x1, 1); | |
1077 __ Ret(); | 1084 __ Ret(); |
1078 | 1085 |
1079 // Load debug copy of the bytecode array. | 1086 // Load debug copy of the bytecode array. |
1080 __ Bind(&load_debug_bytecode_array); | 1087 __ Bind(&load_debug_bytecode_array); |
1081 __ Ldr(kInterpreterBytecodeArrayRegister, | 1088 __ Ldr(kInterpreterBytecodeArrayRegister, |
1082 FieldMemOperand(debug_info, DebugInfo::kAbstractCodeIndex)); | 1089 FieldMemOperand(debug_info, DebugInfo::kAbstractCodeIndex)); |
1083 __ B(&bytecode_array_loaded); | 1090 __ B(&bytecode_array_loaded); |
1084 | 1091 |
1085 // If the bytecode array is no longer present, then the underlying function | 1092 // If the bytecode array is no longer present, then the underlying function |
1086 // has been switched to a different kind of code and we heal the closure by | 1093 // has been switched to a different kind of code and we heal the closure by |
1087 // switching the code entry field over to the new code object as well. | 1094 // switching the code entry field over to the new code object as well. |
1088 __ Bind(&bytecode_array_not_present); | 1095 __ Bind(&bytecode_array_not_present); |
1089 __ LeaveFrame(StackFrame::JAVA_SCRIPT); | 1096 __ LeaveFrame(StackFrame::JAVA_SCRIPT); |
1090 __ Ldr(x7, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); | 1097 __ Ldr(x7, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); |
1091 __ Ldr(x7, FieldMemOperand(x7, SharedFunctionInfo::kCodeOffset)); | 1098 __ Ldr(x7, FieldMemOperand(x7, SharedFunctionInfo::kCodeOffset)); |
1092 __ Add(x7, x7, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1099 __ Add(x7, x7, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1093 __ Str(x7, FieldMemOperand(x1, JSFunction::kCodeEntryOffset)); | 1100 __ Str(x7, FieldMemOperand(x1, JSFunction::kCodeEntryOffset)); |
1094 __ RecordWriteCodeEntryField(x1, x7, x5); | 1101 __ RecordWriteCodeEntryField(x1, x7, x5); |
1095 __ Jump(x7); | 1102 __ Jump(x7); |
1096 } | 1103 } |
1097 | 1104 |
| 1105 void Builtins::Generate_InterpreterMarkBaselineOnReturn(MacroAssembler* masm) { |
| 1106 // Save the function and context for call to CompileBaseline. |
| 1107 __ ldr(x1, MemOperand(fp, StandardFrameConstants::kFunctionOffset)); |
| 1108 __ ldr(kContextRegister, |
| 1109 MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 1110 |
| 1111 // Leave the frame before recompiling for baseline so that we don't count as |
| 1112 // an activation on the stack. |
| 1113 LeaveInterpreterFrame(masm, x2); |
| 1114 |
| 1115 { |
| 1116 FrameScope frame_scope(masm, StackFrame::INTERNAL); |
| 1117 // Push return value. |
| 1118 __ push(x0); |
| 1119 |
| 1120 // Push function as argument and compile for baseline. |
| 1121 __ push(x1); |
| 1122 __ CallRuntime(Runtime::kCompileBaseline); |
| 1123 |
| 1124 // Restore return value. |
| 1125 __ pop(x0); |
| 1126 } |
| 1127 __ Ret(); |
| 1128 } |
| 1129 |
1098 // static | 1130 // static |
1099 void Builtins::Generate_InterpreterPushArgsAndCallImpl( | 1131 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
1100 MacroAssembler* masm, TailCallMode tail_call_mode) { | 1132 MacroAssembler* masm, TailCallMode tail_call_mode) { |
1101 // ----------- S t a t e ------------- | 1133 // ----------- S t a t e ------------- |
1102 // -- x0 : the number of arguments (not including the receiver) | 1134 // -- x0 : the number of arguments (not including the receiver) |
1103 // -- x2 : the address of the first argument to be pushed. Subsequent | 1135 // -- x2 : the address of the first argument to be pushed. Subsequent |
1104 // arguments should be consecutive above this, in the same order as | 1136 // arguments should be consecutive above this, in the same order as |
1105 // they are to be pushed onto the stack. | 1137 // they are to be pushed onto the stack. |
1106 // -- x1 : the target to call (can be any Object). | 1138 // -- x1 : the target to call (can be any Object). |
1107 // ----------------------------------- | 1139 // ----------------------------------- |
(...skipping 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2856 } | 2888 } |
2857 } | 2889 } |
2858 | 2890 |
2859 | 2891 |
2860 #undef __ | 2892 #undef __ |
2861 | 2893 |
2862 } // namespace internal | 2894 } // namespace internal |
2863 } // namespace v8 | 2895 } // namespace v8 |
2864 | 2896 |
2865 #endif // V8_TARGET_ARCH_ARM | 2897 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |