OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_ARM | 5 #if V8_TARGET_ARCH_ARM |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1155 // Push function as argument and compile for baseline. | 1155 // Push function as argument and compile for baseline. |
1156 __ push(r1); | 1156 __ push(r1); |
1157 __ CallRuntime(Runtime::kCompileBaseline); | 1157 __ CallRuntime(Runtime::kCompileBaseline); |
1158 | 1158 |
1159 // Restore return value. | 1159 // Restore return value. |
1160 __ pop(r0); | 1160 __ pop(r0); |
1161 } | 1161 } |
1162 __ Jump(lr); | 1162 __ Jump(lr); |
1163 } | 1163 } |
1164 | 1164 |
1165 static void Generate_InterpreterPushArgs(MacroAssembler* masm, Register index, | 1165 static void Generate_InterpreterPushArgs(MacroAssembler* masm, |
1166 Register limit, Register scratch) { | 1166 Register num_args, Register index, |
1167 Register scratch) { | |
rmcilroy
2016/09/07 10:57:39
Could you just pass an extra scratch register and
mythria
2016/09/07 13:11:15
Done.
| |
1168 Register limit = num_args; | |
1169 | |
1170 // Find the address of the last argument. | |
1171 __ mov(limit, Operand(limit, LSL, kPointerSizeLog2)); | |
1172 __ sub(limit, index, limit); | |
1173 | |
1174 // TODO(mythria): Add a stack check before pushing arguments. | |
1167 Label loop_header, loop_check; | 1175 Label loop_header, loop_check; |
1168 __ b(al, &loop_check); | 1176 __ b(al, &loop_check); |
1169 __ bind(&loop_header); | 1177 __ bind(&loop_header); |
1170 __ ldr(scratch, MemOperand(index, -kPointerSize, PostIndex)); | 1178 __ ldr(scratch, MemOperand(index, -kPointerSize, PostIndex)); |
1171 __ push(scratch); | 1179 __ push(scratch); |
1172 __ bind(&loop_check); | 1180 __ bind(&loop_check); |
1173 __ cmp(index, limit); | 1181 __ cmp(index, limit); |
1174 __ b(gt, &loop_header); | 1182 __ b(gt, &loop_header); |
1175 } | 1183 } |
1176 | 1184 |
1177 // static | 1185 // static |
1178 void Builtins::Generate_InterpreterPushArgsAndCallImpl( | 1186 void Builtins::Generate_InterpreterPushArgsAndCallImpl( |
1179 MacroAssembler* masm, TailCallMode tail_call_mode, | 1187 MacroAssembler* masm, TailCallMode tail_call_mode, |
1180 CallableType function_type) { | 1188 CallableType function_type) { |
1181 // ----------- S t a t e ------------- | 1189 // ----------- S t a t e ------------- |
1182 // -- r0 : the number of arguments (not including the receiver) | 1190 // -- r0 : the number of arguments (not including the receiver) |
1183 // -- r2 : the address of the first argument to be pushed. Subsequent | 1191 // -- r2 : the address of the first argument to be pushed. Subsequent |
1184 // arguments should be consecutive above this, in the same order as | 1192 // arguments should be consecutive above this, in the same order as |
1185 // they are to be pushed onto the stack. | 1193 // they are to be pushed onto the stack. |
1186 // -- r1 : the target to call (can be any Object). | 1194 // -- r1 : the target to call (can be any Object). |
1187 // ----------------------------------- | 1195 // ----------------------------------- |
1188 | 1196 |
1189 // Find the address of the last argument. | |
1190 __ add(r3, r0, Operand(1)); // Add one for receiver. | 1197 __ add(r3, r0, Operand(1)); // Add one for receiver. |
1191 __ mov(r3, Operand(r3, LSL, kPointerSizeLog2)); | |
1192 __ sub(r3, r2, r3); | |
1193 | 1198 |
1194 // TODO(mythria): Add a stack check before pushing arguments. | 1199 // Push the arguments. r2, r3, r4 will be modified. |
1195 // Push the arguments. | 1200 Generate_InterpreterPushArgs(masm, r3, r2, r4); |
1196 Generate_InterpreterPushArgs(masm, r2, r3, r4); | |
1197 | 1201 |
1198 // Call the target. | 1202 // Call the target. |
1199 if (function_type == CallableType::kJSFunction) { | 1203 if (function_type == CallableType::kJSFunction) { |
1200 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, | 1204 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, |
1201 tail_call_mode), | 1205 tail_call_mode), |
1202 RelocInfo::CODE_TARGET); | 1206 RelocInfo::CODE_TARGET); |
1203 } else { | 1207 } else { |
1204 DCHECK_EQ(function_type, CallableType::kAny); | 1208 DCHECK_EQ(function_type, CallableType::kAny); |
1205 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 1209 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
1206 tail_call_mode), | 1210 tail_call_mode), |
1207 RelocInfo::CODE_TARGET); | 1211 RelocInfo::CODE_TARGET); |
1208 } | 1212 } |
1209 } | 1213 } |
1210 | 1214 |
1211 // static | 1215 // static |
1212 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( | 1216 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
1213 MacroAssembler* masm, CallableType construct_type) { | 1217 MacroAssembler* masm, CallableType construct_type) { |
1214 // ----------- S t a t e ------------- | 1218 // ----------- S t a t e ------------- |
1215 // -- r0 : argument count (not including receiver) | 1219 // -- r0 : argument count (not including receiver) |
1216 // -- r3 : new target | 1220 // -- r3 : new target |
1217 // -- r1 : constructor to call | 1221 // -- r1 : constructor to call |
1218 // -- r2 : allocation site feedback if available, undefined otherwise. | 1222 // -- r2 : allocation site feedback if available, undefined otherwise. |
1219 // -- r4 : address of the first argument | 1223 // -- r4 : address of the first argument |
1220 // ----------------------------------- | 1224 // ----------------------------------- |
1221 | 1225 |
1222 // Find the address of the last argument. | |
1223 __ mov(r5, Operand(r0, LSL, kPointerSizeLog2)); | |
1224 __ sub(r5, r4, r5); | |
1225 | |
1226 // Push a slot for the receiver to be constructed. | 1226 // Push a slot for the receiver to be constructed. |
1227 __ mov(ip, Operand::Zero()); | 1227 __ mov(ip, Operand::Zero()); |
1228 __ push(ip); | 1228 __ push(ip); |
1229 | 1229 |
1230 // InterpreterPushArgs modified num_args, so copy argument count to a | |
1231 // different register. | |
1232 __ mov(r5, r0); | |
1233 | |
1230 // TODO(mythria): Add a stack check before pushing arguments. | 1234 // TODO(mythria): Add a stack check before pushing arguments. |
1231 // Push the arguments. | 1235 // Push the arguments. r5, r4, r6 will be modified. |
1232 Generate_InterpreterPushArgs(masm, r4, r5, r6); | 1236 Generate_InterpreterPushArgs(masm, r5, r4, r6); |
1233 | 1237 |
1234 __ AssertUndefinedOrAllocationSite(r2, r5); | 1238 __ AssertUndefinedOrAllocationSite(r2, r5); |
1235 if (construct_type == CallableType::kJSFunction) { | 1239 if (construct_type == CallableType::kJSFunction) { |
1236 __ AssertFunction(r1); | 1240 __ AssertFunction(r1); |
1237 | 1241 |
1238 // Tail call to the function-specific construct stub (still in the caller | 1242 // Tail call to the function-specific construct stub (still in the caller |
1239 // context at this point). | 1243 // context at this point). |
1240 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 1244 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
1241 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset)); | 1245 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset)); |
1242 // Jump to the construct function. | 1246 // Jump to the construct function. |
1243 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1247 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1244 | 1248 |
1245 } else { | 1249 } else { |
1246 DCHECK_EQ(construct_type, CallableType::kAny); | 1250 DCHECK_EQ(construct_type, CallableType::kAny); |
1247 // Call the constructor with r0, r1, and r3 unmodified. | 1251 // Call the constructor with r0, r1, and r3 unmodified. |
1248 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 1252 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
1249 } | 1253 } |
1250 } | 1254 } |
1251 | 1255 |
1256 // static | |
1257 void Builtins::Generate_InterpreterPushArgsAndConstructArray( | |
1258 MacroAssembler* masm) { | |
1259 // ----------- S t a t e ------------- | |
1260 // -- r0 : argument count (not including receiver) | |
1261 // -- r1 : target to call verified to be Array function | |
1262 // -- r2 : allocation site feedback if available, undefined otherwise. | |
1263 // -- r3 : address of the first argument | |
1264 // ----------------------------------- | |
1265 | |
1266 __ add(r4, r0, Operand(1)); // Add one for receiver. | |
1267 | |
1268 // TODO(mythria): Add a stack check before pushing arguments. | |
1269 // Push the arguments. r4, r3, r5 will be modified. | |
1270 Generate_InterpreterPushArgs(masm, r4, r3, r5); | |
1271 | |
1272 // Array constructor expects constructor in r3. It is same as r1 here. | |
1273 __ mov(r3, r1); | |
1274 | |
1275 ArrayConstructorStub stub(masm->isolate()); | |
1276 __ TailCallStub(&stub); | |
1277 } | |
1278 | |
1252 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { | 1279 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
1253 // Set the return address to the correct point in the interpreter entry | 1280 // Set the return address to the correct point in the interpreter entry |
1254 // trampoline. | 1281 // trampoline. |
1255 Smi* interpreter_entry_return_pc_offset( | 1282 Smi* interpreter_entry_return_pc_offset( |
1256 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); | 1283 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); |
1257 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); | 1284 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); |
1258 __ Move(r2, masm->isolate()->builtins()->InterpreterEntryTrampoline()); | 1285 __ Move(r2, masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
1259 __ add(lr, r2, Operand(interpreter_entry_return_pc_offset->value() + | 1286 __ add(lr, r2, Operand(interpreter_entry_return_pc_offset->value() + |
1260 Code::kHeaderSize - kHeapObjectTag)); | 1287 Code::kHeaderSize - kHeapObjectTag)); |
1261 | 1288 |
(...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2951 __ bkpt(0); | 2978 __ bkpt(0); |
2952 } | 2979 } |
2953 } | 2980 } |
2954 | 2981 |
2955 #undef __ | 2982 #undef __ |
2956 | 2983 |
2957 } // namespace internal | 2984 } // namespace internal |
2958 } // namespace v8 | 2985 } // namespace v8 |
2959 | 2986 |
2960 #endif // V8_TARGET_ARCH_ARM | 2987 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |