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 3748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3759 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); | 3759 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
3760 } | 3760 } |
3761 return; | 3761 return; |
3762 } | 3762 } |
3763 | 3763 |
3764 HAllocate* dominator_allocate_instr = HAllocate::cast(dominator); | 3764 HAllocate* dominator_allocate_instr = HAllocate::cast(dominator); |
3765 HValue* dominator_size = dominator_allocate_instr->size(); | 3765 HValue* dominator_size = dominator_allocate_instr->size(); |
3766 HValue* current_size = size(); | 3766 HValue* current_size = size(); |
3767 // We can just fold allocations that are guaranteed in new space. | 3767 // We can just fold allocations that are guaranteed in new space. |
3768 // TODO(hpayer): Add support for non-constant allocation in dominator. | 3768 // TODO(hpayer): Add support for non-constant allocation in dominator. |
3769 if (!GuaranteedInNewSpace() || !current_size->IsInteger32Constant() || | 3769 if (!IsNewSpaceAllocation() || !current_size->IsInteger32Constant() || |
3770 !dominator_allocate_instr->GuaranteedInNewSpace() || | 3770 !dominator_allocate_instr->IsNewSpaceAllocation() || |
3771 !dominator_size->IsInteger32Constant()) { | 3771 !dominator_size->IsInteger32Constant()) { |
3772 if (FLAG_trace_allocation_folding) { | 3772 if (FLAG_trace_allocation_folding) { |
3773 PrintF("#%d (%s) cannot fold into #%d (%s)\n", | 3773 PrintF("#%d (%s) cannot fold into #%d (%s)\n", |
3774 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); | 3774 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
3775 } | 3775 } |
3776 return; | 3776 return; |
3777 } | 3777 } |
3778 | 3778 |
3779 // First update the size of the dominator allocate instruction. | 3779 // First update the size of the dominator allocate instruction. |
3780 int32_t dominator_size_constant = | 3780 int32_t dominator_size_constant = |
3781 HConstant::cast(dominator_size)->GetInteger32Constant(); | 3781 HConstant::cast(dominator_size)->GetInteger32Constant(); |
3782 int32_t current_size_constant = | 3782 int32_t current_size_constant = |
3783 HConstant::cast(current_size)->GetInteger32Constant(); | 3783 HConstant::cast(current_size)->GetInteger32Constant(); |
3784 int32_t new_dominator_size = dominator_size_constant + current_size_constant; | 3784 int32_t new_dominator_size = dominator_size_constant + current_size_constant; |
3785 | 3785 |
3786 if (MustAllocateDoubleAligned()) { | 3786 if (MustAllocateDoubleAligned()) { |
3787 if (!dominator_allocate_instr->MustAllocateDoubleAligned()) { | 3787 if (!dominator_allocate_instr->MustAllocateDoubleAligned()) { |
3788 dominator_allocate_instr->SetFlags(HAllocate::ALLOCATE_DOUBLE_ALIGNED); | 3788 dominator_allocate_instr->MakeDoubleAligned(); |
3789 } | 3789 } |
3790 if ((dominator_size_constant & kDoubleAlignmentMask) != 0) { | 3790 if ((dominator_size_constant & kDoubleAlignmentMask) != 0) { |
3791 dominator_size_constant += kDoubleSize / 2; | 3791 dominator_size_constant += kDoubleSize / 2; |
3792 new_dominator_size += kDoubleSize / 2; | 3792 new_dominator_size += kDoubleSize / 2; |
3793 } | 3793 } |
3794 } | 3794 } |
3795 | 3795 |
3796 if (new_dominator_size > Page::kMaxNonCodeHeapObjectSize) { | 3796 if (new_dominator_size > Page::kMaxNonCodeHeapObjectSize) { |
3797 if (FLAG_trace_allocation_folding) { | 3797 if (FLAG_trace_allocation_folding) { |
3798 PrintF("#%d (%s) cannot fold into #%d (%s) due to size: %d\n", | 3798 PrintF("#%d (%s) cannot fold into #%d (%s) due to size: %d\n", |
3799 id(), Mnemonic(), dominator->id(), dominator->Mnemonic(), | 3799 id(), Mnemonic(), dominator->id(), dominator->Mnemonic(), |
3800 new_dominator_size); | 3800 new_dominator_size); |
3801 } | 3801 } |
3802 return; | 3802 return; |
3803 } | 3803 } |
3804 HBasicBlock* block = dominator->block(); | 3804 HBasicBlock* block = dominator->block(); |
3805 Zone* zone = block->zone(); | 3805 Zone* zone = block->zone(); |
3806 HInstruction* new_dominator_size_constant = new(zone) HConstant( | 3806 HInstruction* new_dominator_size_constant = new(zone) HConstant( |
3807 new_dominator_size); | 3807 new_dominator_size); |
3808 new_dominator_size_constant->InsertBefore(dominator_allocate_instr); | 3808 new_dominator_size_constant->InsertBefore(dominator_allocate_instr); |
3809 dominator_allocate_instr->UpdateSize(new_dominator_size_constant); | 3809 dominator_allocate_instr->UpdateSize(new_dominator_size_constant); |
3810 | 3810 |
3811 #ifdef VERIFY_HEAP | 3811 #ifdef VERIFY_HEAP |
3812 if (FLAG_verify_heap) { | 3812 if (FLAG_verify_heap) { |
3813 dominator_allocate_instr->SetFlags(HAllocate::PREFILL_WITH_FILLER); | 3813 dominator_allocate_instr->MakePrefillWithFiller(); |
3814 } | 3814 } |
3815 #endif | 3815 #endif |
3816 | 3816 |
3817 // After that replace the dominated allocate instruction. | 3817 // After that replace the dominated allocate instruction. |
3818 HInstruction* dominated_allocate_instr = | 3818 HInstruction* dominated_allocate_instr = |
3819 new(zone) HInnerAllocatedObject(dominator_allocate_instr, | 3819 new(zone) HInnerAllocatedObject(dominator_allocate_instr, |
3820 dominator_size_constant, | 3820 dominator_size_constant, |
3821 type()); | 3821 type()); |
3822 dominated_allocate_instr->InsertBefore(this); | 3822 dominated_allocate_instr->InsertBefore(this); |
3823 DeleteAndReplaceWith(dominated_allocate_instr); | 3823 DeleteAndReplaceWith(dominated_allocate_instr); |
3824 if (FLAG_trace_allocation_folding) { | 3824 if (FLAG_trace_allocation_folding) { |
3825 PrintF("#%d (%s) folded into #%d (%s)\n", | 3825 PrintF("#%d (%s) folded into #%d (%s)\n", |
3826 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); | 3826 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
3827 } | 3827 } |
3828 } | 3828 } |
3829 | 3829 |
3830 | 3830 |
3831 void HAllocate::PrintDataTo(StringStream* stream) { | 3831 void HAllocate::PrintDataTo(StringStream* stream) { |
3832 size()->PrintNameTo(stream); | 3832 size()->PrintNameTo(stream); |
3833 if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)"); | 3833 if (!IsNewSpaceAllocation()) stream->Add(" (pretenure)"); |
3834 } | 3834 } |
3835 | 3835 |
3836 | 3836 |
3837 HType HRegExpLiteral::CalculateInferredType() { | 3837 HType HRegExpLiteral::CalculateInferredType() { |
3838 return HType::JSObject(); | 3838 return HType::JSObject(); |
3839 } | 3839 } |
3840 | 3840 |
3841 | 3841 |
3842 HType HFunctionLiteral::CalculateInferredType() { | 3842 HType HFunctionLiteral::CalculateInferredType() { |
3843 return HType::JSObject(); | 3843 return HType::JSObject(); |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4570 break; | 4570 break; |
4571 case kExternalMemory: | 4571 case kExternalMemory: |
4572 stream->Add("[external-memory]"); | 4572 stream->Add("[external-memory]"); |
4573 break; | 4573 break; |
4574 } | 4574 } |
4575 | 4575 |
4576 stream->Add("@%d", offset()); | 4576 stream->Add("@%d", offset()); |
4577 } | 4577 } |
4578 | 4578 |
4579 } } // namespace v8::internal | 4579 } } // namespace v8::internal |
OLD | NEW |