Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: src/hydrogen-instructions.cc

Issue 18596005: Allocation folding integrated into the GVN phase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after
3190 HType HAllocateObject::CalculateInferredType() { 3190 HType HAllocateObject::CalculateInferredType() {
3191 return HType::JSObject(); 3191 return HType::JSObject();
3192 } 3192 }
3193 3193
3194 3194
3195 HType HAllocate::CalculateInferredType() { 3195 HType HAllocate::CalculateInferredType() {
3196 return type_; 3196 return type_;
3197 } 3197 }
3198 3198
3199 3199
3200 void HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
3201 HValue* dominator) {
3202 ASSERT(side_effect == kChangesNewSpacePromotion);
3203 // Try to fold allocations together with their dominating allocations.
3204 if (!FLAG_use_allocation_folding || !dominator->IsAllocate()) {
3205 return;
3206 }
3207 HAllocate* dominator_allocate_instr = HAllocate::cast(dominator);
3208 HValue* dominator_size = dominator_allocate_instr->size();
3209 HValue* current_size = size();
3210 // We can just fold allocations that are guaranteed in new space.
3211 // TODO(hpayer): Support double aligned allocations.
3212 // TODO(hpayer): Add support for non-constant allocation in dominator.
3213 if (!GuaranteedInNewSpace() || MustAllocateDoubleAligned() ||
3214 !current_size->IsInteger32Constant() ||
3215 !dominator_allocate_instr->GuaranteedInNewSpace() ||
3216 dominator_allocate_instr->MustAllocateDoubleAligned() ||
3217 !dominator_size->IsInteger32Constant()) {
3218 return;
3219 }
3220
3221 // First update the size of the dominator allocate instruction.
3222 int32_t dominator_size_constant =
3223 HConstant::cast(dominator_size)->GetInteger32Constant();
3224 int32_t current_size_constant =
3225 HConstant::cast(current_size)->GetInteger32Constant();
3226 HBasicBlock* block = dominator->block();
3227 Zone* zone = block->zone();
3228 HInstruction* new_dominator_size = new(zone) HConstant(
3229 dominator_size_constant + current_size_constant);
3230 new_dominator_size->InsertBefore(dominator_allocate_instr);
3231 dominator_allocate_instr->UpdateSize(new_dominator_size);
3232
3233 // TODO(hpayer): Remove filler map but make sure new space is valid.
3234 HInstruction* free_space_instr =
3235 new(zone) HInnerAllocatedObject(dominator_allocate_instr,
3236 dominator_size_constant,
3237 type());
3238 free_space_instr->InsertAfter(dominator_allocate_instr);
3239 HConstant* filler_map = new(zone) HConstant(
3240 isolate()->factory()->free_space_map(),
3241 UniqueValueId(isolate()->heap()->free_space_map()),
3242 Representation::Tagged(),
3243 HType::Tagged(),
3244 false,
3245 true,
3246 false,
3247 false);
3248 filler_map->InsertAfter(free_space_instr);
3249
3250 HInstruction* store_map = new(zone) HStoreNamedField(
3251 free_space_instr, HObjectAccess::ForMap(), filler_map);
3252 store_map->SetFlag(HValue::kHasNoObservableSideEffects);
3253 store_map->InsertAfter(filler_map);
3254
3255 HInstruction* free_space_size = new(zone) HConstant(current_size_constant);
3256 free_space_size->InsertAfter(store_map);
3257 HObjectAccess access =
3258 HObjectAccess::ForJSObjectOffset(FreeSpace::kSizeOffset);
3259 HInstruction* store_size = new(zone) HStoreNamedField(
3260 free_space_instr, access, free_space_size);
3261 store_size->SetFlag(HValue::kHasNoObservableSideEffects);
3262 store_size->InsertAfter(free_space_size);
3263
3264 // After that replace the dominated allocate instruction.
3265 HInstruction* dominated_allocate_instr =
3266 new(zone) HInnerAllocatedObject(dominator_allocate_instr,
3267 dominator_size_constant,
3268 type());
3269 dominated_allocate_instr->InsertBefore(this);
3270 DeleteAndReplaceWith(dominated_allocate_instr);
3271 if (FLAG_trace_allocation_folding) {
3272 PrintF("#%d (%s) folded into #%d (%s)\n",
3273 id(), Mnemonic(), dominator->id(), dominator->Mnemonic());
3274 }
3275 }
3276
3277
3200 void HAllocate::PrintDataTo(StringStream* stream) { 3278 void HAllocate::PrintDataTo(StringStream* stream) {
3201 size()->PrintNameTo(stream); 3279 size()->PrintNameTo(stream);
3202 if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)"); 3280 if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)");
3203 } 3281 }
3204 3282
3205 3283
3206 HType HRegExpLiteral::CalculateInferredType() { 3284 HType HRegExpLiteral::CalculateInferredType() {
3207 return HType::JSObject(); 3285 return HType::JSObject();
3208 } 3286 }
3209 3287
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
3916 case kBackingStore: 3994 case kBackingStore:
3917 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); 3995 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString());
3918 stream->Add("[backing-store]"); 3996 stream->Add("[backing-store]");
3919 break; 3997 break;
3920 } 3998 }
3921 3999
3922 stream->Add("@%d", offset()); 4000 stream->Add("@%d", offset());
3923 } 4001 }
3924 4002
3925 } } // namespace v8::internal 4003 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698