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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 } | 586 } |
587 | 587 |
588 | 588 |
589 MemOperand LCodeGen::ToHighMemOperand(LOperand* op) const { | 589 MemOperand LCodeGen::ToHighMemOperand(LOperand* op) const { |
590 ASSERT(op->IsDoubleStackSlot()); | 590 ASSERT(op->IsDoubleStackSlot()); |
591 return MemOperand(fp, StackSlotOffset(op->index()) + kPointerSize); | 591 return MemOperand(fp, StackSlotOffset(op->index()) + kPointerSize); |
592 } | 592 } |
593 | 593 |
594 | 594 |
595 void LCodeGen::WriteTranslation(LEnvironment* environment, | 595 void LCodeGen::WriteTranslation(LEnvironment* environment, |
596 Translation* translation, | 596 Translation* translation) { |
597 int* pushed_arguments_index, | |
598 int* pushed_arguments_count) { | |
599 if (environment == NULL) return; | 597 if (environment == NULL) return; |
600 | 598 |
601 // The translation includes one command per value in the environment. | 599 // The translation includes one command per value in the environment. |
602 int translation_size = environment->values()->length(); | 600 int translation_size = environment->translation_size(); |
603 // The output frame height does not include the parameters. | 601 // The output frame height does not include the parameters. |
604 int height = translation_size - environment->parameter_count(); | 602 int height = translation_size - environment->parameter_count(); |
605 | 603 |
606 // Function parameters are arguments to the outermost environment. The | 604 WriteTranslation(environment->outer(), translation); |
607 // arguments index points to the first element of a sequence of tagged | |
608 // values on the stack that represent the arguments. This needs to be | |
609 // kept in sync with the LArgumentsElements implementation. | |
610 *pushed_arguments_index = -environment->parameter_count(); | |
611 *pushed_arguments_count = environment->parameter_count(); | |
612 | |
613 WriteTranslation(environment->outer(), | |
614 translation, | |
615 pushed_arguments_index, | |
616 pushed_arguments_count); | |
617 bool has_closure_id = !info()->closure().is_null() && | 605 bool has_closure_id = !info()->closure().is_null() && |
618 !info()->closure().is_identical_to(environment->closure()); | 606 !info()->closure().is_identical_to(environment->closure()); |
619 int closure_id = has_closure_id | 607 int closure_id = has_closure_id |
620 ? DefineDeoptimizationLiteral(environment->closure()) | 608 ? DefineDeoptimizationLiteral(environment->closure()) |
621 : Translation::kSelfLiteralId; | 609 : Translation::kSelfLiteralId; |
622 | 610 |
623 switch (environment->frame_type()) { | 611 switch (environment->frame_type()) { |
624 case JS_FUNCTION: | 612 case JS_FUNCTION: |
625 translation->BeginJSFrame(environment->ast_id(), closure_id, height); | 613 translation->BeginJSFrame(environment->ast_id(), closure_id, height); |
626 break; | 614 break; |
(...skipping 11 matching lines...) Expand all Loading... |
638 translation->BeginSetterStubFrame(closure_id); | 626 translation->BeginSetterStubFrame(closure_id); |
639 break; | 627 break; |
640 case STUB: | 628 case STUB: |
641 translation->BeginCompiledStubFrame(); | 629 translation->BeginCompiledStubFrame(); |
642 break; | 630 break; |
643 case ARGUMENTS_ADAPTOR: | 631 case ARGUMENTS_ADAPTOR: |
644 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); | 632 translation->BeginArgumentsAdaptorFrame(closure_id, translation_size); |
645 break; | 633 break; |
646 } | 634 } |
647 | 635 |
648 // Inlined frames which push their arguments cause the index to be | |
649 // bumped and another stack area to be used for materialization, | |
650 // otherwise actual argument values are unknown for inlined frames. | |
651 bool arguments_known = true; | |
652 int arguments_index = *pushed_arguments_index; | |
653 int arguments_count = *pushed_arguments_count; | |
654 if (environment->entry() != NULL) { | |
655 arguments_known = environment->entry()->arguments_pushed(); | |
656 arguments_index = arguments_index < 0 | |
657 ? GetStackSlotCount() : arguments_index + arguments_count; | |
658 arguments_count = environment->entry()->arguments_count() + 1; | |
659 if (environment->entry()->arguments_pushed()) { | |
660 *pushed_arguments_index = arguments_index; | |
661 *pushed_arguments_count = arguments_count; | |
662 } | |
663 } | |
664 | |
665 for (int i = 0; i < translation_size; ++i) { | 636 for (int i = 0; i < translation_size; ++i) { |
666 LOperand* value = environment->values()->at(i); | 637 LOperand* value = environment->values()->at(i); |
667 // spilled_registers_ and spilled_double_registers_ are either | 638 // spilled_registers_ and spilled_double_registers_ are either |
668 // both NULL or both set. | 639 // both NULL or both set. |
669 if (environment->spilled_registers() != NULL && value != NULL) { | 640 if (environment->spilled_registers() != NULL && value != NULL) { |
670 if (value->IsRegister() && | 641 if (value->IsRegister() && |
671 environment->spilled_registers()[value->index()] != NULL) { | 642 environment->spilled_registers()[value->index()] != NULL) { |
672 translation->MarkDuplicate(); | 643 translation->MarkDuplicate(); |
673 AddToTranslation(translation, | 644 AddToTranslation(translation, |
674 environment->spilled_registers()[value->index()], | 645 environment->spilled_registers()[value->index()], |
675 environment->HasTaggedValueAt(i), | 646 environment->HasTaggedValueAt(i), |
676 environment->HasUint32ValueAt(i), | 647 environment->HasUint32ValueAt(i)); |
677 arguments_known, | |
678 arguments_index, | |
679 arguments_count); | |
680 } else if ( | 648 } else if ( |
681 value->IsDoubleRegister() && | 649 value->IsDoubleRegister() && |
682 environment->spilled_double_registers()[value->index()] != NULL) { | 650 environment->spilled_double_registers()[value->index()] != NULL) { |
683 translation->MarkDuplicate(); | 651 translation->MarkDuplicate(); |
684 AddToTranslation( | 652 AddToTranslation( |
685 translation, | 653 translation, |
686 environment->spilled_double_registers()[value->index()], | 654 environment->spilled_double_registers()[value->index()], |
687 false, | 655 false, |
688 false, | 656 false); |
689 arguments_known, | |
690 arguments_index, | |
691 arguments_count); | |
692 } | 657 } |
693 } | 658 } |
694 | 659 |
| 660 // TODO(mstarzinger): Introduce marker operands to indicate that this value |
| 661 // is not present and must be reconstructed from the deoptimizer. Currently |
| 662 // this is only used for the arguments object. |
| 663 if (value == NULL) { |
| 664 int arguments_count = environment->values()->length() - translation_size; |
| 665 translation->BeginArgumentsObject(arguments_count); |
| 666 for (int i = 0; i < arguments_count; ++i) { |
| 667 LOperand* value = environment->values()->at(translation_size + i); |
| 668 ASSERT(environment->spilled_registers() == NULL || |
| 669 !value->IsRegister() || |
| 670 environment->spilled_registers()[value->index()] == NULL); |
| 671 ASSERT(environment->spilled_registers() == NULL || |
| 672 !value->IsDoubleRegister() || |
| 673 environment->spilled_double_registers()[value->index()] == NULL); |
| 674 AddToTranslation(translation, |
| 675 value, |
| 676 environment->HasTaggedValueAt(translation_size + i), |
| 677 environment->HasUint32ValueAt(translation_size + i)); |
| 678 } |
| 679 continue; |
| 680 } |
| 681 |
695 AddToTranslation(translation, | 682 AddToTranslation(translation, |
696 value, | 683 value, |
697 environment->HasTaggedValueAt(i), | 684 environment->HasTaggedValueAt(i), |
698 environment->HasUint32ValueAt(i), | 685 environment->HasUint32ValueAt(i)); |
699 arguments_known, | |
700 arguments_index, | |
701 arguments_count); | |
702 } | 686 } |
703 } | 687 } |
704 | 688 |
705 | 689 |
706 void LCodeGen::AddToTranslation(Translation* translation, | 690 void LCodeGen::AddToTranslation(Translation* translation, |
707 LOperand* op, | 691 LOperand* op, |
708 bool is_tagged, | 692 bool is_tagged, |
709 bool is_uint32, | 693 bool is_uint32) { |
710 bool arguments_known, | 694 if (op->IsStackSlot()) { |
711 int arguments_index, | |
712 int arguments_count) { | |
713 if (op == NULL) { | |
714 // TODO(twuerthinger): Introduce marker operands to indicate that this value | |
715 // is not present and must be reconstructed from the deoptimizer. Currently | |
716 // this is only used for the arguments object. | |
717 translation->StoreArgumentsObject( | |
718 arguments_known, arguments_index, arguments_count); | |
719 } else if (op->IsStackSlot()) { | |
720 if (is_tagged) { | 695 if (is_tagged) { |
721 translation->StoreStackSlot(op->index()); | 696 translation->StoreStackSlot(op->index()); |
722 } else if (is_uint32) { | 697 } else if (is_uint32) { |
723 translation->StoreUint32StackSlot(op->index()); | 698 translation->StoreUint32StackSlot(op->index()); |
724 } else { | 699 } else { |
725 translation->StoreInt32StackSlot(op->index()); | 700 translation->StoreInt32StackSlot(op->index()); |
726 } | 701 } |
727 } else if (op->IsDoubleStackSlot()) { | 702 } else if (op->IsDoubleStackSlot()) { |
728 translation->StoreDoubleStackSlot(op->index()); | 703 translation->StoreDoubleStackSlot(op->index()); |
729 } else if (op->IsArgument()) { | 704 } else if (op->IsArgument()) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 // 0 ..................................................... size-1 | 791 // 0 ..................................................... size-1 |
817 // [parameters] [locals] [expression stack including arguments] | 792 // [parameters] [locals] [expression stack including arguments] |
818 | 793 |
819 // Layout of the translation: | 794 // Layout of the translation: |
820 // 0 ........................................................ size - 1 + 4 | 795 // 0 ........................................................ size - 1 + 4 |
821 // [expression stack including arguments] [locals] [4 words] [parameters] | 796 // [expression stack including arguments] [locals] [4 words] [parameters] |
822 // |>------------ translation_size ------------<| | 797 // |>------------ translation_size ------------<| |
823 | 798 |
824 int frame_count = 0; | 799 int frame_count = 0; |
825 int jsframe_count = 0; | 800 int jsframe_count = 0; |
826 int args_index = 0; | |
827 int args_count = 0; | |
828 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { | 801 for (LEnvironment* e = environment; e != NULL; e = e->outer()) { |
829 ++frame_count; | 802 ++frame_count; |
830 if (e->frame_type() == JS_FUNCTION) { | 803 if (e->frame_type() == JS_FUNCTION) { |
831 ++jsframe_count; | 804 ++jsframe_count; |
832 } | 805 } |
833 } | 806 } |
834 Translation translation(&translations_, frame_count, jsframe_count, zone()); | 807 Translation translation(&translations_, frame_count, jsframe_count, zone()); |
835 WriteTranslation(environment, &translation, &args_index, &args_count); | 808 WriteTranslation(environment, &translation); |
836 int deoptimization_index = deoptimizations_.length(); | 809 int deoptimization_index = deoptimizations_.length(); |
837 int pc_offset = masm()->pc_offset(); | 810 int pc_offset = masm()->pc_offset(); |
838 environment->Register(deoptimization_index, | 811 environment->Register(deoptimization_index, |
839 translation.index(), | 812 translation.index(), |
840 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); | 813 (mode == Safepoint::kLazyDeopt) ? pc_offset : -1); |
841 deoptimizations_.Add(environment, zone()); | 814 deoptimizations_.Add(environment, zone()); |
842 } | 815 } |
843 } | 816 } |
844 | 817 |
845 | 818 |
(...skipping 5065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5911 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); | 5884 __ sub(scratch, result, Operand::PointerOffsetFromSmiKey(index)); |
5912 __ ldr(result, FieldMemOperand(scratch, | 5885 __ ldr(result, FieldMemOperand(scratch, |
5913 FixedArray::kHeaderSize - kPointerSize)); | 5886 FixedArray::kHeaderSize - kPointerSize)); |
5914 __ bind(&done); | 5887 __ bind(&done); |
5915 } | 5888 } |
5916 | 5889 |
5917 | 5890 |
5918 #undef __ | 5891 #undef __ |
5919 | 5892 |
5920 } } // namespace v8::internal | 5893 } } // namespace v8::internal |
OLD | NEW |