Skip to content

Commit 7b79224

Browse files
bmeurerCommit bot
authored andcommitted
[crankshaft] Disable further folding already folded allocations.
When we try to further fold previously folded allocations in Crankshaft GVN we don't properly transform the allocations involved, which causes the mechanism to leave holes in the new/old space (and thereby violate the iterability property of the new/old space). BUG=chromium:621868 [email protected] Review-Url: https://codereview.chromium.org/2297983003 Cr-Commit-Position: refs/heads/master@{#39040}
1 parent ce9e773 commit 7b79224

3 files changed

Lines changed: 31 additions & 13 deletions

File tree

src/crankshaft/hydrogen-instructions.cc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,6 +3184,13 @@ bool HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
31843184
return false;
31853185
}
31863186

3187+
if (IsAllocationFoldingDominator()) {
3188+
if (FLAG_trace_allocation_folding) {
3189+
PrintF("#%d (%s) cannot fold into #%d (%s), already dominator\n", id(),
3190+
Mnemonic(), dominator->id(), dominator->Mnemonic());
3191+
}
3192+
return false;
3193+
}
31873194

31883195
if (!IsFoldable(dominator_allocate)) {
31893196
if (FLAG_trace_allocation_folding) {
@@ -3235,17 +3242,6 @@ bool HAllocate::HandleSideEffectDominator(GVNFlag side_effect,
32353242
}
32363243
}
32373244

3238-
if (IsAllocationFoldingDominator()) {
3239-
DeleteAndReplaceWith(dominator_allocate);
3240-
if (FLAG_trace_allocation_folding) {
3241-
PrintF(
3242-
"#%d (%s) folded dominator into #%d (%s), new dominator size: %d\n",
3243-
id(), Mnemonic(), dominator_allocate->id(),
3244-
dominator_allocate->Mnemonic(), new_dominator_size);
3245-
}
3246-
return true;
3247-
}
3248-
32493245
if (!dominator_allocate->IsAllocationFoldingDominator()) {
32503246
HAllocate* first_alloc =
32513247
HAllocate::New(isolate, zone, dominator_allocate->context(),
@@ -3280,6 +3276,8 @@ std::ostream& HAllocate::PrintDataTo(std::ostream& os) const { // NOLINT
32803276
if (IsOldSpaceAllocation()) os << "P";
32813277
if (MustAllocateDoubleAligned()) os << "A";
32823278
if (MustPrefillWithFiller()) os << "F";
3279+
if (IsAllocationFoldingDominator()) os << "d";
3280+
if (IsAllocationFolded()) os << "f";
32833281
return os << ")";
32843282
}
32853283

src/crankshaft/hydrogen-instructions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4935,7 +4935,7 @@ class HAllocate final : public HTemplateInstruction<3> {
49354935
static_cast<HAllocate::Flags>(flags_ | ALLOCATION_FOLDING_DOMINATOR);
49364936
}
49374937

4938-
bool IsAllocationFoldingDominator() {
4938+
bool IsAllocationFoldingDominator() const {
49394939
return (flags_ & ALLOCATION_FOLDING_DOMINATOR) != 0;
49404940
}
49414941

@@ -4946,7 +4946,7 @@ class HAllocate final : public HTemplateInstruction<3> {
49464946
SetOperandAt(2, dominator);
49474947
}
49484948

4949-
bool IsAllocationFolded() { return (flags_ & ALLOCATION_FOLDED) != 0; }
4949+
bool IsAllocationFolded() const { return (flags_ & ALLOCATION_FOLDED) != 0; }
49504950

49514951
bool HandleSideEffectDominator(GVNFlag side_effect,
49524952
HValue* dominator) override;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2016 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --allow-natives-syntax --verify-heap
6+
7+
function f(a) { // First parameter is tagged.
8+
var n = 1 + a;
9+
}
10+
11+
function g() {
12+
f();
13+
var d = {x : f()};
14+
return [d];
15+
}
16+
17+
g();
18+
g();
19+
%OptimizeFunctionOnNextCall(g);
20+
g();

0 commit comments

Comments
 (0)