| 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 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 case IS_INTERNALIZED_STRING: | 1653 case IS_INTERNALIZED_STRING: |
| 1654 *mask = kIsInternalizedMask; | 1654 *mask = kIsInternalizedMask; |
| 1655 *tag = kInternalizedTag; | 1655 *tag = kInternalizedTag; |
| 1656 return; | 1656 return; |
| 1657 default: | 1657 default: |
| 1658 UNREACHABLE(); | 1658 UNREACHABLE(); |
| 1659 } | 1659 } |
| 1660 } | 1660 } |
| 1661 | 1661 |
| 1662 | 1662 |
| 1663 void HCheckMaps::SetSideEffectDominator(GVNFlag side_effect, | 1663 void HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect, |
| 1664 HValue* dominator) { | 1664 HValue* dominator) { |
| 1665 ASSERT(side_effect == kChangesMaps); | 1665 ASSERT(side_effect == kChangesMaps); |
| 1666 // TODO(mstarzinger): For now we specialize on HStoreNamedField, but once | 1666 // TODO(mstarzinger): For now we specialize on HStoreNamedField, but once |
| 1667 // type information is rich enough we should generalize this to any HType | 1667 // type information is rich enough we should generalize this to any HType |
| 1668 // for which the map is known. | 1668 // for which the map is known. |
| 1669 if (HasNoUses() && dominator->IsStoreNamedField()) { | 1669 if (HasNoUses() && dominator->IsStoreNamedField()) { |
| 1670 HStoreNamedField* store = HStoreNamedField::cast(dominator); | 1670 HStoreNamedField* store = HStoreNamedField::cast(dominator); |
| 1671 UniqueValueId map_unique_id = store->transition_unique_id(); | 1671 UniqueValueId map_unique_id = store->transition_unique_id(); |
| 1672 if (!map_unique_id.IsInitialized() || store->object() != value()) return; | 1672 if (!map_unique_id.IsInitialized() || store->object() != value()) return; |
| 1673 for (int i = 0; i < map_set()->length(); i++) { | 1673 for (int i = 0; i < map_set()->length(); i++) { |
| 1674 if (map_unique_id == map_unique_ids_.at(i)) { | 1674 if (map_unique_id == map_unique_ids_.at(i)) { |
| (...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3172 if (!input_rep.IsTagged()) rep = rep.generalize(input_rep); | 3172 if (!input_rep.IsTagged()) rep = rep.generalize(input_rep); |
| 3173 return rep; | 3173 return rep; |
| 3174 } | 3174 } |
| 3175 | 3175 |
| 3176 | 3176 |
| 3177 HType HStringCharFromCode::CalculateInferredType() { | 3177 HType HStringCharFromCode::CalculateInferredType() { |
| 3178 return HType::String(); | 3178 return HType::String(); |
| 3179 } | 3179 } |
| 3180 | 3180 |
| 3181 | 3181 |
| 3182 HType HAllocateObject::CalculateInferredType() { | |
| 3183 return HType::JSObject(); | |
| 3184 } | |
| 3185 | |
| 3186 | |
| 3187 HType HAllocate::CalculateInferredType() { | 3182 HType HAllocate::CalculateInferredType() { |
| 3188 return type_; | 3183 return type_; |
| 3189 } | 3184 } |
| 3190 | 3185 |
| 3191 | 3186 |
| 3187 void HAllocate::HandleSideEffectDominator(GVNFlag side_effect, |
| 3188 HValue* dominator) { |
| 3189 ASSERT(side_effect == kChangesNewSpacePromotion); |
| 3190 if (!FLAG_use_allocation_folding) return; |
| 3191 |
| 3192 // Try to fold allocations together with their dominating allocations. |
| 3193 if (!dominator->IsAllocate()) { |
| 3194 if (FLAG_trace_allocation_folding) { |
| 3195 PrintF("#%d (%s) cannot fold into #%d (%s)\n", |
| 3196 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
| 3197 } |
| 3198 return; |
| 3199 } |
| 3200 |
| 3201 HAllocate* dominator_allocate_instr = HAllocate::cast(dominator); |
| 3202 HValue* dominator_size = dominator_allocate_instr->size(); |
| 3203 HValue* current_size = size(); |
| 3204 // We can just fold allocations that are guaranteed in new space. |
| 3205 // TODO(hpayer): Support double aligned allocations. |
| 3206 // TODO(hpayer): Add support for non-constant allocation in dominator. |
| 3207 if (!GuaranteedInNewSpace() || MustAllocateDoubleAligned() || |
| 3208 !current_size->IsInteger32Constant() || |
| 3209 !dominator_allocate_instr->GuaranteedInNewSpace() || |
| 3210 dominator_allocate_instr->MustAllocateDoubleAligned() || |
| 3211 !dominator_size->IsInteger32Constant()) { |
| 3212 if (FLAG_trace_allocation_folding) { |
| 3213 PrintF("#%d (%s) cannot fold into #%d (%s)\n", |
| 3214 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
| 3215 } |
| 3216 return; |
| 3217 } |
| 3218 |
| 3219 // First update the size of the dominator allocate instruction. |
| 3220 int32_t dominator_size_constant = |
| 3221 HConstant::cast(dominator_size)->GetInteger32Constant(); |
| 3222 int32_t current_size_constant = |
| 3223 HConstant::cast(current_size)->GetInteger32Constant(); |
| 3224 HBasicBlock* block = dominator->block(); |
| 3225 Zone* zone = block->zone(); |
| 3226 HInstruction* new_dominator_size = new(zone) HConstant( |
| 3227 dominator_size_constant + current_size_constant); |
| 3228 new_dominator_size->InsertBefore(dominator_allocate_instr); |
| 3229 dominator_allocate_instr->UpdateSize(new_dominator_size); |
| 3230 |
| 3231 #ifdef VERIFY_HEAP |
| 3232 HInstruction* free_space_instr = |
| 3233 new(zone) HInnerAllocatedObject(dominator_allocate_instr, |
| 3234 dominator_size_constant, |
| 3235 type()); |
| 3236 free_space_instr->InsertAfter(dominator_allocate_instr); |
| 3237 HConstant* filler_map = new(zone) HConstant( |
| 3238 isolate()->factory()->free_space_map(), |
| 3239 UniqueValueId(isolate()->heap()->free_space_map()), |
| 3240 Representation::Tagged(), |
| 3241 HType::Tagged(), |
| 3242 false, |
| 3243 true, |
| 3244 false, |
| 3245 false); |
| 3246 filler_map->InsertAfter(free_space_instr); |
| 3247 |
| 3248 HInstruction* store_map = new(zone) HStoreNamedField( |
| 3249 free_space_instr, HObjectAccess::ForMap(), filler_map); |
| 3250 store_map->SetFlag(HValue::kHasNoObservableSideEffects); |
| 3251 store_map->InsertAfter(filler_map); |
| 3252 |
| 3253 HInstruction* free_space_size = new(zone) HConstant(current_size_constant); |
| 3254 free_space_size->InsertAfter(store_map); |
| 3255 HObjectAccess access = |
| 3256 HObjectAccess::ForJSObjectOffset(FreeSpace::kSizeOffset); |
| 3257 HInstruction* store_size = new(zone) HStoreNamedField( |
| 3258 free_space_instr, access, free_space_size); |
| 3259 store_size->SetFlag(HValue::kHasNoObservableSideEffects); |
| 3260 store_size->InsertAfter(free_space_size); |
| 3261 #endif |
| 3262 |
| 3263 // After that replace the dominated allocate instruction. |
| 3264 HInstruction* dominated_allocate_instr = |
| 3265 new(zone) HInnerAllocatedObject(dominator_allocate_instr, |
| 3266 dominator_size_constant, |
| 3267 type()); |
| 3268 dominated_allocate_instr->InsertBefore(this); |
| 3269 DeleteAndReplaceWith(dominated_allocate_instr); |
| 3270 if (FLAG_trace_allocation_folding) { |
| 3271 PrintF("#%d (%s) folded into #%d (%s)\n", |
| 3272 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
| 3273 } |
| 3274 } |
| 3275 |
| 3276 |
| 3192 void HAllocate::PrintDataTo(StringStream* stream) { | 3277 void HAllocate::PrintDataTo(StringStream* stream) { |
| 3193 size()->PrintNameTo(stream); | 3278 size()->PrintNameTo(stream); |
| 3194 if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)"); | 3279 if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)"); |
| 3195 } | 3280 } |
| 3196 | 3281 |
| 3197 | 3282 |
| 3198 HType HRegExpLiteral::CalculateInferredType() { | 3283 HType HRegExpLiteral::CalculateInferredType() { |
| 3199 return HType::JSObject(); | 3284 return HType::JSObject(); |
| 3200 } | 3285 } |
| 3201 | 3286 |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3901 case kBackingStore: | 3986 case kBackingStore: |
| 3902 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3987 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 3903 stream->Add("[backing-store]"); | 3988 stream->Add("[backing-store]"); |
| 3904 break; | 3989 break; |
| 3905 } | 3990 } |
| 3906 | 3991 |
| 3907 stream->Add("@%d", offset()); | 3992 stream->Add("@%d", offset()); |
| 3908 } | 3993 } |
| 3909 | 3994 |
| 3910 } } // namespace v8::internal | 3995 } } // namespace v8::internal |
| OLD | NEW |