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

Unified Diff: src/crankshaft/hydrogen-instructions.cc

Issue 1899813003: [crankshaft] Fragmentation-free allocation folding. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
Index: src/crankshaft/hydrogen-instructions.cc
diff --git a/src/crankshaft/hydrogen-instructions.cc b/src/crankshaft/hydrogen-instructions.cc
index 3d48d8fb71862d1e486ac6f0cc68911a8759f8a0..7fa653b368efe2afa2b05d3ab2c45d57223a58a2 100644
--- a/src/crankshaft/hydrogen-instructions.cc
+++ b/src/crankshaft/hydrogen-instructions.cc
@@ -3253,103 +3253,33 @@ bool HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
}
}
- bool keep_heap_iterable = FLAG_log_gc || FLAG_heap_stats;
-#ifdef VERIFY_HEAP
- keep_heap_iterable = keep_heap_iterable || FLAG_verify_heap;
-#endif
-
- if (keep_heap_iterable) {
- dominator_allocate->MakePrefillWithFiller();
- } else {
- // TODO(hpayer): This is a short-term hack to make allocation mementos
- // work again in new space.
- dominator_allocate->ClearNextMapWord(original_object_size);
+ if (!dominator_allocate->IsAllocationFoldingDominator()) {
+ HAllocate* first_alloc = HAllocate::New(
+ isolate, zone, dominator_allocate->context(), dominator_size,
+ dominator_allocate->type(),
+ IsNewSpaceAllocation() ? NOT_TENURED : TENURED, JS_OBJECT_TYPE);
+ first_alloc->MakeAllocationFoldingDominated();
+ first_alloc->InsertAfter(dominator_allocate);
+ dominator_allocate->ReplaceAllUsesWith(first_alloc);
+ dominator_allocate->MakeAllocationFoldingDominator();
+ if (FLAG_trace_allocation_folding) {
+ PrintF("#%d (%s) inserted for dominator #%d (%s)\n", first_alloc->id(),
+ first_alloc->Mnemonic(), dominator_allocate->id(),
+ dominator_allocate->Mnemonic());
+ }
}
- dominator_allocate->UpdateClearNextMapWord(MustClearNextMapWord());
-
- // After that replace the dominated allocate instruction.
- HInstruction* inner_offset = HConstant::CreateAndInsertBefore(
- isolate, zone, context(), dominator_size_constant, Representation::None(),
- this);
+ MakeAllocationFoldingDominated();
- HInstruction* dominated_allocate_instr = HInnerAllocatedObject::New(
- isolate, zone, context(), dominator_allocate, inner_offset, 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_allocate->id(),
- dominator_allocate->Mnemonic());
+ PrintF("#%d (%s) folded into #%d (%s), new dominator size: %d\n", id(),
+ Mnemonic(), dominator_allocate->id(), dominator_allocate->Mnemonic(),
+ new_dominator_size);
}
return true;
}
-void HAllocate::UpdateFreeSpaceFiller(int32_t free_space_size) {
- DCHECK(filler_free_space_size_ != NULL);
- Zone* zone = block()->zone();
- // We must explicitly force Smi representation here because on x64 we
- // would otherwise automatically choose int32, but the actual store
- // requires a Smi-tagged value.
- HConstant* new_free_space_size = HConstant::CreateAndInsertBefore(
- block()->isolate(), zone, context(),
- filler_free_space_size_->value()->GetInteger32Constant() +
- free_space_size,
- Representation::Smi(), filler_free_space_size_);
- filler_free_space_size_->UpdateValue(new_free_space_size);
-}
-
-
-void HAllocate::CreateFreeSpaceFiller(int32_t free_space_size) {
- DCHECK(filler_free_space_size_ == NULL);
- Isolate* isolate = block()->isolate();
- Zone* zone = block()->zone();
- HInstruction* free_space_instr =
- HInnerAllocatedObject::New(isolate, zone, context(), dominating_allocate_,
- dominating_allocate_->size(), type());
- free_space_instr->InsertBefore(this);
- HConstant* filler_map = HConstant::CreateAndInsertAfter(
- zone, Unique<Map>::CreateImmovable(isolate->factory()->free_space_map()),
- true, free_space_instr);
- HInstruction* store_map =
- HStoreNamedField::New(isolate, zone, context(), free_space_instr,
- HObjectAccess::ForMap(), filler_map);
- store_map->SetFlag(HValue::kHasNoObservableSideEffects);
- store_map->InsertAfter(filler_map);
-
- // We must explicitly force Smi representation here because on x64 we
- // would otherwise automatically choose int32, but the actual store
- // requires a Smi-tagged value.
- HConstant* filler_size =
- HConstant::CreateAndInsertAfter(isolate, zone, context(), free_space_size,
- Representation::Smi(), store_map);
- // Must force Smi representation for x64 (see comment above).
- HObjectAccess access = HObjectAccess::ForMapAndOffset(
- isolate->factory()->free_space_map(), FreeSpace::kSizeOffset,
- Representation::Smi());
- HStoreNamedField* store_size = HStoreNamedField::New(
- isolate, zone, context(), free_space_instr, access, filler_size);
- store_size->SetFlag(HValue::kHasNoObservableSideEffects);
- store_size->InsertAfter(filler_size);
- filler_free_space_size_ = store_size;
-}
-
-
-void HAllocate::ClearNextMapWord(int offset) {
- if (MustClearNextMapWord()) {
- Zone* zone = block()->zone();
- HObjectAccess access =
- HObjectAccess::ForObservableJSObjectOffset(offset);
- HStoreNamedField* clear_next_map =
- HStoreNamedField::New(block()->isolate(), zone, context(), this, access,
- block()->graph()->GetConstant0());
- clear_next_map->ClearAllSideEffects();
- clear_next_map->InsertAfter(this);
- }
-}
-
-
std::ostream& HAllocate::PrintDataTo(std::ostream& os) const { // NOLINT
os << NameOf(size()) << " (";
if (IsNewSpaceAllocation()) os << "N";

Powered by Google App Engine
This is Rietveld 408576698