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

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

Issue 2681783002: X87: [turbofan] Introduce JSCallForwardVarargs operator. (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | src/x87/interface-descriptors-x87.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_X87 5 #if V8_TARGET_ARCH_X87
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 2294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2305 } 2305 }
2306 2306
2307 // Dispatch to Call or Construct depending on whether new.target is undefined. 2307 // Dispatch to Call or Construct depending on whether new.target is undefined.
2308 { 2308 {
2309 __ CompareRoot(edx, Heap::kUndefinedValueRootIndex); 2309 __ CompareRoot(edx, Heap::kUndefinedValueRootIndex);
2310 __ j(equal, masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); 2310 __ j(equal, masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
2311 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 2311 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
2312 } 2312 }
2313 } 2313 }
2314 2314
2315 // static
2316 void Builtins::Generate_CallForwardVarargs(MacroAssembler* masm,
2317 Handle<Code> code) {
2318 // ----------- S t a t e -------------
2319 // -- edi : the target to call (can be any Object)
2320 // -- ecx : start index (to support rest parameters)
2321 // -- esp[0] : return address.
2322 // -- esp[4] : thisArgument
2323 // -----------------------------------
2324
2325 // Check if we have an arguments adaptor frame below the function frame.
2326 Label arguments_adaptor, arguments_done;
2327 __ mov(ebx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
2328 __ cmp(Operand(ebx, CommonFrameConstants::kContextOrFrameTypeOffset),
2329 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
2330 __ j(equal, &arguments_adaptor, Label::kNear);
2331 {
2332 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
2333 __ mov(eax, FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset));
2334 __ mov(eax,
2335 FieldOperand(eax, SharedFunctionInfo::kFormalParameterCountOffset));
2336 __ mov(ebx, ebp);
2337 }
2338 __ jmp(&arguments_done, Label::kNear);
2339 __ bind(&arguments_adaptor);
2340 {
2341 // Just load the length from the ArgumentsAdaptorFrame.
2342 __ mov(eax, Operand(ebx, ArgumentsAdaptorFrameConstants::kLengthOffset));
2343 }
2344 __ bind(&arguments_done);
2345
2346 Label stack_empty, stack_done;
2347 __ SmiUntag(eax);
2348 __ sub(eax, ecx);
2349 __ j(less_equal, &stack_empty);
2350 {
2351 // Check for stack overflow.
2352 {
2353 // Check the stack for overflow. We are not trying to catch interruptions
2354 // (i.e. debug break and preemption) here, so check the "real stack
2355 // limit".
2356 Label done;
2357 __ LoadRoot(ecx, Heap::kRealStackLimitRootIndex);
2358 // Make ecx the space we have left. The stack might already be
2359 // overflowed here which will cause ecx to become negative.
2360 __ neg(ecx);
2361 __ add(ecx, esp);
2362 __ sar(ecx, kPointerSizeLog2);
2363 // Check if the arguments will overflow the stack.
2364 __ cmp(ecx, eax);
2365 __ j(greater, &done, Label::kNear); // Signed comparison.
2366 __ TailCallRuntime(Runtime::kThrowStackOverflow);
2367 __ bind(&done);
2368 }
2369
2370 // Forward the arguments from the caller frame.
2371 {
2372 Label loop;
2373 __ mov(ecx, eax);
2374 __ pop(edx);
2375 __ bind(&loop);
2376 {
2377 __ Push(Operand(ebx, ecx, times_pointer_size, 1 * kPointerSize));
2378 __ dec(ecx);
2379 __ j(not_zero, &loop);
2380 }
2381 __ push(edx);
2382 }
2383 }
2384 __ jmp(&stack_done, Label::kNear);
2385 __ bind(&stack_empty);
2386 {
2387 // We just pass the receiver, which is already on the stack.
2388 __ Move(eax, Immediate(0));
2389 }
2390 __ bind(&stack_done);
2391
2392 __ Jump(code, RelocInfo::CODE_TARGET);
2393 }
2394
2315 namespace { 2395 namespace {
2316 2396
2317 // Drops top JavaScript frame and an arguments adaptor frame below it (if 2397 // Drops top JavaScript frame and an arguments adaptor frame below it (if
2318 // present) preserving all the arguments prepared for current call. 2398 // present) preserving all the arguments prepared for current call.
2319 // Does nothing if debugger is currently active. 2399 // Does nothing if debugger is currently active.
2320 // ES6 14.6.3. PrepareForTailCall 2400 // ES6 14.6.3. PrepareForTailCall
2321 // 2401 //
2322 // Stack structure for the function g() tail calling f(): 2402 // Stack structure for the function g() tail calling f():
2323 // 2403 //
2324 // ------- Caller frame: ------- 2404 // ------- Caller frame: -------
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
3334 3414
3335 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { 3415 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
3336 Generate_OnStackReplacementHelper(masm, true); 3416 Generate_OnStackReplacementHelper(masm, true);
3337 } 3417 }
3338 3418
3339 #undef __ 3419 #undef __
3340 } // namespace internal 3420 } // namespace internal
3341 } // namespace v8 3421 } // namespace v8
3342 3422
3343 #endif // V8_TARGET_ARCH_X87 3423 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | src/x87/interface-descriptors-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698