[vm/compiler] Properly treat AllocateClosureInstr as an allocation.

When we switched from allocating closures with AllocateObject to
using AllocateClosure, a couple of places that needed to check for
IsAllocateClosure() were missed. This caused AllocateClosureInstrs to
never have a NotAliased Identity(), which then forced some
AllocateUninitializedContextInstrs to be kept instead of eliminated.

TEST=Checked using benchmarks that saw regressions due to this change.

Change-Id: If63d4cae190453233429b5657cbe177cac265074
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199430
Commit-Queue: Tess Strickland <sstrickl@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Tess Strickland
2021-05-12 16:34:00 +00:00
committed by commit-bot@chromium.org
parent 3fa5667c1a
commit 7131d3182c
@@ -444,8 +444,8 @@ class Place : public ValueObject {
static bool IsAllocation(Definition* defn) {
return (defn != NULL) &&
(defn->IsAllocateObject() || defn->IsCreateArray() ||
defn->IsAllocateTypedData() ||
(defn->IsAllocateObject() || defn->IsAllocateClosure() ||
defn->IsCreateArray() || defn->IsAllocateTypedData() ||
defn->IsAllocateUninitializedContext() ||
(defn->IsStaticCall() &&
defn->AsStaticCall()->IsRecognizedFactory()));
@@ -1554,7 +1554,9 @@ void DelayAllocations::Optimize(FlowGraph* graph) {
for (ForwardInstructionIterator instr_it(block); !instr_it.Done();
instr_it.Advance()) {
Definition* def = instr_it.Current()->AsDefinition();
if (def != nullptr && (def->IsAllocateObject() || def->IsCreateArray()) &&
if (def != nullptr &&
(def->IsAllocateObject() || def->IsAllocateClosure() ||
def->IsCreateArray()) &&
def->env() == nullptr && !moved.HasKey(def)) {
Instruction* use = DominantUse(def);
if (use != nullptr && !use->IsPhi() && IsOneTimeUse(use, def)) {