Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Side by Side Diff: src/builtins/ia32/builtins-ia32.cc

Issue 2655233002: [turbofan] Introduce JSCallForwardVarargs operator. (Closed)
Patch Set: Fix formatting. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins/builtins-call.cc ('k') | src/builtins/mips/builtins-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.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 2275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2286 } 2286 }
2287 2287
2288 // Dispatch to Call or Construct depending on whether new.target is undefined. 2288 // Dispatch to Call or Construct depending on whether new.target is undefined.
2289 { 2289 {
2290 __ CompareRoot(edx, Heap::kUndefinedValueRootIndex); 2290 __ CompareRoot(edx, Heap::kUndefinedValueRootIndex);
2291 __ j(equal, masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); 2291 __ j(equal, masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
2292 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 2292 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
2293 } 2293 }
2294 } 2294 }
2295 2295
2296 // static
2297 void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm,
2298 Handle<Code> code) {
2299 // ----------- S t a t e -------------
2300 // -- edi : the target to call (can be any Object)
2301 // -- ecx : start index (to support rest parameters)
2302 // -- esp[0] : return address.
2303 // -- esp[4] : thisArgument
2304 // -----------------------------------
2305
2306 // Check if we have an arguments adaptor frame below the function frame.
2307 Label arguments_adaptor, arguments_done;
2308 __ mov(ebx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
2309 __ cmp(Operand(ebx, CommonFrameConstants::kContextOrFrameTypeOffset),
2310 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
2311 __ j(equal, &arguments_adaptor, Label::kNear);
2312 {
2313 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
2314 __ mov(eax, FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset));
2315 __ mov(eax,
2316 FieldOperand(eax, SharedFunctionInfo::kFormalParameterCountOffset));
2317 __ mov(ebx, ebp);
2318 }
2319 __ jmp(&arguments_done, Label::kNear);
2320 __ bind(&arguments_adaptor);
2321 {
2322 // Just load the length from the ArgumentsAdaptorFrame.
2323 __ mov(eax, Operand(ebx, ArgumentsAdaptorFrameConstants::kLengthOffset));
2324 }
2325 __ bind(&arguments_done);
2326
2327 Label stack_empty, stack_done;
2328 __ SmiUntag(eax);
2329 __ sub(eax, ecx);
2330 __ j(less_equal, &stack_empty);
2331 {
2332 // Check for stack overflow.
2333 {
2334 // Check the stack for overflow. We are not trying to catch interruptions
2335 // (i.e. debug break and preemption) here, so check the "real stack
2336 // limit".
2337 Label done;
2338 __ LoadRoot(ecx, Heap::kRealStackLimitRootIndex);
2339 // Make ecx the space we have left. The stack might already be
2340 // overflowed here which will cause ecx to become negative.
2341 __ neg(ecx);
2342 __ add(ecx, esp);
2343 __ sar(ecx, kPointerSizeLog2);
2344 // Check if the arguments will overflow the stack.
2345 __ cmp(ecx, eax);
2346 __ j(greater, &done, Label::kNear); // Signed comparison.
2347 __ TailCallRuntime(Runtime::kThrowStackOverflow);
2348 __ bind(&done);
2349 }
2350
2351 // Forward the arguments from the caller frame.
2352 {
2353 Label loop;
2354 __ mov(ecx, eax);
2355 __ pop(edx);
2356 __ bind(&loop);
2357 {
2358 __ Push(Operand(ebx, ecx, times_pointer_size, 1 * kPointerSize));
2359 __ dec(ecx);
2360 __ j(not_zero, &loop);
2361 }
2362 __ push(edx);
2363 }
2364 }
2365 __ jmp(&stack_done, Label::kNear);
2366 __ bind(&stack_empty);
2367 {
2368 // We just pass the receiver, which is already on the stack.
2369 __ Move(eax, Immediate(0));
2370 }
2371 __ bind(&stack_done);
2372
2373 __ Jump(code, RelocInfo::CODE_TARGET);
2374 }
2375
2296 namespace { 2376 namespace {
2297 2377
2298 // 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
2299 // present) preserving all the arguments prepared for current call. 2379 // present) preserving all the arguments prepared for current call.
2300 // Does nothing if debugger is currently active. 2380 // Does nothing if debugger is currently active.
2301 // ES6 14.6.3. PrepareForTailCall 2381 // ES6 14.6.3. PrepareForTailCall
2302 // 2382 //
2303 // Stack structure for the function g() tail calling f(): 2383 // Stack structure for the function g() tail calling f():
2304 // 2384 //
2305 // ------- Caller frame: ------- 2385 // ------- Caller frame: -------
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
3293 3373
3294 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { 3374 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
3295 Generate_OnStackReplacementHelper(masm, true); 3375 Generate_OnStackReplacementHelper(masm, true);
3296 } 3376 }
3297 3377
3298 #undef __ 3378 #undef __
3299 } // namespace internal 3379 } // namespace internal
3300 } // namespace v8 3380 } // namespace v8
3301 3381
3302 #endif // V8_TARGET_ARCH_IA32 3382 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/builtins/builtins-call.cc ('k') | src/builtins/mips/builtins-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698