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