| 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 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 // arguments should be consecutive above this, in the same order as | 1179 // arguments should be consecutive above this, in the same order as |
| 1180 // they are to be pushed onto the stack. | 1180 // they are to be pushed onto the stack. |
| 1181 // -- x1 : the target to call (can be any Object). | 1181 // -- x1 : the target to call (can be any Object). |
| 1182 // ----------------------------------- | 1182 // ----------------------------------- |
| 1183 | 1183 |
| 1184 // Find the address of the last argument. | 1184 // Find the address of the last argument. |
| 1185 __ add(x3, x0, Operand(1)); // Add one for receiver. | 1185 __ add(x3, x0, Operand(1)); // Add one for receiver. |
| 1186 __ lsl(x3, x3, kPointerSizeLog2); | 1186 __ lsl(x3, x3, kPointerSizeLog2); |
| 1187 __ sub(x4, x2, x3); | 1187 __ sub(x4, x2, x3); |
| 1188 | 1188 |
| 1189 // TODO(mythria): Add a stack check before pushing arguments. |
| 1189 // Push the arguments. | 1190 // Push the arguments. |
| 1190 Label loop_header, loop_check; | 1191 Label loop_header, loop_check; |
| 1191 __ Mov(x5, jssp); | 1192 __ Mov(x5, jssp); |
| 1192 __ Claim(x3, 1); | 1193 __ Claim(x3, 1); |
| 1193 __ B(&loop_check); | 1194 __ B(&loop_check); |
| 1194 __ Bind(&loop_header); | 1195 __ Bind(&loop_header); |
| 1195 // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned. | 1196 // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned. |
| 1196 __ Ldr(x3, MemOperand(x2, -kPointerSize, PostIndex)); | 1197 __ Ldr(x3, MemOperand(x2, -kPointerSize, PostIndex)); |
| 1197 __ Str(x3, MemOperand(x5, -kPointerSize, PreIndex)); | 1198 __ Str(x3, MemOperand(x5, -kPointerSize, PreIndex)); |
| 1198 __ Bind(&loop_check); | 1199 __ Bind(&loop_check); |
| 1199 __ Cmp(x2, x4); | 1200 __ Cmp(x2, x4); |
| 1200 __ B(gt, &loop_header); | 1201 __ B(gt, &loop_header); |
| 1201 | 1202 |
| 1202 // Call the target. | 1203 // Call the target. |
| 1203 if (function_type == CallableType::kJSFunction) { | 1204 if (function_type == CallableType::kJSFunction) { |
| 1204 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, | 1205 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, |
| 1205 tail_call_mode), | 1206 tail_call_mode), |
| 1206 RelocInfo::CODE_TARGET); | 1207 RelocInfo::CODE_TARGET); |
| 1207 } else { | 1208 } else { |
| 1208 DCHECK_EQ(function_type, CallableType::kAny); | 1209 DCHECK_EQ(function_type, CallableType::kAny); |
| 1209 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 1210 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
| 1210 tail_call_mode), | 1211 tail_call_mode), |
| 1211 RelocInfo::CODE_TARGET); | 1212 RelocInfo::CODE_TARGET); |
| 1212 } | 1213 } |
| 1213 } | 1214 } |
| 1214 | 1215 |
| 1215 // static | 1216 // static |
| 1216 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { | 1217 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
| 1218 MacroAssembler* masm, CallableType construct_type) { |
| 1217 // ----------- S t a t e ------------- | 1219 // ----------- S t a t e ------------- |
| 1218 // -- x0 : argument count (not including receiver) | 1220 // -- x0 : argument count (not including receiver) |
| 1219 // -- x3 : new target | 1221 // -- x3 : new target |
| 1220 // -- x1 : constructor to call | 1222 // -- x1 : constructor to call |
| 1221 // -- x2 : address of the first argument | 1223 // -- x2 : allocation site feedback if available, undefined otherwise |
| 1224 // -- x4 : address of the first argument |
| 1222 // ----------------------------------- | 1225 // ----------------------------------- |
| 1223 | 1226 |
| 1224 // Find the address of the last argument. | 1227 // Find the address of the last argument. |
| 1225 __ add(x5, x0, Operand(1)); // Add one for receiver (to be constructed). | 1228 __ add(x5, x0, Operand(1)); // Add one for receiver (to be constructed). |
| 1226 __ lsl(x5, x5, kPointerSizeLog2); | 1229 __ lsl(x5, x5, kPointerSizeLog2); |
| 1227 | 1230 |
| 1228 // Set stack pointer and where to stop. | 1231 // Set stack pointer and where to stop. |
| 1229 __ Mov(x6, jssp); | 1232 __ Mov(x6, jssp); |
| 1230 __ Claim(x5, 1); | 1233 __ Claim(x5, 1); |
| 1231 __ sub(x4, x6, x5); | 1234 __ sub(x7, x6, x5); |
| 1232 | 1235 |
| 1233 // Push a slot for the receiver. | 1236 // Push a slot for the receiver. |
| 1234 __ Str(xzr, MemOperand(x6, -kPointerSize, PreIndex)); | 1237 __ Str(xzr, MemOperand(x6, -kPointerSize, PreIndex)); |
| 1235 | 1238 |
| 1236 Label loop_header, loop_check; | 1239 Label loop_header, loop_check; |
| 1240 // TODO(mythria): Add a stack check before pushing arguments. |
| 1237 // Push the arguments. | 1241 // Push the arguments. |
| 1238 __ B(&loop_check); | 1242 __ B(&loop_check); |
| 1239 __ Bind(&loop_header); | 1243 __ Bind(&loop_header); |
| 1240 // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned. | 1244 // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned. |
| 1241 __ Ldr(x5, MemOperand(x2, -kPointerSize, PostIndex)); | 1245 __ Ldr(x5, MemOperand(x4, -kPointerSize, PostIndex)); |
| 1242 __ Str(x5, MemOperand(x6, -kPointerSize, PreIndex)); | 1246 __ Str(x5, MemOperand(x6, -kPointerSize, PreIndex)); |
| 1243 __ Bind(&loop_check); | 1247 __ Bind(&loop_check); |
| 1244 __ Cmp(x6, x4); | 1248 __ Cmp(x6, x7); |
| 1245 __ B(gt, &loop_header); | 1249 __ B(gt, &loop_header); |
| 1246 | 1250 |
| 1247 // Call the constructor with x0, x1, and x3 unmodified. | 1251 __ AssertUndefinedOrAllocationSite(x2, x6); |
| 1248 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 1252 if (construct_type == CallableType::kJSFunction) { |
| 1253 __ AssertFunction(x1); |
| 1254 |
| 1255 // Tail call to the function-specific construct stub (still in the caller |
| 1256 // context at this point). |
| 1257 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); |
| 1258 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset)); |
| 1259 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag); |
| 1260 __ Br(x4); |
| 1261 } else { |
| 1262 DCHECK_EQ(construct_type, CallableType::kAny); |
| 1263 // Call the constructor with x0, x1, and x3 unmodified. |
| 1264 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
| 1265 } |
| 1249 } | 1266 } |
| 1250 | 1267 |
| 1251 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { | 1268 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
| 1252 // Set the return address to the correct point in the interpreter entry | 1269 // Set the return address to the correct point in the interpreter entry |
| 1253 // trampoline. | 1270 // trampoline. |
| 1254 Smi* interpreter_entry_return_pc_offset( | 1271 Smi* interpreter_entry_return_pc_offset( |
| 1255 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); | 1272 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); |
| 1256 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); | 1273 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); |
| 1257 __ LoadObject(x1, masm->isolate()->builtins()->InterpreterEntryTrampoline()); | 1274 __ LoadObject(x1, masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
| 1258 __ Add(lr, x1, Operand(interpreter_entry_return_pc_offset->value() + | 1275 __ Add(lr, x1, Operand(interpreter_entry_return_pc_offset->value() + |
| (...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3033 __ Unreachable(); | 3050 __ Unreachable(); |
| 3034 } | 3051 } |
| 3035 } | 3052 } |
| 3036 | 3053 |
| 3037 #undef __ | 3054 #undef __ |
| 3038 | 3055 |
| 3039 } // namespace internal | 3056 } // namespace internal |
| 3040 } // namespace v8 | 3057 } // namespace v8 |
| 3041 | 3058 |
| 3042 #endif // V8_TARGET_ARCH_ARM | 3059 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |