OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
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 2285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 } | 2296 } |
2297 | 2297 |
2298 // Dispatch to Call or Construct depending on whether new.target is undefined. | 2298 // Dispatch to Call or Construct depending on whether new.target is undefined. |
2299 { | 2299 { |
2300 __ CompareRoot(r6, Heap::kUndefinedValueRootIndex); | 2300 __ CompareRoot(r6, Heap::kUndefinedValueRootIndex); |
2301 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET, eq); | 2301 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET, eq); |
2302 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 2302 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
2303 } | 2303 } |
2304 } | 2304 } |
2305 | 2305 |
| 2306 // static |
| 2307 void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm, |
| 2308 Handle<Code> code) { |
| 2309 // ----------- S t a t e ------------- |
| 2310 // -- r4 : the target to call (can be any Object) |
| 2311 // -- r5 : start index (to support rest parameters) |
| 2312 // -- lr : return address. |
| 2313 // -- sp[0] : thisArgument |
| 2314 // ----------------------------------- |
| 2315 |
| 2316 // Check if we have an arguments adaptor frame below the function frame. |
| 2317 Label arguments_adaptor, arguments_done; |
| 2318 __ LoadP(r6, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 2319 __ LoadP(ip, MemOperand(r6, CommonFrameConstants::kContextOrFrameTypeOffset)); |
| 2320 __ CmpSmiLiteral(ip, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 2321 __ beq(&arguments_adaptor); |
| 2322 { |
| 2323 __ LoadP(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 2324 __ LoadP(r3, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset)); |
| 2325 __ LoadWordArith( |
| 2326 r3, |
| 2327 FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 2328 __ mr(r6, fp); |
| 2329 } |
| 2330 __ b(&arguments_done); |
| 2331 __ bind(&arguments_adaptor); |
| 2332 { |
| 2333 // Load the length from the ArgumentsAdaptorFrame. |
| 2334 __ LoadP(r3, MemOperand(r6, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 2335 } |
| 2336 __ bind(&arguments_done); |
| 2337 |
| 2338 Label stack_empty, stack_done, stack_overflow; |
| 2339 __ SmiUntag(r3); |
| 2340 __ sub(r3, r3, r5); |
| 2341 __ cmpi(r3, Operand::Zero()); |
| 2342 __ ble(&stack_empty); |
| 2343 { |
| 2344 // Check for stack overflow. |
| 2345 Generate_StackOverflowCheck(masm, r3, r5, &stack_overflow); |
| 2346 |
| 2347 // Forward the arguments from the caller frame. |
| 2348 { |
| 2349 Label loop; |
| 2350 __ addi(r6, r6, Operand(kPointerSize)); |
| 2351 __ mr(r5, r3); |
| 2352 __ bind(&loop); |
| 2353 { |
| 2354 __ ShiftLeftImm(ip, r5, Operand(kPointerSizeLog2)); |
| 2355 __ LoadPX(ip, MemOperand(r6, ip)); |
| 2356 __ push(ip); |
| 2357 __ subi(r5, r5, Operand(1)); |
| 2358 __ cmpi(r5, Operand::Zero()); |
| 2359 __ bne(&loop); |
| 2360 } |
| 2361 } |
| 2362 } |
| 2363 __ b(&stack_done); |
| 2364 __ bind(&stack_overflow); |
| 2365 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 2366 __ bind(&stack_empty); |
| 2367 { |
| 2368 // We just pass the receiver, which is already on the stack. |
| 2369 __ mov(r3, Operand::Zero()); |
| 2370 } |
| 2371 __ bind(&stack_done); |
| 2372 |
| 2373 __ Jump(code, RelocInfo::CODE_TARGET); |
| 2374 } |
| 2375 |
2306 namespace { | 2376 namespace { |
2307 | 2377 |
2308 // Drops top JavaScript frame and an arguments adaptor frame below it (if | 2378 // Drops top JavaScript frame and an arguments adaptor frame below it (if |
2309 // present) preserving all the arguments prepared for current call. | 2379 // present) preserving all the arguments prepared for current call. |
2310 // Does nothing if debugger is currently active. | 2380 // Does nothing if debugger is currently active. |
2311 // ES6 14.6.3. PrepareForTailCall | 2381 // ES6 14.6.3. PrepareForTailCall |
2312 // | 2382 // |
2313 // Stack structure for the function g() tail calling f(): | 2383 // Stack structure for the function g() tail calling f(): |
2314 // | 2384 // |
2315 // ------- Caller frame: ------- | 2385 // ------- Caller frame: ------- |
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3111 __ CallRuntime(Runtime::kThrowStackOverflow); | 3181 __ CallRuntime(Runtime::kThrowStackOverflow); |
3112 __ bkpt(0); | 3182 __ bkpt(0); |
3113 } | 3183 } |
3114 } | 3184 } |
3115 | 3185 |
3116 #undef __ | 3186 #undef __ |
3117 } // namespace internal | 3187 } // namespace internal |
3118 } // namespace v8 | 3188 } // namespace v8 |
3119 | 3189 |
3120 #endif // V8_TARGET_ARCH_PPC | 3190 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |