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