| 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 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2191 | 2191 |
| 2192 // Dispatch to Call or Construct depending on whether new.target is undefined. | 2192 // Dispatch to Call or Construct depending on whether new.target is undefined. |
| 2193 { | 2193 { |
| 2194 __ CompareRoot(r6, Heap::kUndefinedValueRootIndex); | 2194 __ CompareRoot(r6, Heap::kUndefinedValueRootIndex); |
| 2195 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET, eq); | 2195 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET, eq); |
| 2196 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 2196 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
| 2197 } | 2197 } |
| 2198 } | 2198 } |
| 2199 | 2199 |
| 2200 // static | 2200 // static |
| 2201 void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm, | 2201 void Builtins::Generate_ForwardVarargs(MacroAssembler* masm, |
| 2202 Handle<Code> code) { | 2202 Handle<Code> code) { |
| 2203 // ----------- S t a t e ------------- | 2203 // ----------- S t a t e ------------- |
| 2204 // -- r4 : the target to call (can be any Object) | 2204 // -- r3 : the number of arguments (not including the receiver) |
| 2205 // -- r5 : start index (to support rest parameters) | 2205 // -- r6 : the new.target (for [[Construct]] calls) |
| 2206 // -- lr : return address. | 2206 // -- r4 : the target to call (can be any Object) |
| 2207 // -- sp[0] : thisArgument | 2207 // -- r5 : start index (to support rest parameters) |
| 2208 // ----------------------------------- | 2208 // ----------------------------------- |
| 2209 | 2209 |
| 2210 // Check if we have an arguments adaptor frame below the function frame. | 2210 // Check if we have an arguments adaptor frame below the function frame. |
| 2211 Label arguments_adaptor, arguments_done; | 2211 Label arguments_adaptor, arguments_done; |
| 2212 __ LoadP(r6, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 2212 __ LoadP(r7, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 2213 __ LoadP(ip, MemOperand(r6, CommonFrameConstants::kContextOrFrameTypeOffset)); | 2213 __ LoadP(ip, MemOperand(r7, CommonFrameConstants::kContextOrFrameTypeOffset)); |
| 2214 __ cmpi(ip, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); | 2214 __ cmpi(ip, Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); |
| 2215 __ beq(&arguments_adaptor); | 2215 __ beq(&arguments_adaptor); |
| 2216 { | 2216 { |
| 2217 __ LoadP(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 2217 __ LoadP(r8, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 2218 __ LoadP(r3, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset)); | 2218 __ LoadP(r8, FieldMemOperand(r8, JSFunction::kSharedFunctionInfoOffset)); |
| 2219 __ LoadWordArith( | 2219 __ LoadWordArith( |
| 2220 r3, | 2220 r8, |
| 2221 FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset)); | 2221 FieldMemOperand(r8, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 2222 __ mr(r6, fp); | 2222 __ mr(r7, fp); |
| 2223 } | 2223 } |
| 2224 __ b(&arguments_done); | 2224 __ b(&arguments_done); |
| 2225 __ bind(&arguments_adaptor); | 2225 __ bind(&arguments_adaptor); |
| 2226 { | 2226 { |
| 2227 // Load the length from the ArgumentsAdaptorFrame. | 2227 // Load the length from the ArgumentsAdaptorFrame. |
| 2228 __ LoadP(r3, MemOperand(r6, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 2228 __ LoadP(r8, MemOperand(r7, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 2229 #if V8_TARGET_ARCH_PPC64 | 2229 #if V8_TARGET_ARCH_PPC64 |
| 2230 __ SmiUntag(r3); | 2230 __ SmiUntag(r8); |
| 2231 #endif | 2231 #endif |
| 2232 } | 2232 } |
| 2233 __ bind(&arguments_done); | 2233 __ bind(&arguments_done); |
| 2234 | 2234 |
| 2235 Label stack_empty, stack_done, stack_overflow; | 2235 Label stack_done, stack_overflow; |
| 2236 #if !V8_TARGET_ARCH_PPC64 | 2236 #if !V8_TARGET_ARCH_PPC64 |
| 2237 __ SmiUntag(r3); | 2237 __ SmiUntag(r8); |
| 2238 #endif | 2238 #endif |
| 2239 __ sub(r3, r3, r5); | 2239 __ sub(r8, r8, r5); |
| 2240 __ cmpi(r3, Operand::Zero()); | 2240 __ cmpi(r8, Operand::Zero()); |
| 2241 __ ble(&stack_empty); | 2241 __ ble(&stack_done); |
| 2242 { | 2242 { |
| 2243 // Check for stack overflow. | 2243 // Check for stack overflow. |
| 2244 Generate_StackOverflowCheck(masm, r3, r5, &stack_overflow); | 2244 Generate_StackOverflowCheck(masm, r8, r5, &stack_overflow); |
| 2245 | 2245 |
| 2246 // Forward the arguments from the caller frame. | 2246 // Forward the arguments from the caller frame. |
| 2247 { | 2247 { |
| 2248 Label loop; | 2248 Label loop; |
| 2249 __ addi(r6, r6, Operand(kPointerSize)); | 2249 __ addi(r7, r7, Operand(kPointerSize)); |
| 2250 __ mr(r5, r3); | 2250 __ add(r3, r3, r8); |
| 2251 __ bind(&loop); | 2251 __ bind(&loop); |
| 2252 { | 2252 { |
| 2253 __ ShiftLeftImm(ip, r5, Operand(kPointerSizeLog2)); | 2253 __ ShiftLeftImm(ip, r8, Operand(kPointerSizeLog2)); |
| 2254 __ LoadPX(ip, MemOperand(r6, ip)); | 2254 __ LoadPX(ip, MemOperand(r7, ip)); |
| 2255 __ push(ip); | 2255 __ push(ip); |
| 2256 __ subi(r5, r5, Operand(1)); | 2256 __ subi(r8, r8, Operand(1)); |
| 2257 __ cmpi(r5, Operand::Zero()); | 2257 __ cmpi(r8, Operand::Zero()); |
| 2258 __ bne(&loop); | 2258 __ bne(&loop); |
| 2259 } | 2259 } |
| 2260 } | 2260 } |
| 2261 } | 2261 } |
| 2262 __ b(&stack_done); | 2262 __ b(&stack_done); |
| 2263 __ bind(&stack_overflow); | 2263 __ bind(&stack_overflow); |
| 2264 __ TailCallRuntime(Runtime::kThrowStackOverflow); | 2264 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
| 2265 __ bind(&stack_empty); | |
| 2266 { | |
| 2267 // We just pass the receiver, which is already on the stack. | |
| 2268 __ mov(r3, Operand::Zero()); | |
| 2269 } | |
| 2270 __ bind(&stack_done); | 2265 __ bind(&stack_done); |
| 2271 | 2266 |
| 2267 // Tail-call to the {code} handler. |
| 2272 __ Jump(code, RelocInfo::CODE_TARGET); | 2268 __ Jump(code, RelocInfo::CODE_TARGET); |
| 2273 } | 2269 } |
| 2274 | 2270 |
| 2275 namespace { | 2271 namespace { |
| 2276 | 2272 |
| 2277 // Drops top JavaScript frame and an arguments adaptor frame below it (if | 2273 // Drops top JavaScript frame and an arguments adaptor frame below it (if |
| 2278 // present) preserving all the arguments prepared for current call. | 2274 // present) preserving all the arguments prepared for current call. |
| 2279 // Does nothing if debugger is currently active. | 2275 // Does nothing if debugger is currently active. |
| 2280 // ES6 14.6.3. PrepareForTailCall | 2276 // ES6 14.6.3. PrepareForTailCall |
| 2281 // | 2277 // |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3135 } | 3131 } |
| 3136 // Now jump to the instructions of the returned code object. | 3132 // Now jump to the instructions of the returned code object. |
| 3137 __ Jump(r11); | 3133 __ Jump(r11); |
| 3138 } | 3134 } |
| 3139 | 3135 |
| 3140 #undef __ | 3136 #undef __ |
| 3141 } // namespace internal | 3137 } // namespace internal |
| 3142 } // namespace v8 | 3138 } // namespace v8 |
| 3143 | 3139 |
| 3144 #endif // V8_TARGET_ARCH_PPC | 3140 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |