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

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

Issue 1865833002: [generators] Decouple generator resume from fullcodegen. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
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_X64 5 #if V8_TARGET_ARCH_X64
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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 457
458 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { 458 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
459 Generate_JSEntryTrampolineHelper(masm, false); 459 Generate_JSEntryTrampolineHelper(masm, false);
460 } 460 }
461 461
462 462
463 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { 463 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
464 Generate_JSEntryTrampolineHelper(masm, true); 464 Generate_JSEntryTrampolineHelper(masm, true);
465 } 465 }
466 466
467 // static
468 void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
469 // ----------- S t a t e -------------
470 // -- rax : the value to pass to the generator
471 // -- rbx : the JSGeneratorObject to resume
472 // -- rdx : the resume mode (tagged)
473 // -- rsp[0] : return address
474 // -----------------------------------
475 __ AssertGeneratorObject(rbx);
476
477 // Store input value into generator object.
478 __ movp(FieldOperand(rbx, JSGeneratorObject::kInputOffset), rax);
479 __ RecordWriteField(rbx, JSGeneratorObject::kInputOffset, rax, rcx,
480 kDontSaveFPRegs);
481
482 // Load suspended function and context.
483 __ movp(rsi, FieldOperand(rbx, JSGeneratorObject::kContextOffset));
484 __ movp(rdi, FieldOperand(rbx, JSGeneratorObject::kFunctionOffset));
485
486 // Flood function if we are stepping.
487 Label skip_flooding;
488 ExternalReference step_in_enabled =
489 ExternalReference::debug_step_in_enabled_address(masm->isolate());
490 Operand step_in_enabled_operand = masm->ExternalOperand(step_in_enabled);
491 __ cmpb(step_in_enabled_operand, Immediate(0));
492 __ j(equal, &skip_flooding);
493 {
494 FrameScope scope(masm, StackFrame::INTERNAL);
495 __ Push(rbx);
496 __ Push(rdx);
497 __ Push(rdi);
498 __ CallRuntime(Runtime::kDebugPrepareStepInIfStepping);
499 __ Pop(rdx);
500 __ Pop(rbx);
501 __ movp(rdi, FieldOperand(rbx, JSGeneratorObject::kFunctionOffset));
502 }
503 __ bind(&skip_flooding);
504
505 // Pop return address.
506 __ PopReturnAddressTo(rax);
507
508 // Push receiver.
509 __ Push(FieldOperand(rbx, JSGeneratorObject::kReceiverOffset));
510
511 // ----------- S t a t e -------------
512 // -- rax : return address
513 // -- rbx : the JSGeneratorObject to resume
514 // -- rdx : the resume mode (tagged)
515 // -- rdi : generator function
516 // -- rsi : generator context
517 // -- rsp[0] : generator receiver
518 // -----------------------------------
519
520 // Push holes for arguments to generator function. Since the parser forced
521 // context allocation for any variables in generators, the actual argument
522 // values have already been copied into the context and these dummy values
523 // will never be used.
524 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
525 __ LoadSharedFunctionInfoSpecialField(
526 rcx, rcx, SharedFunctionInfo::kFormalParameterCountOffset);
527 {
528 Label done_loop, loop;
529 __ bind(&loop);
530 __ subl(rcx, Immediate(1));
531 __ j(carry, &done_loop, Label::kNear);
532 __ PushRoot(Heap::kTheHoleValueRootIndex);
533 __ jmp(&loop);
534 __ bind(&done_loop);
535 }
536
537 // Enter a new JavaScript frame, and initialize its slots as they were when
538 // the generator was suspended.
539 FrameScope scope(masm, StackFrame::MANUAL);
540 __ PushReturnAddressFrom(rax); // Return address.
541 __ Push(rbp); // Caller's frame pointer.
542 __ Move(rbp, rsp);
543 __ Push(rsi); // Callee's context.
544 __ Push(rdi); // Callee's JS Function.
545
546 // Restore the operand stack.
547 __ movp(rsi, FieldOperand(rbx, JSGeneratorObject::kOperandStackOffset));
548 __ SmiToInteger32(rax, FieldOperand(rsi, FixedArray::kLengthOffset));
549 {
550 Label done_loop, loop;
551 __ Set(rcx, 0);
552 __ bind(&loop);
553 __ cmpl(rcx, rax);
554 __ j(equal, &done_loop, Label::kNear);
555 __ Push(
556 FieldOperand(rsi, rcx, times_pointer_size, FixedArray::kHeaderSize));
557 __ addl(rcx, Immediate(1));
558 __ jmp(&loop);
559 __ bind(&done_loop);
560 }
561
562 // Push resume mode (consumed in continuation).
563 __ Push(rdx);
564
565 // Reset operand stack so we don't leak.
566 __ LoadRoot(FieldOperand(rbx, JSGeneratorObject::kOperandStackOffset),
567 Heap::kEmptyFixedArrayRootIndex);
568
569 // Restore context and value.
570 __ movp(rsi, FieldOperand(rbx, JSGeneratorObject::kContextOffset));
571 __ movp(rax, FieldOperand(rbx, JSGeneratorObject::kInputOffset));
572
573 // Resume the generator function at the continuation.
574 __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
575 __ movp(rdx, FieldOperand(rdx, SharedFunctionInfo::kCodeOffset));
576 __ SmiToInteger64(rcx,
577 FieldOperand(rbx, JSGeneratorObject::kContinuationOffset));
578 __ leap(rdx, FieldOperand(rdx, rcx, times_1, Code::kHeaderSize));
579 __ Move(FieldOperand(rbx, JSGeneratorObject::kContinuationOffset),
580 Smi::FromInt(JSGeneratorObject::kGeneratorExecuting));
581 __ jmp(rdx);
582 }
467 583
468 // Generate code for entering a JS function with the interpreter. 584 // Generate code for entering a JS function with the interpreter.
469 // On entry to the function the receiver and arguments have been pushed on the 585 // On entry to the function the receiver and arguments have been pushed on the
470 // stack left to right. The actual argument count matches the formal parameter 586 // stack left to right. The actual argument count matches the formal parameter
471 // count expected by the function. 587 // count expected by the function.
472 // 588 //
473 // The live registers are: 589 // The live registers are:
474 // o rdi: the JS function object being called 590 // o rdi: the JS function object being called
475 // o rdx: the new target 591 // o rdx: the new target
476 // o rsi: our context 592 // o rsi: our context
(...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after
2675 __ ret(0); 2791 __ ret(0);
2676 } 2792 }
2677 2793
2678 2794
2679 #undef __ 2795 #undef __
2680 2796
2681 } // namespace internal 2797 } // namespace internal
2682 } // namespace v8 2798 } // namespace v8
2683 2799
2684 #endif // V8_TARGET_ARCH_X64 2800 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698