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 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 // arguments should be consecutive above this, in the same order as | 1182 // arguments should be consecutive above this, in the same order as |
1183 // they are to be pushed onto the stack. | 1183 // they are to be pushed onto the stack. |
1184 // -- r1 : the target to call (can be any Object). | 1184 // -- r1 : the target to call (can be any Object). |
1185 // ----------------------------------- | 1185 // ----------------------------------- |
1186 | 1186 |
1187 // Find the address of the last argument. | 1187 // Find the address of the last argument. |
1188 __ add(r3, r0, Operand(1)); // Add one for receiver. | 1188 __ add(r3, r0, Operand(1)); // Add one for receiver. |
1189 __ mov(r3, Operand(r3, LSL, kPointerSizeLog2)); | 1189 __ mov(r3, Operand(r3, LSL, kPointerSizeLog2)); |
1190 __ sub(r3, r2, r3); | 1190 __ sub(r3, r2, r3); |
1191 | 1191 |
| 1192 // TODO(mythria): Add a stack check before pushing arguments. |
1192 // Push the arguments. | 1193 // Push the arguments. |
1193 Generate_InterpreterPushArgs(masm, r2, r3, r4); | 1194 Generate_InterpreterPushArgs(masm, r2, r3, r4); |
1194 | 1195 |
1195 // Call the target. | 1196 // Call the target. |
1196 if (function_type == CallableType::kJSFunction) { | 1197 if (function_type == CallableType::kJSFunction) { |
1197 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, | 1198 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, |
1198 tail_call_mode), | 1199 tail_call_mode), |
1199 RelocInfo::CODE_TARGET); | 1200 RelocInfo::CODE_TARGET); |
1200 } else { | 1201 } else { |
1201 DCHECK_EQ(function_type, CallableType::kAny); | 1202 DCHECK_EQ(function_type, CallableType::kAny); |
1202 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, | 1203 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, |
1203 tail_call_mode), | 1204 tail_call_mode), |
1204 RelocInfo::CODE_TARGET); | 1205 RelocInfo::CODE_TARGET); |
1205 } | 1206 } |
1206 } | 1207 } |
1207 | 1208 |
1208 // static | 1209 // static |
1209 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { | 1210 void Builtins::Generate_InterpreterPushArgsAndConstructImpl( |
| 1211 MacroAssembler* masm, CallableType construct_type) { |
1210 // ----------- S t a t e ------------- | 1212 // ----------- S t a t e ------------- |
1211 // -- r0 : argument count (not including receiver) | 1213 // -- r0 : argument count (not including receiver) |
1212 // -- r3 : new target | 1214 // -- r3 : new target |
1213 // -- r1 : constructor to call | 1215 // -- r1 : constructor to call |
1214 // -- r2 : address of the first argument | 1216 // -- r2 : allocation site feedback if available, undefined otherwise. |
| 1217 // -- r4 : address of the first argument |
1215 // ----------------------------------- | 1218 // ----------------------------------- |
1216 | 1219 |
1217 // Find the address of the last argument. | 1220 // Find the address of the last argument. |
1218 __ mov(r4, Operand(r0, LSL, kPointerSizeLog2)); | 1221 __ mov(r5, Operand(r0, LSL, kPointerSizeLog2)); |
1219 __ sub(r4, r2, r4); | 1222 __ sub(r5, r4, r5); |
1220 | 1223 |
1221 // Push a slot for the receiver to be constructed. | 1224 // Push a slot for the receiver to be constructed. |
1222 __ mov(ip, Operand::Zero()); | 1225 __ mov(ip, Operand::Zero()); |
1223 __ push(ip); | 1226 __ push(ip); |
1224 | 1227 |
| 1228 // TODO(mythria): Add a stack check before pushing arguments. |
1225 // Push the arguments. | 1229 // Push the arguments. |
1226 Generate_InterpreterPushArgs(masm, r2, r4, r5); | 1230 Generate_InterpreterPushArgs(masm, r4, r5, r6); |
1227 | 1231 |
1228 // Call the constructor with r0, r1, and r3 unmodified. | 1232 __ AssertUndefinedOrAllocationSite(r2, r5); |
1229 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 1233 if (construct_type == CallableType::kJSFunction) { |
| 1234 __ AssertFunction(r1); |
| 1235 |
| 1236 // Tail call to the function-specific construct stub (still in the caller |
| 1237 // context at this point). |
| 1238 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
| 1239 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset)); |
| 1240 // Jump to the construct function. |
| 1241 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 1242 |
| 1243 } else { |
| 1244 DCHECK_EQ(construct_type, CallableType::kAny); |
| 1245 // Call the constructor with r0, r1, and r3 unmodified. |
| 1246 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
| 1247 } |
1230 } | 1248 } |
1231 | 1249 |
1232 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { | 1250 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
1233 // Set the return address to the correct point in the interpreter entry | 1251 // Set the return address to the correct point in the interpreter entry |
1234 // trampoline. | 1252 // trampoline. |
1235 Smi* interpreter_entry_return_pc_offset( | 1253 Smi* interpreter_entry_return_pc_offset( |
1236 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); | 1254 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); |
1237 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); | 1255 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); |
1238 __ Move(r2, masm->isolate()->builtins()->InterpreterEntryTrampoline()); | 1256 __ Move(r2, masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
1239 __ add(lr, r2, Operand(interpreter_entry_return_pc_offset->value() + | 1257 __ add(lr, r2, Operand(interpreter_entry_return_pc_offset->value() + |
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2919 __ bkpt(0); | 2937 __ bkpt(0); |
2920 } | 2938 } |
2921 } | 2939 } |
2922 | 2940 |
2923 #undef __ | 2941 #undef __ |
2924 | 2942 |
2925 } // namespace internal | 2943 } // namespace internal |
2926 } // namespace v8 | 2944 } // namespace v8 |
2927 | 2945 |
2928 #endif // V8_TARGET_ARCH_ARM | 2946 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |