| 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 3192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3203 PrintF("#%d (%s) cannot fold into #%d (%s)\n", | 3203 PrintF("#%d (%s) cannot fold into #%d (%s)\n", |
| 3204 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); | 3204 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
| 3205 } | 3205 } |
| 3206 return; | 3206 return; |
| 3207 } | 3207 } |
| 3208 | 3208 |
| 3209 HAllocate* dominator_allocate_instr = HAllocate::cast(dominator); | 3209 HAllocate* dominator_allocate_instr = HAllocate::cast(dominator); |
| 3210 HValue* dominator_size = dominator_allocate_instr->size(); | 3210 HValue* dominator_size = dominator_allocate_instr->size(); |
| 3211 HValue* current_size = size(); | 3211 HValue* current_size = size(); |
| 3212 // We can just fold allocations that are guaranteed in new space. | 3212 // We can just fold allocations that are guaranteed in new space. |
| 3213 // TODO(hpayer): Support double aligned allocations. | |
| 3214 // TODO(hpayer): Add support for non-constant allocation in dominator. | 3213 // TODO(hpayer): Add support for non-constant allocation in dominator. |
| 3215 if (!GuaranteedInNewSpace() || MustAllocateDoubleAligned() || | 3214 if (!GuaranteedInNewSpace() || |
| 3216 !current_size->IsInteger32Constant() || | 3215 !current_size->IsInteger32Constant() || |
| 3217 !dominator_allocate_instr->GuaranteedInNewSpace() || | 3216 !dominator_allocate_instr->GuaranteedInNewSpace() || |
| 3218 dominator_allocate_instr->MustAllocateDoubleAligned() || | |
| 3219 !dominator_size->IsInteger32Constant()) { | 3217 !dominator_size->IsInteger32Constant()) { |
| 3220 if (FLAG_trace_allocation_folding) { | 3218 if (FLAG_trace_allocation_folding) { |
| 3221 PrintF("#%d (%s) cannot fold into #%d (%s)\n", | 3219 PrintF("#%d (%s) cannot fold into #%d (%s)\n", |
| 3222 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); | 3220 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
| 3223 } | 3221 } |
| 3224 return; | 3222 return; |
| 3225 } | 3223 } |
| 3226 | 3224 |
| 3227 // First update the size of the dominator allocate instruction. | 3225 // First update the size of the dominator allocate instruction. |
| 3228 int32_t dominator_size_constant = | 3226 int32_t dominator_size_constant = |
| 3229 HConstant::cast(dominator_size)->GetInteger32Constant(); | 3227 HConstant::cast(dominator_size)->GetInteger32Constant(); |
| 3230 int32_t current_size_constant = | 3228 int32_t current_size_constant = |
| 3231 HConstant::cast(current_size)->GetInteger32Constant(); | 3229 HConstant::cast(current_size)->GetInteger32Constant(); |
| 3232 int32_t new_dominator_size = dominator_size_constant + current_size_constant; | 3230 int32_t new_dominator_size = |
| 3231 dominator_size_constant + current_size_constant; |
| 3232 bool double_alignment = MustAllocateDoubleAligned() && |
| 3233 kPointerAlignment != kDoubleAlignment; |
| 3234 |
| 3235 if (double_alignment) new_dominator_size += kDoubleSize / 2; |
| 3236 |
| 3233 if (new_dominator_size > Page::kMaxNonCodeHeapObjectSize) { | 3237 if (new_dominator_size > Page::kMaxNonCodeHeapObjectSize) { |
| 3234 if (FLAG_trace_allocation_folding) { | 3238 if (FLAG_trace_allocation_folding) { |
| 3235 PrintF("#%d (%s) cannot fold into #%d (%s) due to size: %d\n", | 3239 PrintF("#%d (%s) cannot fold into #%d (%s) due to size: %d\n", |
| 3236 id(), Mnemonic(), dominator->id(), dominator->Mnemonic(), | 3240 id(), Mnemonic(), dominator->id(), dominator->Mnemonic(), |
| 3237 new_dominator_size); | 3241 new_dominator_size); |
| 3238 } | 3242 } |
| 3239 return; | 3243 return; |
| 3240 } | 3244 } |
| 3241 HBasicBlock* block = dominator->block(); | 3245 HBasicBlock* block = dominator->block(); |
| 3242 Zone* zone = block->zone(); | 3246 Zone* zone = block->zone(); |
| 3243 HInstruction* new_dominator_size_constant = new(zone) HConstant( | 3247 HInstruction* new_dominator_size_constant = new(zone) HConstant( |
| 3244 new_dominator_size); | 3248 new_dominator_size); |
| 3245 new_dominator_size_constant->InsertBefore(dominator_allocate_instr); | 3249 new_dominator_size_constant->InsertBefore(dominator_allocate_instr); |
| 3246 dominator_allocate_instr->UpdateSize(new_dominator_size_constant); | 3250 dominator_allocate_instr->UpdateSize(new_dominator_size_constant); |
| 3247 | 3251 |
| 3248 #ifdef VERIFY_HEAP | 3252 #ifdef VERIFY_HEAP |
| 3249 if (FLAG_verify_heap) { | 3253 if (FLAG_verify_heap) { |
| 3250 dominator_allocate_instr->SetFlags(HAllocate::PREFILL_WITH_FILLER); | 3254 dominator_allocate_instr->SetFlags(HAllocate::PREFILL_WITH_FILLER); |
| 3251 } | 3255 } |
| 3252 #endif | 3256 #endif |
| 3253 | 3257 |
| 3254 // After that replace the dominated allocate instruction. | 3258 // After that replace the dominated allocate instruction. |
| 3255 HInstruction* dominated_allocate_instr = | 3259 HInstruction* dominated_allocate_instr = |
| 3256 new(zone) HInnerAllocatedObject(dominator_allocate_instr, | 3260 new(zone) HInnerAllocatedObject(dominator_allocate_instr, |
| 3257 dominator_size_constant, | 3261 dominator_size_constant, |
| 3258 type()); | 3262 type(), |
| 3263 double_alignment); |
| 3259 dominated_allocate_instr->InsertBefore(this); | 3264 dominated_allocate_instr->InsertBefore(this); |
| 3260 DeleteAndReplaceWith(dominated_allocate_instr); | 3265 DeleteAndReplaceWith(dominated_allocate_instr); |
| 3261 if (FLAG_trace_allocation_folding) { | 3266 if (FLAG_trace_allocation_folding) { |
| 3262 PrintF("#%d (%s) folded into #%d (%s)\n", | 3267 PrintF("#%d (%s) folded into #%d (%s)\n", |
| 3263 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); | 3268 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
| 3264 } | 3269 } |
| 3265 } | 3270 } |
| 3266 | 3271 |
| 3267 | 3272 |
| 3268 void HAllocate::PrintDataTo(StringStream* stream) { | 3273 void HAllocate::PrintDataTo(StringStream* stream) { |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3980 case kBackingStore: | 3985 case kBackingStore: |
| 3981 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3986 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 3982 stream->Add("[backing-store]"); | 3987 stream->Add("[backing-store]"); |
| 3983 break; | 3988 break; |
| 3984 } | 3989 } |
| 3985 | 3990 |
| 3986 stream->Add("@%d", offset()); | 3991 stream->Add("@%d", offset()); |
| 3987 } | 3992 } |
| 3988 | 3993 |
| 3989 } } // namespace v8::internal | 3994 } } // namespace v8::internal |
| OLD | NEW |