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() { |
| 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 |
| 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 = block->graph()->GetConstantFreeSpaceMap(); |
| 3244 HInstruction* store_map = new(zone) HStoreNamedField( |
| 3245 free_space_instr, HObjectAccess::ForMap(), filler_map, |
| 3246 Representation::Tagged(), true); |
| 3247 store_map->InsertAfter(free_space_instr); |
| 3248 |
| 3249 HInstruction* free_space_size = new(zone) HConstant(current_size_constant); |
| 3250 free_space_size->InsertAfter(store_map); |
| 3251 HObjectAccess access = |
| 3252 HObjectAccess::ForJSObjectOffset(FreeSpace::kSizeOffset); |
| 3253 HInstruction* store_size = new(zone) HStoreNamedField( |
| 3254 free_space_instr, access, free_space_size, Representation::Tagged(), |
| 3255 true); |
| 3256 store_size->InsertAfter(free_space_size); |
| 3257 |
| 3258 // After that replace the dominated allocate instruction. |
| 3259 HInstruction* dominated_allocate_instr = |
| 3260 new(zone) HInnerAllocatedObject(dominator_allocate_instr, |
| 3261 dominator_size_constant, |
| 3262 type()); |
| 3263 dominated_allocate_instr->InsertBefore(this); |
| 3264 DeleteAndReplaceWith(dominated_allocate_instr); |
| 3265 if (FLAG_trace_allocation_folding) { |
| 3266 PrintF("#%d (%s) folded into #%d (%s)\n", |
| 3267 id(), Mnemonic(), dominator->id(), dominator->Mnemonic()); |
| 3268 } |
| 3269 } |
| 3270 |
| 3271 |
3200 void HAllocate::PrintDataTo(StringStream* stream) { | 3272 void HAllocate::PrintDataTo(StringStream* stream) { |
3201 size()->PrintNameTo(stream); | 3273 size()->PrintNameTo(stream); |
3202 if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)"); | 3274 if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)"); |
3203 } | 3275 } |
3204 | 3276 |
3205 | 3277 |
3206 HType HRegExpLiteral::CalculateInferredType() { | 3278 HType HRegExpLiteral::CalculateInferredType() { |
3207 return HType::JSObject(); | 3279 return HType::JSObject(); |
3208 } | 3280 } |
3209 | 3281 |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3916 case kBackingStore: | 3988 case kBackingStore: |
3917 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 3989 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
3918 stream->Add("[backing-store]"); | 3990 stream->Add("[backing-store]"); |
3919 break; | 3991 break; |
3920 } | 3992 } |
3921 | 3993 |
3922 stream->Add("@%d", offset()); | 3994 stream->Add("@%d", offset()); |
3923 } | 3995 } |
3924 | 3996 |
3925 } } // namespace v8::internal | 3997 } } // namespace v8::internal |
OLD | NEW |