Chromium Code Reviews| 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 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1647 case IS_INTERNALIZED_STRING: | 1647 case IS_INTERNALIZED_STRING: |
| 1648 *mask = kIsInternalizedMask; | 1648 *mask = kIsInternalizedMask; |
| 1649 *tag = kInternalizedTag; | 1649 *tag = kInternalizedTag; |
| 1650 return; | 1650 return; |
| 1651 default: | 1651 default: |
| 1652 UNREACHABLE(); | 1652 UNREACHABLE(); |
| 1653 } | 1653 } |
| 1654 } | 1654 } |
| 1655 | 1655 |
| 1656 | 1656 |
| 1657 void HCheckMaps::SetSideEffectDominator(GVNFlag side_effect, | 1657 void HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect, |
| 1658 HValue* dominator) { | 1658 HValue* dominator) { |
| 1659 ASSERT(side_effect == kChangesMaps); | 1659 ASSERT(side_effect == kChangesMaps); |
| 1660 // TODO(mstarzinger): For now we specialize on HStoreNamedField, but once | 1660 // TODO(mstarzinger): For now we specialize on HStoreNamedField, but once |
| 1661 // type information is rich enough we should generalize this to any HType | 1661 // type information is rich enough we should generalize this to any HType |
| 1662 // for which the map is known. | 1662 // for which the map is known. |
| 1663 if (HasNoUses() && dominator->IsStoreNamedField()) { | 1663 if (HasNoUses() && dominator->IsStoreNamedField()) { |
| 1664 HStoreNamedField* store = HStoreNamedField::cast(dominator); | 1664 HStoreNamedField* store = HStoreNamedField::cast(dominator); |
| 1665 UniqueValueId map_unique_id = store->transition_unique_id(); | 1665 UniqueValueId map_unique_id = store->transition_unique_id(); |
| 1666 if (!map_unique_id.IsInitialized() || store->object() != value()) return; | 1666 if (!map_unique_id.IsInitialized() || store->object() != value()) return; |
| 1667 for (int i = 0; i < map_set()->length(); i++) { | 1667 for (int i = 0; i < map_set()->length(); i++) { |
| 1668 if (map_unique_id == map_unique_ids_.at(i)) { | 1668 if (map_unique_id == map_unique_ids_.at(i)) { |
| (...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3033 } | 3033 } |
| 3034 return false; | 3034 return false; |
| 3035 } | 3035 } |
| 3036 | 3036 |
| 3037 | 3037 |
| 3038 void HLoadGlobalGeneric::PrintDataTo(StringStream* stream) { | 3038 void HLoadGlobalGeneric::PrintDataTo(StringStream* stream) { |
| 3039 stream->Add("%o ", *name()); | 3039 stream->Add("%o ", *name()); |
| 3040 } | 3040 } |
| 3041 | 3041 |
| 3042 | 3042 |
| 3043 HType HInnerAllocatedObject::CalculateInferredType() { | |
|
titzer
2013/07/09 08:34:39
Can put this in the header.
Hannes Payer (out of office)
2013/07/09 09:01:33
Done.
| |
| 3044 return type_; | |
| 3045 } | |
| 3046 | |
| 3047 | |
| 3043 void HInnerAllocatedObject::PrintDataTo(StringStream* stream) { | 3048 void HInnerAllocatedObject::PrintDataTo(StringStream* stream) { |
| 3044 base_object()->PrintNameTo(stream); | 3049 base_object()->PrintNameTo(stream); |
| 3045 stream->Add(" offset %d", offset()); | 3050 stream->Add(" offset %d", offset()); |
| 3046 } | 3051 } |
| 3047 | 3052 |
| 3048 | 3053 |
| 3049 void HStoreGlobalCell::PrintDataTo(StringStream* stream) { | 3054 void HStoreGlobalCell::PrintDataTo(StringStream* stream) { |
| 3050 stream->Add("[%p] = ", *cell()); | 3055 stream->Add("[%p] = ", *cell()); |
| 3051 value()->PrintNameTo(stream); | 3056 value()->PrintNameTo(stream); |
| 3052 if (!details_.IsDontDelete()) stream->Add(" (deleteable)"); | 3057 if (!details_.IsDontDelete()) stream->Add(" (deleteable)"); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3190 HType HAllocateObject::CalculateInferredType() { | 3195 HType HAllocateObject::CalculateInferredType() { |
| 3191 return HType::JSObject(); | 3196 return HType::JSObject(); |
| 3192 } | 3197 } |
| 3193 | 3198 |
| 3194 | 3199 |
| 3195 HType HAllocate::CalculateInferredType() { | 3200 HType HAllocate::CalculateInferredType() { |
| 3196 return type_; | 3201 return type_; |
| 3197 } | 3202 } |
| 3198 | 3203 |
| 3199 | 3204 |
| 3205 void HAllocate::HandleSideEffectDominator(GVNFlag side_effect, | |
| 3206 HValue* dominator) { | |
| 3207 ASSERT(side_effect == kChangesNewSpacePromotion); | |
| 3208 if (!FLAG_use_allocation_folding || !dominator->IsAllocate()) { | |
| 3209 return; | |
| 3210 } | |
| 3211 HAllocate* dominator_allocate_instr = HAllocate::cast(dominator); | |
| 3212 HValue* dominator_size = dominator_allocate_instr->size(); | |
| 3213 HValue* current_size = size(); | |
| 3214 // We can just fold allocations that are guaranteed in new space. | |
| 3215 // TODO(hpayer): Support double aligned allocations. | |
| 3216 // TODO(hpayer): Add support for non-constant allocation in dominator. | |
| 3217 if (!GuaranteedInNewSpace() || MustAllocateDoubleAligned() || | |
| 3218 !current_size->IsInteger32Constant() || | |
| 3219 !dominator_allocate_instr->GuaranteedInNewSpace() || | |
| 3220 dominator_allocate_instr->MustAllocateDoubleAligned() || | |
| 3221 !dominator_size->IsInteger32Constant()) { | |
| 3222 return; | |
| 3223 } | |
| 3224 | |
|
titzer
2013/07/09 08:34:39
Add comment to the effect of "try to fold allocati
Hannes Payer (out of office)
2013/07/09 09:01:33
Done.
| |
| 3225 // First update the size of the dominator allocate instruction. | |
| 3226 int32_t dominator_size_constant = | |
| 3227 HConstant::cast(dominator_size)->GetInteger32Constant(); | |
| 3228 int32_t current_size_constant = | |
| 3229 HConstant::cast(current_size)->GetInteger32Constant(); | |
| 3230 HBasicBlock* block = dominator->block(); | |
| 3231 Zone* zone = block->zone(); | |
| 3232 HInstruction* new_dominator_size = new(zone) HConstant( | |
| 3233 dominator_size_constant + current_size_constant); | |
| 3234 new_dominator_size->InsertBefore(dominator_allocate_instr); | |
| 3235 dominator_allocate_instr->UpdateSize(new_dominator_size); | |
| 3236 | |
| 3237 // TODO(hpayer): Remove filler map but make sure new space is valid. | |
| 3238 HInstruction* free_space_instr = | |
| 3239 new(zone) HInnerAllocatedObject(dominator_allocate_instr, | |
| 3240 dominator_size_constant, | |
| 3241 type()); | |
| 3242 free_space_instr->InsertAfter(dominator_allocate_instr); | |
| 3243 HConstant* filler_map = new(zone) HConstant( | |
| 3244 isolate()->factory()->free_space_map(), | |
| 3245 UniqueValueId(isolate()->heap()->free_space_map()), | |
| 3246 Representation::None(), | |
|
titzer
2013/07/09 08:34:39
I think you want Representation::Tagged()
Hannes Payer (out of office)
2013/07/09 09:01:33
Done.
| |
| 3247 HType::Tagged(), | |
| 3248 false, | |
| 3249 true, | |
| 3250 false, | |
| 3251 false); | |
| 3252 filler_map->InsertAfter(free_space_instr); | |
| 3253 | |
| 3254 HInstruction* store_map = new(zone) HStoreNamedField( | |
| 3255 free_space_instr, HObjectAccess::ForMap(), filler_map); | |
| 3256 store_map->SetFlag(HValue::kHasNoObservableSideEffects); | |
| 3257 store_map->InsertAfter(filler_map); | |
| 3258 | |
| 3259 HInstruction* free_space_size = new(zone) HConstant(current_size_constant); | |
| 3260 free_space_size->InsertAfter(store_map); | |
| 3261 HObjectAccess access = | |
| 3262 HObjectAccess::ForJSObjectOffset(FreeSpace::kSizeOffset); | |
| 3263 HInstruction* store_size = new(zone) HStoreNamedField( | |
| 3264 free_space_instr, access, free_space_size); | |
| 3265 store_size->InsertAfter(free_space_size); | |
| 3266 | |
| 3267 // After that replace the dominated allocate instruction. | |
| 3268 HInstruction* dominated_allocate_instr = | |
| 3269 new(zone) HInnerAllocatedObject(dominator_allocate_instr, | |
| 3270 dominator_size_constant, | |
| 3271 type()); | |
| 3272 dominated_allocate_instr->InsertBefore(this); | |
| 3273 DeleteAndReplaceWith(dominated_allocate_instr); | |
| 3274 if (FLAG_trace_allocation_folding) { | |
| 3275 PrintF("#%d (%s) folded into #%d (%s)\n", | |
| 3276 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); | |
| 3277 } | |
| 3278 } | |
| 3279 | |
| 3280 | |
| 3200 void HAllocate::PrintDataTo(StringStream* stream) { | 3281 void HAllocate::PrintDataTo(StringStream* stream) { |
| 3201 size()->PrintNameTo(stream); | 3282 size()->PrintNameTo(stream); |
| 3202 if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)"); | 3283 if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)"); |
| 3203 } | 3284 } |
| 3204 | 3285 |
| 3205 | 3286 |
| 3206 HType HRegExpLiteral::CalculateInferredType() { | 3287 HType HRegExpLiteral::CalculateInferredType() { |
| 3207 return HType::JSObject(); | 3288 return HType::JSObject(); |
| 3208 } | 3289 } |
| 3209 | 3290 |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3916 case kBackingStore: | 3997 case kBackingStore: |
| 3917 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3998 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 3918 stream->Add("[backing-store]"); | 3999 stream->Add("[backing-store]"); |
| 3919 break; | 4000 break; |
| 3920 } | 4001 } |
| 3921 | 4002 |
| 3922 stream->Add("@%d", offset()); | 4003 stream->Add("@%d", offset()); |
| 3923 } | 4004 } |
| 3924 | 4005 |
| 3925 } } // namespace v8::internal | 4006 } } // namespace v8::internal |
| OLD | NEW |