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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 // Push function as argument and compile for baseline. | 1164 // Push function as argument and compile for baseline. |
1165 __ push(x1); | 1165 __ push(x1); |
1166 __ CallRuntime(Runtime::kCompileBaseline); | 1166 __ CallRuntime(Runtime::kCompileBaseline); |
1167 | 1167 |
1168 // Restore return value. | 1168 // Restore return value. |
1169 __ pop(x0); | 1169 __ pop(x0); |
1170 } | 1170 } |
1171 __ Ret(); | 1171 __ Ret(); |
1172 } | 1172 } |
1173 | 1173 |
| 1174 static void Generate_InterpreterPushArgs(MacroAssembler* masm, |
| 1175 Register num_args, Register index, |
| 1176 Register last_arg, Register stack_addr, |
| 1177 Register scratch) { |
| 1178 __ Mov(scratch, num_args); |
| 1179 __ lsl(scratch, scratch, kPointerSizeLog2); |
| 1180 __ sub(last_arg, index, scratch); |
| 1181 |
| 1182 // Set stack pointer and where to stop. |
| 1183 __ Mov(stack_addr, jssp); |
| 1184 __ Claim(scratch, 1); |
| 1185 |
| 1186 // TODO(mythria): Add a stack check before pushing arguments. |
| 1187 // Push the arguments. |
| 1188 Label loop_header, loop_check; |
| 1189 __ B(&loop_check); |
| 1190 __ Bind(&loop_header); |
| 1191 // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned. |
| 1192 __ Ldr(scratch, MemOperand(index, -kPointerSize, PostIndex)); |
| 1193 __ Str(scratch, MemOperand(stack_addr, -kPointerSize, PreIndex)); |
| 1194 __ Bind(&loop_check); |
| 1195 __ Cmp(index, last_arg); |
| 1196 __ B(gt, &loop_header); |
| 1197 } |
| 1198 |
1174 // static | 1199 // static |
1175 void Builtins::Generate_InterpreterPushArgsAndCallImpl( | 1200 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
1176 MacroAssembler* masm, TailCallMode tail_call_mode, | 1201 MacroAssembler* masm, TailCallMode tail_call_mode, |
1177 CallableType function_type) { | 1202 CallableType function_type) { |
1178 // ----------- S t a t e ------------- | 1203 // ----------- S t a t e ------------- |
1179 // -- x0 : the number of arguments (not including the receiver) | 1204 // -- x0 : the number of arguments (not including the receiver) |
1180 // -- x2 : the address of the first argument to be pushed. Subsequent | 1205 // -- x2 : the address of the first argument to be pushed. Subsequent |
1181 // arguments should be consecutive above this, in the same order as | 1206 // arguments should be consecutive above this, in the same order as |
1182 // they are to be pushed onto the stack. | 1207 // they are to be pushed onto the stack. |
1183 // -- x1 : the target to call (can be any Object). | 1208 // -- x1 : the target to call (can be any Object). |
1184 // ----------------------------------- | 1209 // ----------------------------------- |
1185 | 1210 |
1186 // Find the address of the last argument. | 1211 // Add one for the receiver. |
1187 __ add(x3, x0, Operand(1)); // Add one for receiver. | 1212 __ add(x3, x0, Operand(1)); |
1188 __ lsl(x3, x3, kPointerSizeLog2); | |
1189 __ sub(x4, x2, x3); | |
1190 | 1213 |
1191 // TODO(mythria): Add a stack check before pushing arguments. | 1214 // Push the arguments. x2, x4, x5, x6 will be modified. |
1192 // Push the arguments. | 1215 Generate_InterpreterPushArgs(masm, x3, x2, x4, x5, x6); |
1193 Label loop_header, loop_check; | |
1194 __ Mov(x5, jssp); | |
1195 __ Claim(x3, 1); | |
1196 __ B(&loop_check); | |
1197 __ Bind(&loop_header); | |
1198 // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned. | |
1199 __ Ldr(x3, MemOperand(x2, -kPointerSize, PostIndex)); | |
1200 __ Str(x3, MemOperand(x5, -kPointerSize, PreIndex)); | |
1201 __ Bind(&loop_check); | |
1202 __ Cmp(x2, x4); | |
1203 __ B(gt, &loop_header); | |
1204 | 1216 |
1205 // Call the target. | 1217 // Call the target. |
1206 if (function_type == CallableType::kJSFunction) { | 1218 if (function_type == CallableType::kJSFunction) { |
1207 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, | 1219 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, |
1208 tail_call_mode), | 1220 tail_call_mode), |
1209 RelocInfo::CODE_TARGET); | 1221 RelocInfo::CODE_TARGET); |
1210 } else { | 1222 } else { |
1211 DCHECK_EQ(function_type, CallableType::kAny); | 1223 DCHECK_EQ(function_type, CallableType::kAny); |
1212 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 1224 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
1213 tail_call_mode), | 1225 tail_call_mode), |
1214 RelocInfo::CODE_TARGET); | 1226 RelocInfo::CODE_TARGET); |
1215 } | 1227 } |
1216 } | 1228 } |
1217 | 1229 |
1218 // static | 1230 // static |
1219 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( | 1231 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
1220 MacroAssembler* masm, CallableType construct_type) { | 1232 MacroAssembler* masm, CallableType construct_type) { |
1221 // ----------- S t a t e ------------- | 1233 // ----------- S t a t e ------------- |
1222 // -- x0 : argument count (not including receiver) | 1234 // -- x0 : argument count (not including receiver) |
1223 // -- x3 : new target | 1235 // -- x3 : new target |
1224 // -- x1 : constructor to call | 1236 // -- x1 : constructor to call |
1225 // -- x2 : allocation site feedback if available, undefined otherwise | 1237 // -- x2 : allocation site feedback if available, undefined otherwise |
1226 // -- x4 : address of the first argument | 1238 // -- x4 : address of the first argument |
1227 // ----------------------------------- | 1239 // ----------------------------------- |
1228 | 1240 |
1229 // Find the address of the last argument. | 1241 // Push a slot for the receiver. |
1230 __ add(x5, x0, Operand(1)); // Add one for receiver (to be constructed). | 1242 __ Push(xzr); |
1231 __ lsl(x5, x5, kPointerSizeLog2); | |
1232 | 1243 |
1233 // Set stack pointer and where to stop. | 1244 // Push the arguments. x5, x4, x6, x7 will be modified. |
1234 __ Mov(x6, jssp); | 1245 Generate_InterpreterPushArgs(masm, x0, x4, x5, x6, x7); |
1235 __ Claim(x5, 1); | |
1236 __ sub(x7, x6, x5); | |
1237 | |
1238 // Push a slot for the receiver. | |
1239 __ Str(xzr, MemOperand(x6, -kPointerSize, PreIndex)); | |
1240 | |
1241 Label loop_header, loop_check; | |
1242 // TODO(mythria): Add a stack check before pushing arguments. | |
1243 // Push the arguments. | |
1244 __ B(&loop_check); | |
1245 __ Bind(&loop_header); | |
1246 // TODO(rmcilroy): Push two at a time once we ensure we keep stack aligned. | |
1247 __ Ldr(x5, MemOperand(x4, -kPointerSize, PostIndex)); | |
1248 __ Str(x5, MemOperand(x6, -kPointerSize, PreIndex)); | |
1249 __ Bind(&loop_check); | |
1250 __ Cmp(x6, x7); | |
1251 __ B(gt, &loop_header); | |
1252 | 1246 |
1253 __ AssertUndefinedOrAllocationSite(x2, x6); | 1247 __ AssertUndefinedOrAllocationSite(x2, x6); |
1254 if (construct_type == CallableType::kJSFunction) { | 1248 if (construct_type == CallableType::kJSFunction) { |
1255 __ AssertFunction(x1); | 1249 __ AssertFunction(x1); |
1256 | 1250 |
1257 // Tail call to the function-specific construct stub (still in the caller | 1251 // Tail call to the function-specific construct stub (still in the caller |
1258 // context at this point). | 1252 // context at this point). |
1259 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); | 1253 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); |
1260 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset)); | 1254 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset)); |
1261 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag); | 1255 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag); |
1262 __ Br(x4); | 1256 __ Br(x4); |
1263 } else { | 1257 } else { |
1264 DCHECK_EQ(construct_type, CallableType::kAny); | 1258 DCHECK_EQ(construct_type, CallableType::kAny); |
1265 // Call the constructor with x0, x1, and x3 unmodified. | 1259 // Call the constructor with x0, x1, and x3 unmodified. |
1266 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 1260 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
1267 } | 1261 } |
1268 } | 1262 } |
1269 | 1263 |
| 1264 // static |
| 1265 void Builtins::Generate_InterpreterPushArgsAndConstructArray( |
| 1266 MacroAssembler* masm) { |
| 1267 // ----------- S t a t e ------------- |
| 1268 // -- x0 : argument count (not including receiver) |
| 1269 // -- x1 : target to call verified to be Array function |
| 1270 // -- x2 : allocation site feedback if available, undefined otherwise. |
| 1271 // -- x3 : address of the first argument |
| 1272 // ----------------------------------- |
| 1273 |
| 1274 __ add(x4, x0, Operand(1)); // Add one for the receiver. |
| 1275 |
| 1276 // Push the arguments. x3, x5, x6, x7 will be modified. |
| 1277 Generate_InterpreterPushArgs(masm, x4, x3, x5, x6, x7); |
| 1278 |
| 1279 // Array constructor expects constructor in x3. It is same as call target. |
| 1280 __ mov(x3, x1); |
| 1281 |
| 1282 ArrayConstructorStub stub(masm->isolate()); |
| 1283 __ TailCallStub(&stub); |
| 1284 } |
| 1285 |
1270 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { | 1286 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
1271 // Set the return address to the correct point in the interpreter entry | 1287 // Set the return address to the correct point in the interpreter entry |
1272 // trampoline. | 1288 // trampoline. |
1273 Smi* interpreter_entry_return_pc_offset( | 1289 Smi* interpreter_entry_return_pc_offset( |
1274 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); | 1290 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); |
1275 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); | 1291 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); |
1276 __ LoadObject(x1, masm->isolate()->builtins()->InterpreterEntryTrampoline()); | 1292 __ LoadObject(x1, masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
1277 __ Add(lr, x1, Operand(interpreter_entry_return_pc_offset->value() + | 1293 __ Add(lr, x1, Operand(interpreter_entry_return_pc_offset->value() + |
1278 Code::kHeaderSize - kHeapObjectTag)); | 1294 Code::kHeaderSize - kHeapObjectTag)); |
1279 | 1295 |
(...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3064 __ Unreachable(); | 3080 __ Unreachable(); |
3065 } | 3081 } |
3066 } | 3082 } |
3067 | 3083 |
3068 #undef __ | 3084 #undef __ |
3069 | 3085 |
3070 } // namespace internal | 3086 } // namespace internal |
3071 } // namespace v8 | 3087 } // namespace v8 |
3072 | 3088 |
3073 #endif // V8_TARGET_ARCH_ARM | 3089 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |