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 2315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2326 // ----------------------------------- | 2326 // ----------------------------------- |
2327 | 2327 |
2328 // Dispatch to Call or Construct depending on whether new.target is undefined. | 2328 // Dispatch to Call or Construct depending on whether new.target is undefined. |
2329 { | 2329 { |
2330 __ CompareRoot(new_target, Heap::kUndefinedValueRootIndex); | 2330 __ CompareRoot(new_target, Heap::kUndefinedValueRootIndex); |
2331 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET, eq); | 2331 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET, eq); |
2332 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 2332 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
2333 } | 2333 } |
2334 } | 2334 } |
2335 | 2335 |
| 2336 // static |
| 2337 void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm, |
| 2338 Handle<Code> code) { |
| 2339 // ----------- S t a t e ------------- |
| 2340 // -- x1 : the target to call (can be any Object) |
| 2341 // -- x2 : start index (to support rest parameters) |
| 2342 // -- lr : return address. |
| 2343 // -- sp[0] : thisArgument |
| 2344 // ----------------------------------- |
| 2345 |
| 2346 // Check if we have an arguments adaptor frame below the function frame. |
| 2347 Label arguments_adaptor, arguments_done; |
| 2348 __ Ldr(x3, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 2349 __ Ldr(x4, MemOperand(x3, CommonFrameConstants::kContextOrFrameTypeOffset)); |
| 2350 __ Cmp(x4, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
| 2351 __ B(eq, &arguments_adaptor); |
| 2352 { |
| 2353 __ Ldr(x0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 2354 __ Ldr(x0, FieldMemOperand(x0, JSFunction::kSharedFunctionInfoOffset)); |
| 2355 __ Ldrsw(x0, FieldMemOperand( |
| 2356 x0, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 2357 __ Mov(x3, fp); |
| 2358 } |
| 2359 __ B(&arguments_done); |
| 2360 __ Bind(&arguments_adaptor); |
| 2361 { |
| 2362 // Just load the length from ArgumentsAdaptorFrame. |
| 2363 __ Ldrsw(x0, UntagSmiMemOperand( |
| 2364 x3, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 2365 } |
| 2366 __ Bind(&arguments_done); |
| 2367 |
| 2368 Label stack_empty, stack_done, stack_overflow; |
| 2369 __ Subs(x0, x0, x2); |
| 2370 __ B(le, &stack_empty); |
| 2371 { |
| 2372 // Check for stack overflow. |
| 2373 Generate_StackOverflowCheck(masm, x0, x2, &stack_overflow); |
| 2374 |
| 2375 // Forward the arguments from the caller frame. |
| 2376 { |
| 2377 Label loop; |
| 2378 __ Add(x3, x3, kPointerSize); |
| 2379 __ Mov(x2, x0); |
| 2380 __ bind(&loop); |
| 2381 { |
| 2382 __ Ldr(x4, MemOperand(x3, x2, LSL, kPointerSizeLog2)); |
| 2383 __ Push(x4); |
| 2384 __ Subs(x2, x2, 1); |
| 2385 __ B(ne, &loop); |
| 2386 } |
| 2387 } |
| 2388 } |
| 2389 __ B(&stack_done); |
| 2390 __ Bind(&stack_overflow); |
| 2391 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 2392 __ Bind(&stack_empty); |
| 2393 { |
| 2394 // We just pass the receiver, which is already on the stack. |
| 2395 __ Mov(x0, 0); |
| 2396 } |
| 2397 __ Bind(&stack_done); |
| 2398 |
| 2399 __ Jump(code, RelocInfo::CODE_TARGET); |
| 2400 } |
| 2401 |
2336 namespace { | 2402 namespace { |
2337 | 2403 |
2338 // Drops top JavaScript frame and an arguments adaptor frame below it (if | 2404 // Drops top JavaScript frame and an arguments adaptor frame below it (if |
2339 // present) preserving all the arguments prepared for current call. | 2405 // present) preserving all the arguments prepared for current call. |
2340 // Does nothing if debugger is currently active. | 2406 // Does nothing if debugger is currently active. |
2341 // ES6 14.6.3. PrepareForTailCall | 2407 // ES6 14.6.3. PrepareForTailCall |
2342 // | 2408 // |
2343 // Stack structure for the function g() tail calling f(): | 2409 // Stack structure for the function g() tail calling f(): |
2344 // | 2410 // |
2345 // ------- Caller frame: ------- | 2411 // ------- Caller frame: ------- |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3161 __ Unreachable(); | 3227 __ Unreachable(); |
3162 } | 3228 } |
3163 } | 3229 } |
3164 | 3230 |
3165 #undef __ | 3231 #undef __ |
3166 | 3232 |
3167 } // namespace internal | 3233 } // namespace internal |
3168 } // namespace v8 | 3234 } // namespace v8 |
3169 | 3235 |
3170 #endif // V8_TARGET_ARCH_ARM | 3236 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |