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