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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 } | 607 } |
608 | 608 |
609 | 609 |
610 Operand LCodeGen::HighOperand(LOperand* op) { | 610 Operand LCodeGen::HighOperand(LOperand* op) { |
611 ASSERT(op->IsDoubleStackSlot()); | 611 ASSERT(op->IsDoubleStackSlot()); |
612 return Operand(ebp, StackSlotOffset(op->index()) + kPointerSize); | 612 return Operand(ebp, StackSlotOffset(op->index()) + kPointerSize); |
613 } | 613 } |
614 | 614 |
615 | 615 |
616 void LCodeGen::WriteTranslation(LEnvironment* environment, | 616 void LCodeGen::WriteTranslation(LEnvironment* environment, |
617 Translation* translation) { | 617 Translation* translation, |
| 618 int* pushed_arguments_index, |
| 619 int* pushed_arguments_count) { |
618 if (environment == NULL) return; | 620 if (environment == NULL) return; |
619 | 621 |
620 // The translation includes one command per value in the environment. | 622 // The translation includes one command per value in the environment. |
621 int translation_size = environment->translation_size(); | 623 int translation_size = environment->values()->length(); |
622 // The output frame height does not include the parameters. | 624 // The output frame height does not include the parameters. |
623 int height = translation_size - environment->parameter_count(); | 625 int height = translation_size - environment->parameter_count(); |
624 | 626 |
625 WriteTranslation(environment->outer(), translation); | 627 // Function parameters are arguments to the outermost environment. The |
| 628 // arguments index points to the first element of a sequence of tagged |
| 629 // values on the stack that represent the arguments. This needs to be |
| 630 // kept in sync with the LArgumentsElements implementation. |
| 631 *pushed_arguments_index = -environment->parameter_count(); |
| 632 *pushed_arguments_count = environment->parameter_count(); |
| 633 |
| 634 WriteTranslation(environment->outer(), |
| 635 translation, |
| 636 pushed_arguments_index, |
| 637 pushed_arguments_count); |
626 bool has_closure_id = !info()->closure().is_null() && | 638 bool has_closure_id = !info()->closure().is_null() && |
627 !info()->closure().is_identical_to(environment->closure()); | 639 !info()->closure().is_identical_to(environment->closure()); |
628 int closure_id = has_closure_id | 640 int closure_id = has_closure_id |
629 ? DefineDeoptimizationLiteral(environment->closure()) | 641 ? DefineDeoptimizationLiteral(environment->closure()) |
630 : Translation::kSelfLiteralId; | 642 : Translation::kSelfLiteralId; |
631 switch (environment->frame_type()) { | 643 switch (environment->frame_type()) { |
632 case JS_FUNCTION: | 644 case JS_FUNCTION: |
633 translation->BeginJSFrame(environment->ast_id(), closure_id, height); | 645 translation->BeginJSFrame(environment->ast_id(), closure_id, height); |
634 break; | 646 break; |
635 case JS_CONSTRUCT: | 647 case JS_CONSTRUCT: |
(...skipping 12 matching lines...) Expand all Loading... |
648 case ARGUMENTS_ADAPTOR: | 660 case ARGUMENTS_ADAPTOR: |
649 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); | 661 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); |
650 break; | 662 break; |
651 case STUB: | 663 case STUB: |
652 translation->BeginCompiledStubFrame(); | 664 translation->BeginCompiledStubFrame(); |
653 break; | 665 break; |
654 default: | 666 default: |
655 UNREACHABLE(); | 667 UNREACHABLE(); |
656 } | 668 } |
657 | 669 |
| 670 // Inlined frames which push their arguments cause the index to be |
| 671 // bumped and another stack area to be used for materialization, |
| 672 // otherwise actual argument values are unknown for inlined frames. |
| 673 bool arguments_known = true; |
| 674 int arguments_index = *pushed_arguments_index; |
| 675 int arguments_count = *pushed_arguments_count; |
| 676 if (environment->entry() != NULL) { |
| 677 arguments_known = environment->entry()->arguments_pushed(); |
| 678 arguments_index = arguments_index < 0 |
| 679 ? GetStackSlotCount() : arguments_index + arguments_count; |
| 680 arguments_count = environment->entry()->arguments_count() + 1; |
| 681 if (environment->entry()->arguments_pushed()) { |
| 682 *pushed_arguments_index = arguments_index; |
| 683 *pushed_arguments_count = arguments_count; |
| 684 } |
| 685 } |
| 686 |
658 for (int i = 0; i < translation_size; ++i) { | 687 for (int i = 0; i < translation_size; ++i) { |
659 LOperand* value = environment->values()->at(i); | 688 LOperand* value = environment->values()->at(i); |
660 // spilled_registers_ and spilled_double_registers_ are either | 689 // spilled_registers_ and spilled_double_registers_ are either |
661 // both NULL or both set. | 690 // both NULL or both set. |
662 if (environment->spilled_registers() != NULL && value != NULL) { | 691 if (environment->spilled_registers() != NULL && value != NULL) { |
663 if (value->IsRegister() && | 692 if (value->IsRegister() && |
664 environment->spilled_registers()[value->index()] != NULL) { | 693 environment->spilled_registers()[value->index()] != NULL) { |
665 translation->MarkDuplicate(); | 694 translation->MarkDuplicate(); |
666 AddToTranslation(translation, | 695 AddToTranslation(translation, |
667 environment->spilled_registers()[value->index()], | 696 environment->spilled_registers()[value->index()], |
668 environment->HasTaggedValueAt(i), | 697 environment->HasTaggedValueAt(i), |
669 environment->HasUint32ValueAt(i)); | 698 environment->HasUint32ValueAt(i), |
| 699 arguments_known, |
| 700 arguments_index, |
| 701 arguments_count); |
670 } else if ( | 702 } else if ( |
671 value->IsDoubleRegister() && | 703 value->IsDoubleRegister() && |
672 environment->spilled_double_registers()[value->index()] != NULL) { | 704 environment->spilled_double_registers()[value->index()] != NULL) { |
673 translation->MarkDuplicate(); | 705 translation->MarkDuplicate(); |
674 AddToTranslation( | 706 AddToTranslation( |
675 translation, | 707 translation, |
676 environment->spilled_double_registers()[value->index()], | 708 environment->spilled_double_registers()[value->index()], |
677 false, | 709 false, |
678 false); | 710 false, |
| 711 arguments_known, |
| 712 arguments_index, |
| 713 arguments_count); |
679 } | 714 } |
680 } | 715 } |
681 | 716 |
682 // TODO(mstarzinger): 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 if (value == NULL) { | |
686 int arguments_count = environment->values()->length() - translation_size; | |
687 translation->BeginArgumentsObject(arguments_count); | |
688 for (int i = 0; i < arguments_count; ++i) { | |
689 LOperand* value = environment->values()->at(translation_size + i); | |
690 ASSERT(environment->spilled_registers() == NULL || | |
691 !value->IsRegister() || | |
692 environment->spilled_registers()[value->index()] == NULL); | |
693 ASSERT(environment->spilled_registers() == NULL || | |
694 !value->IsDoubleRegister() || | |
695 environment->spilled_double_registers()[value->index()] == NULL); | |
696 AddToTranslation(translation, | |
697 value, | |
698 environment->HasTaggedValueAt(translation_size + i), | |
699 environment->HasUint32ValueAt(translation_size + i)); | |
700 } | |
701 continue; | |
702 } | |
703 | |
704 AddToTranslation(translation, | 717 AddToTranslation(translation, |
705 value, | 718 value, |
706 environment->HasTaggedValueAt(i), | 719 environment->HasTaggedValueAt(i), |
707 environment->HasUint32ValueAt(i)); | 720 environment->HasUint32ValueAt(i), |
| 721 arguments_known, |
| 722 arguments_index, |
| 723 arguments_count); |
708 } | 724 } |
709 } | 725 } |
710 | 726 |
711 | 727 |
712 void LCodeGen::AddToTranslation(Translation* translation, | 728 void LCodeGen::AddToTranslation(Translation* translation, |
713 LOperand* op, | 729 LOperand* op, |
714 bool is_tagged, | 730 bool is_tagged, |
715 bool is_uint32) { | 731 bool is_uint32, |
716 if (op->IsStackSlot()) { | 732 bool arguments_known, |
| 733 int arguments_index, |
| 734 int arguments_count) { |
| 735 if (op == NULL) { |
| 736 // TODO(twuerthinger): Introduce marker operands to indicate that this value |
| 737 // is not present and must be reconstructed from the deoptimizer. Currently |
| 738 // this is only used for the arguments object. |
| 739 translation->StoreArgumentsObject( |
| 740 arguments_known, arguments_index, arguments_count); |
| 741 } else if (op->IsStackSlot()) { |
717 if (is_tagged) { | 742 if (is_tagged) { |
718 translation->StoreStackSlot(op->index()); | 743 translation->StoreStackSlot(op->index()); |
719 } else if (is_uint32) { | 744 } else if (is_uint32) { |
720 translation->StoreUint32StackSlot(op->index()); | 745 translation->StoreUint32StackSlot(op->index()); |
721 } else { | 746 } else { |
722 translation->StoreInt32StackSlot(op->index()); | 747 translation->StoreInt32StackSlot(op->index()); |
723 } | 748 } |
724 } else if (op->IsDoubleStackSlot()) { | 749 } else if (op->IsDoubleStackSlot()) { |
725 translation->StoreDoubleStackSlot(op->index()); | 750 translation->StoreDoubleStackSlot(op->index()); |
726 } else if (op->IsArgument()) { | 751 } else if (op->IsArgument()) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 // 0 ..................................................... size-1 | 857 // 0 ..................................................... size-1 |
833 // [parameters] [locals] [expression stack including arguments] | 858 // [parameters] [locals] [expression stack including arguments] |
834 | 859 |
835 // Layout of the translation: | 860 // Layout of the translation: |
836 // 0 ........................................................ size - 1 + 4 | 861 // 0 ........................................................ size - 1 + 4 |
837 // [expression stack including arguments] [locals] [4 words] [parameters] | 862 // [expression stack including arguments] [locals] [4 words] [parameters] |
838 // |>------------ translation_size ------------<| | 863 // |>------------ translation_size ------------<| |
839 | 864 |
840 int frame_count = 0; | 865 int frame_count = 0; |
841 int jsframe_count = 0; | 866 int jsframe_count = 0; |
| 867 int args_index = 0; |
| 868 int args_count = 0; |
842 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { | 869 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { |
843 ++frame_count; | 870 ++frame_count; |
844 if (e->frame_type() == JS_FUNCTION) { | 871 if (e->frame_type() == JS_FUNCTION) { |
845 ++jsframe_count; | 872 ++jsframe_count; |
846 } | 873 } |
847 } | 874 } |
848 Translation translation(&translations_, frame_count, jsframe_count, zone()); | 875 Translation translation(&translations_, frame_count, jsframe_count, zone()); |
849 WriteTranslation(environment, &translation); | 876 WriteTranslation(environment, &translation, &args_index, &args_count); |
850 int deoptimization_index = deoptimizations_.length(); | 877 int deoptimization_index = deoptimizations_.length(); |
851 int pc_offset = masm()->pc_offset(); | 878 int pc_offset = masm()->pc_offset(); |
852 environment->Register(deoptimization_index, | 879 environment->Register(deoptimization_index, |
853 translation.index(), | 880 translation.index(), |
854 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); | 881 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); |
855 deoptimizations_.Add(environment, zone()); | 882 deoptimizations_.Add(environment, zone()); |
856 } | 883 } |
857 } | 884 } |
858 | 885 |
859 | 886 |
(...skipping 5644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6504 FixedArray::kHeaderSize - kPointerSize)); | 6531 FixedArray::kHeaderSize - kPointerSize)); |
6505 __ bind(&done); | 6532 __ bind(&done); |
6506 } | 6533 } |
6507 | 6534 |
6508 | 6535 |
6509 #undef __ | 6536 #undef __ |
6510 | 6537 |
6511 } } // namespace v8::internal | 6538 } } // namespace v8::internal |
6512 | 6539 |
6513 #endif // V8_TARGET_ARCH_IA32 | 6540 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |