OLD | NEW |
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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 // -- rdx : the resume mode (tagged) | 472 // -- rdx : the resume mode (tagged) |
473 // -- rsp[0] : return address | 473 // -- rsp[0] : return address |
474 // ----------------------------------- | 474 // ----------------------------------- |
475 __ AssertGeneratorObject(rbx); | 475 __ AssertGeneratorObject(rbx); |
476 | 476 |
477 // Store input value into generator object. | 477 // Store input value into generator object. |
478 __ movp(FieldOperand(rbx, JSGeneratorObject::kInputOffset), rax); | 478 __ movp(FieldOperand(rbx, JSGeneratorObject::kInputOffset), rax); |
479 __ RecordWriteField(rbx, JSGeneratorObject::kInputOffset, rax, rcx, | 479 __ RecordWriteField(rbx, JSGeneratorObject::kInputOffset, rax, rcx, |
480 kDontSaveFPRegs); | 480 kDontSaveFPRegs); |
481 | 481 |
| 482 // Store resume mode into generator object. |
| 483 __ movp(FieldOperand(rbx, JSGeneratorObject::kResumeModeOffset), rdx); |
| 484 |
482 // Load suspended function and context. | 485 // Load suspended function and context. |
483 __ movp(rsi, FieldOperand(rbx, JSGeneratorObject::kContextOffset)); | 486 __ movp(rsi, FieldOperand(rbx, JSGeneratorObject::kContextOffset)); |
484 __ movp(rdi, FieldOperand(rbx, JSGeneratorObject::kFunctionOffset)); | 487 __ movp(rdi, FieldOperand(rbx, JSGeneratorObject::kFunctionOffset)); |
485 | 488 |
486 // Flood function if we are stepping. | 489 // Flood function if we are stepping. |
487 Label skip_flooding; | 490 Label skip_flooding; |
488 ExternalReference step_in_enabled = | 491 ExternalReference step_in_enabled = |
489 ExternalReference::debug_step_in_enabled_address(masm->isolate()); | 492 ExternalReference::debug_step_in_enabled_address(masm->isolate()); |
490 Operand step_in_enabled_operand = masm->ExternalOperand(step_in_enabled); | 493 Operand step_in_enabled_operand = masm->ExternalOperand(step_in_enabled); |
491 __ cmpb(step_in_enabled_operand, Immediate(0)); | 494 __ cmpb(step_in_enabled_operand, Immediate(0)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 __ bind(&loop); | 555 __ bind(&loop); |
553 __ cmpl(rcx, rax); | 556 __ cmpl(rcx, rax); |
554 __ j(equal, &done_loop, Label::kNear); | 557 __ j(equal, &done_loop, Label::kNear); |
555 __ Push( | 558 __ Push( |
556 FieldOperand(rsi, rcx, times_pointer_size, FixedArray::kHeaderSize)); | 559 FieldOperand(rsi, rcx, times_pointer_size, FixedArray::kHeaderSize)); |
557 __ addl(rcx, Immediate(1)); | 560 __ addl(rcx, Immediate(1)); |
558 __ jmp(&loop); | 561 __ jmp(&loop); |
559 __ bind(&done_loop); | 562 __ bind(&done_loop); |
560 } | 563 } |
561 | 564 |
562 // Push resume mode (consumed in continuation). | |
563 __ Push(rdx); | |
564 | |
565 // Reset operand stack so we don't leak. | 565 // Reset operand stack so we don't leak. |
566 __ LoadRoot(FieldOperand(rbx, JSGeneratorObject::kOperandStackOffset), | 566 __ LoadRoot(FieldOperand(rbx, JSGeneratorObject::kOperandStackOffset), |
567 Heap::kEmptyFixedArrayRootIndex); | 567 Heap::kEmptyFixedArrayRootIndex); |
568 | 568 |
569 // Restore context and value. | 569 // Restore context. |
570 __ movp(rsi, FieldOperand(rbx, JSGeneratorObject::kContextOffset)); | 570 __ movp(rsi, FieldOperand(rbx, JSGeneratorObject::kContextOffset)); |
571 __ movp(rax, FieldOperand(rbx, JSGeneratorObject::kInputOffset)); | |
572 | 571 |
573 // Resume the generator function at the continuation. | 572 // Resume the generator function at the continuation. |
574 __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 573 __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
575 __ movp(rdx, FieldOperand(rdx, SharedFunctionInfo::kCodeOffset)); | 574 __ movp(rdx, FieldOperand(rdx, SharedFunctionInfo::kCodeOffset)); |
576 __ SmiToInteger64(rcx, | 575 __ SmiToInteger64(rcx, |
577 FieldOperand(rbx, JSGeneratorObject::kContinuationOffset)); | 576 FieldOperand(rbx, JSGeneratorObject::kContinuationOffset)); |
578 __ leap(rdx, FieldOperand(rdx, rcx, times_1, Code::kHeaderSize)); | 577 __ leap(rdx, FieldOperand(rdx, rcx, times_1, Code::kHeaderSize)); |
579 __ Move(FieldOperand(rbx, JSGeneratorObject::kContinuationOffset), | 578 __ Move(FieldOperand(rbx, JSGeneratorObject::kContinuationOffset), |
580 Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)); | 579 Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)); |
| 580 __ movp(rax, rbx); // Continuation expects generator object in rax. |
581 __ jmp(rdx); | 581 __ jmp(rdx); |
582 } | 582 } |
583 | 583 |
584 // Generate code for entering a JS function with the interpreter. | 584 // Generate code for entering a JS function with the interpreter. |
585 // 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 |
586 // 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 |
587 // count expected by the function. | 587 // count expected by the function. |
588 // | 588 // |
589 // The live registers are: | 589 // The live registers are: |
590 // o rdi: the JS function object being called | 590 // o rdi: the JS function object being called |
(...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2791 __ ret(0); | 2791 __ ret(0); |
2792 } | 2792 } |
2793 | 2793 |
2794 | 2794 |
2795 #undef __ | 2795 #undef __ |
2796 | 2796 |
2797 } // namespace internal | 2797 } // namespace internal |
2798 } // namespace v8 | 2798 } // namespace v8 |
2799 | 2799 |
2800 #endif // V8_TARGET_ARCH_X64 | 2800 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |