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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 { | 507 { |
508 Label done_loop, loop; | 508 Label done_loop, loop; |
509 __ bind(&loop); | 509 __ bind(&loop); |
510 __ subl(rcx, Immediate(1)); | 510 __ subl(rcx, Immediate(1)); |
511 __ j(carry, &done_loop, Label::kNear); | 511 __ j(carry, &done_loop, Label::kNear); |
512 __ PushRoot(Heap::kTheHoleValueRootIndex); | 512 __ PushRoot(Heap::kTheHoleValueRootIndex); |
513 __ jmp(&loop); | 513 __ jmp(&loop); |
514 __ bind(&done_loop); | 514 __ bind(&done_loop); |
515 } | 515 } |
516 | 516 |
517 // Dispatch on the kind of generator object. | 517 // Underlying function needs to have bytecode available. |
518 Label old_generator; | 518 if (FLAG_debug_code) { |
519 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 519 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
520 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kFunctionDataOffset)); | 520 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kFunctionDataOffset)); |
521 __ CmpObjectType(rcx, BYTECODE_ARRAY_TYPE, rcx); | 521 __ CmpObjectType(rcx, BYTECODE_ARRAY_TYPE, rcx); |
522 __ j(not_equal, &old_generator); | 522 __ Assert(equal, kMissingBytecodeArray); |
| 523 } |
523 | 524 |
524 // New-style (ignition/turbofan) generator object. | 525 // Resume (Ignition/TurboFan) generator object. |
525 { | 526 { |
526 __ PushReturnAddressFrom(rax); | 527 __ PushReturnAddressFrom(rax); |
527 __ movp(rax, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 528 __ movp(rax, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
528 __ LoadSharedFunctionInfoSpecialField( | 529 __ LoadSharedFunctionInfoSpecialField( |
529 rax, rax, SharedFunctionInfo::kFormalParameterCountOffset); | 530 rax, rax, SharedFunctionInfo::kFormalParameterCountOffset); |
530 // We abuse new.target both to indicate that this is a resume call and to | 531 // We abuse new.target both to indicate that this is a resume call and to |
531 // pass in the generator object. In ordinary calls, new.target is always | 532 // pass in the generator object. In ordinary calls, new.target is always |
532 // undefined because generator functions are non-constructable. | 533 // undefined because generator functions are non-constructable. |
533 __ movp(rdx, rbx); | 534 __ movp(rdx, rbx); |
534 __ jmp(FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 535 __ jmp(FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
535 } | 536 } |
536 | 537 |
537 // Old-style (full-codegen) generator object. | |
538 __ bind(&old_generator); | |
539 { | |
540 // Enter a new JavaScript frame, and initialize its slots as they were when | |
541 // the generator was suspended. | |
542 FrameScope scope(masm, StackFrame::MANUAL); | |
543 __ PushReturnAddressFrom(rax); // Return address. | |
544 __ Push(rbp); // Caller's frame pointer. | |
545 __ Move(rbp, rsp); | |
546 __ Push(rsi); // Callee's context. | |
547 __ Push(rdi); // Callee's JS Function. | |
548 | |
549 // Restore the operand stack. | |
550 __ movp(rsi, FieldOperand(rbx, JSGeneratorObject::kOperandStackOffset)); | |
551 __ SmiToInteger32(rax, FieldOperand(rsi, FixedArray::kLengthOffset)); | |
552 { | |
553 Label done_loop, loop; | |
554 __ Set(rcx, 0); | |
555 __ bind(&loop); | |
556 __ cmpl(rcx, rax); | |
557 __ j(equal, &done_loop, Label::kNear); | |
558 __ Push( | |
559 FieldOperand(rsi, rcx, times_pointer_size, FixedArray::kHeaderSize)); | |
560 __ addl(rcx, Immediate(1)); | |
561 __ jmp(&loop); | |
562 __ bind(&done_loop); | |
563 } | |
564 | |
565 // Reset operand stack so we don't leak. | |
566 __ LoadRoot(FieldOperand(rbx, JSGeneratorObject::kOperandStackOffset), | |
567 Heap::kEmptyFixedArrayRootIndex); | |
568 | |
569 // Restore context. | |
570 __ movp(rsi, FieldOperand(rbx, JSGeneratorObject::kContextOffset)); | |
571 | |
572 // Resume the generator function at the continuation. | |
573 __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | |
574 __ movp(rdx, FieldOperand(rdx, SharedFunctionInfo::kCodeOffset)); | |
575 __ SmiToInteger64( | |
576 rcx, FieldOperand(rbx, JSGeneratorObject::kContinuationOffset)); | |
577 __ leap(rdx, FieldOperand(rdx, rcx, times_1, Code::kHeaderSize)); | |
578 __ Move(FieldOperand(rbx, JSGeneratorObject::kContinuationOffset), | |
579 Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)); | |
580 __ movp(rax, rbx); // Continuation expects generator object in rax. | |
581 __ jmp(rdx); | |
582 } | |
583 | |
584 __ bind(&prepare_step_in_if_stepping); | 538 __ bind(&prepare_step_in_if_stepping); |
585 { | 539 { |
586 FrameScope scope(masm, StackFrame::INTERNAL); | 540 FrameScope scope(masm, StackFrame::INTERNAL); |
587 __ Push(rbx); | 541 __ Push(rbx); |
588 __ Push(rdx); | 542 __ Push(rdx); |
589 __ Push(rdi); | 543 __ Push(rdi); |
590 __ CallRuntime(Runtime::kDebugPrepareStepInIfStepping); | 544 __ CallRuntime(Runtime::kDebugPrepareStepInIfStepping); |
591 __ Pop(rdx); | 545 __ Pop(rdx); |
592 __ Pop(rbx); | 546 __ Pop(rbx); |
593 __ movp(rdi, FieldOperand(rbx, JSGeneratorObject::kFunctionOffset)); | 547 __ movp(rdi, FieldOperand(rbx, JSGeneratorObject::kFunctionOffset)); |
(...skipping 2507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3101 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3055 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
3102 Generate_OnStackReplacementHelper(masm, true); | 3056 Generate_OnStackReplacementHelper(masm, true); |
3103 } | 3057 } |
3104 | 3058 |
3105 #undef __ | 3059 #undef __ |
3106 | 3060 |
3107 } // namespace internal | 3061 } // namespace internal |
3108 } // namespace v8 | 3062 } // namespace v8 |
3109 | 3063 |
3110 #endif // V8_TARGET_ARCH_X64 | 3064 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |