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

Unified 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 side-by-side diff with in-line comments
Download patch
« src/hydrogen-instructions.h ('K') | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 041ef8b37408f11fcb8cdc68e26abbf3c479966e..5a4ba7d4d5ebaba4b518e96fe3d9d77eb447b586 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -1654,7 +1654,7 @@ void HCheckInstanceType::GetCheckMaskAndTag(uint8_t* mask, uint8_t* tag) {
}
-void HCheckMaps::SetSideEffectDominator(GVNFlag side_effect,
+void HCheckMaps::HandleSideEffectDominator(GVNFlag side_effect,
HValue* dominator) {
Michael Starzinger 2013/07/08 12:44:06 nit: Indentation if off.
Hannes Payer (out of office) 2013/07/08 13:43:48 Done.
ASSERT(side_effect == kChangesMaps);
// TODO(mstarzinger): For now we specialize on HStoreNamedField, but once
@@ -3040,6 +3040,11 @@ void HLoadGlobalGeneric::PrintDataTo(StringStream* stream) {
}
+HType HInnerAllocatedObject::CalculateInferredType() {
+ return type_;
+}
+
+
void HInnerAllocatedObject::PrintDataTo(StringStream* stream) {
base_object()->PrintNameTo(stream);
stream->Add(" offset %d", offset());
@@ -3197,6 +3202,75 @@ HType HAllocate::CalculateInferredType() {
}
+void HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
+ HValue* dominator) {
Michael Starzinger 2013/07/08 12:44:06 nit: Indentation is off.
Hannes Payer (out of office) 2013/07/08 13:43:48 Done.
+ ASSERT(side_effect == kChangesNewSpacePromotion);
+ if (FLAG_use_allocation_folding) {
titzer 2013/07/08 12:40:14 if (!FLAG_...) return; if (!...) return; Can remo
Michael Starzinger 2013/07/08 12:44:06 Can we do early returns here instead of indenting
Hannes Payer (out of office) 2013/07/08 13:43:48 Done.
+ if (dominator->IsAllocate()) {
+ HAllocate* dominator_allocate_instr = HAllocate::cast(dominator);
+ // We can just fold allocations that are guaranteed in new space.
+ // TODO(hpayer): Support double aligned allocations.
+ if (GuaranteedInNewSpace() && !MustAllocateDoubleAligned() &&
+ dominator_allocate_instr->GuaranteedInNewSpace() &&
+ !dominator_allocate_instr->MustAllocateDoubleAligned()) {
+ HValue* dominator_size = dominator_allocate_instr->size();
+ HValue* current_size = size();
+ // TODO(hpayer): Add support for non-constant allocation in dominator.
+ if (current_size->IsInteger32Constant() &&
+ dominator_size->IsInteger32Constant()) {
+ // First update the size of the dominator allocate instruction.
+ int32_t dominator_size_constant =
+ HConstant::cast(dominator_size)->GetInteger32Constant();
+ int32_t current_size_constant =
+ HConstant::cast(current_size)->GetInteger32Constant();
+ HBasicBlock* block = dominator->block();
+ Zone* zone = block->zone();
+ HInstruction* new_dominator_size = new(zone) HConstant(
+ dominator_size_constant + current_size_constant);
+ HInstruction* dominator_instr = HInstruction::cast(dominator);
titzer 2013/07/08 12:40:14 You already have dominator as dominator_allocate_i
Hannes Payer (out of office) 2013/07/08 13:43:48 Done.
+ new_dominator_size->InsertBefore(dominator_instr);
+ dominator_allocate_instr->UpdateSize(new_dominator_size);
+
+ // TODO(hpayer): Remove filler map but make sure new space is valid.
+ HInstruction* free_space_instr =
+ new(zone) HInnerAllocatedObject(dominator_instr,
+ dominator_size_constant,
+ type());
+ free_space_instr->InsertAfter(dominator_instr);
+ HConstant* filler_map = block->graph()->GetConstantFreeSpaceMap();
titzer 2013/07/08 12:40:14 Don't make this a global constant in the graph. Th
Michael Starzinger 2013/07/08 12:44:06 I don't think this is an issue as the HConstant wi
Hannes Payer (out of office) 2013/07/08 13:43:48 OK. I am leaving this code since it will disappea
titzer 2013/07/08 13:49:38 Why? If it is not so important, then please do not
Michael Starzinger 2013/07/08 14:02:43 I kind of see Ben's point here. If it is possible
+ HInstruction* store_map = new(zone) HStoreNamedField(
+ free_space_instr, HObjectAccess::ForMap(), filler_map,
+ Representation::Tagged(), true);
+ store_map->InsertAfter(free_space_instr);
+
+ HInstruction* free_space_size =
+ new(zone) HConstant(current_size_constant);
+ free_space_size->InsertAfter(store_map);
+ HObjectAccess access =
+ HObjectAccess::ForJSObjectOffset(FreeSpace::kSizeOffset);
+ HInstruction* store_size = new(zone) HStoreNamedField(
+ free_space_instr, access, free_space_size,
+ Representation::Tagged(), true);
+ store_size->InsertAfter(free_space_size);
+
+ // After that replace the dominated allocate instruction.
+ HInstruction* dominated_allocate_instr =
+ new(zone) HInnerAllocatedObject(dominator_instr,
+ dominator_size_constant,
+ type());
+ dominated_allocate_instr->InsertBefore(this);
+ DeleteAndReplaceWith(dominated_allocate_instr);
+ if (FLAG_trace_allocation_folding) {
+ PrintF("#%d (%s) folded into #%d (%s)\n",
+ id(), Mnemonic(), dominator->id(), dominator->Mnemonic());
+ }
+ }
+ }
+ }
+ }
+}
+
+
void HAllocate::PrintDataTo(StringStream* stream) {
size()->PrintNameTo(stream);
if (!GuaranteedInNewSpace()) stream->Add(" (pretenure)");
« src/hydrogen-instructions.h ('K') | « src/hydrogen-instructions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698