OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 } | 554 } |
555 | 555 |
556 | 556 |
557 MemOperand LCodeGen::ToHighMemOperand(LOperand* op) const { | 557 MemOperand LCodeGen::ToHighMemOperand(LOperand* op) const { |
558 ASSERT(op->IsDoubleStackSlot()); | 558 ASSERT(op->IsDoubleStackSlot()); |
559 return MemOperand(fp, StackSlotOffset(op->index()) + kPointerSize); | 559 return MemOperand(fp, StackSlotOffset(op->index()) + kPointerSize); |
560 } | 560 } |
561 | 561 |
562 | 562 |
563 void LCodeGen::WriteTranslation(LEnvironment* environment, | 563 void LCodeGen::WriteTranslation(LEnvironment* environment, |
564 Translation* translation) { | 564 Translation* translation, |
| 565 int* pushed_arguments_index, |
| 566 int* pushed_arguments_count) { |
565 if (environment == NULL) return; | 567 if (environment == NULL) return; |
566 | 568 |
567 // The translation includes one command per value in the environment. | 569 // The translation includes one command per value in the environment. |
568 int translation_size = environment->translation_size(); | 570 int translation_size = environment->values()->length(); |
569 // The output frame height does not include the parameters. | 571 // The output frame height does not include the parameters. |
570 int height = translation_size - environment->parameter_count(); | 572 int height = translation_size - environment->parameter_count(); |
571 | 573 |
572 WriteTranslation(environment->outer(), translation); | 574 // Function parameters are arguments to the outermost environment. The |
| 575 // arguments index points to the first element of a sequence of tagged |
| 576 // values on the stack that represent the arguments. This needs to be |
| 577 // kept in sync with the LArgumentsElements implementation. |
| 578 *pushed_arguments_index = -environment->parameter_count(); |
| 579 *pushed_arguments_count = environment->parameter_count(); |
| 580 |
| 581 WriteTranslation(environment->outer(), |
| 582 translation, |
| 583 pushed_arguments_index, |
| 584 pushed_arguments_count); |
573 bool has_closure_id = !info()->closure().is_null() && | 585 bool has_closure_id = !info()->closure().is_null() && |
574 !info()->closure().is_identical_to(environment->closure()); | 586 !info()->closure().is_identical_to(environment->closure()); |
575 int closure_id = has_closure_id | 587 int closure_id = has_closure_id |
576 ? DefineDeoptimizationLiteral(environment->closure()) | 588 ? DefineDeoptimizationLiteral(environment->closure()) |
577 : Translation::kSelfLiteralId; | 589 : Translation::kSelfLiteralId; |
578 | 590 |
579 switch (environment->frame_type()) { | 591 switch (environment->frame_type()) { |
580 case JS_FUNCTION: | 592 case JS_FUNCTION: |
581 translation->BeginJSFrame(environment->ast_id(), closure_id, height); | 593 translation->BeginJSFrame(environment->ast_id(), closure_id, height); |
582 break; | 594 break; |
(...skipping 11 matching lines...) Expand all Loading... |
594 translation->BeginSetterStubFrame(closure_id); | 606 translation->BeginSetterStubFrame(closure_id); |
595 break; | 607 break; |
596 case STUB: | 608 case STUB: |
597 translation->BeginCompiledStubFrame(); | 609 translation->BeginCompiledStubFrame(); |
598 break; | 610 break; |
599 case ARGUMENTS_ADAPTOR: | 611 case ARGUMENTS_ADAPTOR: |
600 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); | 612 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); |
601 break; | 613 break; |
602 } | 614 } |
603 | 615 |
| 616 // Inlined frames which push their arguments cause the index to be |
| 617 // bumped and another stack area to be used for materialization, |
| 618 // otherwise actual argument values are unknown for inlined frames. |
| 619 bool arguments_known = true; |
| 620 int arguments_index = *pushed_arguments_index; |
| 621 int arguments_count = *pushed_arguments_count; |
| 622 if (environment->entry() != NULL) { |
| 623 arguments_known = environment->entry()->arguments_pushed(); |
| 624 arguments_index = arguments_index < 0 |
| 625 ? GetStackSlotCount() : arguments_index + arguments_count; |
| 626 arguments_count = environment->entry()->arguments_count() + 1; |
| 627 if (environment->entry()->arguments_pushed()) { |
| 628 *pushed_arguments_index = arguments_index; |
| 629 *pushed_arguments_count = arguments_count; |
| 630 } |
| 631 } |
| 632 |
604 for (int i = 0; i < translation_size; ++i) { | 633 for (int i = 0; i < translation_size; ++i) { |
605 LOperand* value = environment->values()->at(i); | 634 LOperand* value = environment->values()->at(i); |
606 // spilled_registers_ and spilled_double_registers_ are either | 635 // spilled_registers_ and spilled_double_registers_ are either |
607 // both NULL or both set. | 636 // both NULL or both set. |
608 if (environment->spilled_registers() != NULL && value != NULL) { | 637 if (environment->spilled_registers() != NULL && value != NULL) { |
609 if (value->IsRegister() && | 638 if (value->IsRegister() && |
610 environment->spilled_registers()[value->index()] != NULL) { | 639 environment->spilled_registers()[value->index()] != NULL) { |
611 translation->MarkDuplicate(); | 640 translation->MarkDuplicate(); |
612 AddToTranslation(translation, | 641 AddToTranslation(translation, |
613 environment->spilled_registers()[value->index()], | 642 environment->spilled_registers()[value->index()], |
614 environment->HasTaggedValueAt(i), | 643 environment->HasTaggedValueAt(i), |
615 environment->HasUint32ValueAt(i)); | 644 environment->HasUint32ValueAt(i), |
| 645 arguments_known, |
| 646 arguments_index, |
| 647 arguments_count); |
616 } else if ( | 648 } else if ( |
617 value->IsDoubleRegister() && | 649 value->IsDoubleRegister() && |
618 environment->spilled_double_registers()[value->index()] != NULL) { | 650 environment->spilled_double_registers()[value->index()] != NULL) { |
619 translation->MarkDuplicate(); | 651 translation->MarkDuplicate(); |
620 AddToTranslation( | 652 AddToTranslation( |
621 translation, | 653 translation, |
622 environment->spilled_double_registers()[value->index()], | 654 environment->spilled_double_registers()[value->index()], |
623 false, | 655 false, |
624 false); | 656 false, |
| 657 arguments_known, |
| 658 arguments_index, |
| 659 arguments_count); |
625 } | 660 } |
626 } | 661 } |
627 | 662 |
628 // TODO(mstarzinger): Introduce marker operands to indicate that this value | |
629 // is not present and must be reconstructed from the deoptimizer. Currently | |
630 // this is only used for the arguments object. | |
631 if (value == NULL) { | |
632 int arguments_count = environment->values()->length() - translation_size; | |
633 translation->BeginArgumentsObject(arguments_count); | |
634 for (int i = 0; i < arguments_count; ++i) { | |
635 LOperand* value = environment->values()->at(translation_size + i); | |
636 ASSERT(environment->spilled_registers() == NULL || | |
637 !value->IsRegister() || | |
638 environment->spilled_registers()[value->index()] == NULL); | |
639 ASSERT(environment->spilled_registers() == NULL || | |
640 !value->IsDoubleRegister() || | |
641 environment->spilled_double_registers()[value->index()] == NULL); | |
642 AddToTranslation(translation, | |
643 value, | |
644 environment->HasTaggedValueAt(translation_size + i), | |
645 environment->HasUint32ValueAt(translation_size + i)); | |
646 } | |
647 continue; | |
648 } | |
649 | |
650 AddToTranslation(translation, | 663 AddToTranslation(translation, |
651 value, | 664 value, |
652 environment->HasTaggedValueAt(i), | 665 environment->HasTaggedValueAt(i), |
653 environment->HasUint32ValueAt(i)); | 666 environment->HasUint32ValueAt(i), |
| 667 arguments_known, |
| 668 arguments_index, |
| 669 arguments_count); |
654 } | 670 } |
655 } | 671 } |
656 | 672 |
657 | 673 |
658 void LCodeGen::AddToTranslation(Translation* translation, | 674 void LCodeGen::AddToTranslation(Translation* translation, |
659 LOperand* op, | 675 LOperand* op, |
660 bool is_tagged, | 676 bool is_tagged, |
661 bool is_uint32) { | 677 bool is_uint32, |
662 if (op->IsStackSlot()) { | 678 bool arguments_known, |
| 679 int arguments_index, |
| 680 int arguments_count) { |
| 681 if (op == NULL) { |
| 682 // TODO(twuerthinger): Introduce marker operands to indicate that this value |
| 683 // is not present and must be reconstructed from the deoptimizer. Currently |
| 684 // this is only used for the arguments object. |
| 685 translation->StoreArgumentsObject( |
| 686 arguments_known, arguments_index, arguments_count); |
| 687 } else if (op->IsStackSlot()) { |
663 if (is_tagged) { | 688 if (is_tagged) { |
664 translation->StoreStackSlot(op->index()); | 689 translation->StoreStackSlot(op->index()); |
665 } else if (is_uint32) { | 690 } else if (is_uint32) { |
666 translation->StoreUint32StackSlot(op->index()); | 691 translation->StoreUint32StackSlot(op->index()); |
667 } else { | 692 } else { |
668 translation->StoreInt32StackSlot(op->index()); | 693 translation->StoreInt32StackSlot(op->index()); |
669 } | 694 } |
670 } else if (op->IsDoubleStackSlot()) { | 695 } else if (op->IsDoubleStackSlot()) { |
671 translation->StoreDoubleStackSlot(op->index()); | 696 translation->StoreDoubleStackSlot(op->index()); |
672 } else if (op->IsArgument()) { | 697 } else if (op->IsArgument()) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 // 0 ..................................................... size-1 | 772 // 0 ..................................................... size-1 |
748 // [parameters] [locals] [expression stack including arguments] | 773 // [parameters] [locals] [expression stack including arguments] |
749 | 774 |
750 // Layout of the translation: | 775 // Layout of the translation: |
751 // 0 ........................................................ size - 1 + 4 | 776 // 0 ........................................................ size - 1 + 4 |
752 // [expression stack including arguments] [locals] [4 words] [parameters] | 777 // [expression stack including arguments] [locals] [4 words] [parameters] |
753 // |>------------ translation_size ------------<| | 778 // |>------------ translation_size ------------<| |
754 | 779 |
755 int frame_count = 0; | 780 int frame_count = 0; |
756 int jsframe_count = 0; | 781 int jsframe_count = 0; |
| 782 int args_index = 0; |
| 783 int args_count = 0; |
757 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { | 784 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { |
758 ++frame_count; | 785 ++frame_count; |
759 if (e->frame_type() == JS_FUNCTION) { | 786 if (e->frame_type() == JS_FUNCTION) { |
760 ++jsframe_count; | 787 ++jsframe_count; |
761 } | 788 } |
762 } | 789 } |
763 Translation translation(&translations_, frame_count, jsframe_count, zone()); | 790 Translation translation(&translations_, frame_count, jsframe_count, zone()); |
764 WriteTranslation(environment, &translation); | 791 WriteTranslation(environment, &translation, &args_index, &args_count); |
765 int deoptimization_index = deoptimizations_.length(); | 792 int deoptimization_index = deoptimizations_.length(); |
766 int pc_offset = masm()->pc_offset(); | 793 int pc_offset = masm()->pc_offset(); |
767 environment->Register(deoptimization_index, | 794 environment->Register(deoptimization_index, |
768 translation.index(), | 795 translation.index(), |
769 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); | 796 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); |
770 deoptimizations_.Add(environment, zone()); | 797 deoptimizations_.Add(environment, zone()); |
771 } | 798 } |
772 } | 799 } |
773 | 800 |
774 | 801 |
(...skipping 4906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5681 __ Subu(scratch, result, scratch); | 5708 __ Subu(scratch, result, scratch); |
5682 __ lw(result, FieldMemOperand(scratch, | 5709 __ lw(result, FieldMemOperand(scratch, |
5683 FixedArray::kHeaderSize - kPointerSize)); | 5710 FixedArray::kHeaderSize - kPointerSize)); |
5684 __ bind(&done); | 5711 __ bind(&done); |
5685 } | 5712 } |
5686 | 5713 |
5687 | 5714 |
5688 #undef __ | 5715 #undef __ |
5689 | 5716 |
5690 } } // namespace v8::internal | 5717 } } // namespace v8::internal |
OLD | NEW |