Skip to content

Commit 259a5f8

Browse files
victorgomesV8 LUCI CQ
authored andcommitted
[maglev] Add stable map dependency when loading map from closure
Fixed: 369630648 Change-Id: Ib298eca15e2a9ca8bb12db685a60c5f94a9dc1cc Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5891221 Reviewed-by: Olivier Flückiger <[email protected]> Auto-Submit: Victor Gomes <[email protected]> Commit-Queue: Olivier Flückiger <[email protected]> Cr-Commit-Position: refs/heads/main@{#96334}
1 parent 520ba9d commit 259a5f8

2 files changed

Lines changed: 30 additions & 6 deletions

File tree

src/maglev/maglev-graph-builder.cc

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7012,15 +7012,21 @@ void MaglevGraphBuilder::VisitDeletePropertySloppy() {
70127012

70137013
void MaglevGraphBuilder::VisitGetSuperConstructor() {
70147014
ValueNode* active_function = GetAccumulator();
7015-
ValueNode* map_proto;
7015+
// TODO(victorgomes): Maybe BuildLoadTaggedField should support constants
7016+
// instead.
70167017
if (compiler::OptionalHeapObjectRef constant =
70177018
TryGetConstant(active_function)) {
7018-
map_proto = GetConstant(constant->map(broker()).prototype(broker()));
7019-
} else {
7020-
ValueNode* map =
7021-
BuildLoadTaggedField(active_function, HeapObject::kMapOffset);
7022-
map_proto = BuildLoadTaggedField(map, Map::kPrototypeOffset);
7019+
compiler::MapRef map = constant->map(broker());
7020+
if (map.is_stable()) {
7021+
broker()->dependencies()->DependOnStableMap(map);
7022+
ValueNode* map_proto = GetConstant(map.prototype(broker()));
7023+
StoreRegister(iterator_.GetRegisterOperand(0), map_proto);
7024+
return;
7025+
}
70237026
}
7027+
ValueNode* map =
7028+
BuildLoadTaggedField(active_function, HeapObject::kMapOffset);
7029+
ValueNode* map_proto = BuildLoadTaggedField(map, Map::kPrototypeOffset);
70247030
StoreRegister(iterator_.GetRegisterOperand(0), map_proto);
70257031
}
70267032

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2024 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 --no-lazy-feedback-allocation
6+
7+
class C extends Array {
8+
constructor() {
9+
(() => (() => super())())();
10+
}
11+
}
12+
%PrepareFunctionForOptimization(C);
13+
new C();
14+
new C();
15+
%OptimizeFunctionOnNextCall(C);
16+
new C();
17+
C.__proto__ = [1];
18+
assertThrows(() => { new C() }, TypeError);

0 commit comments

Comments
 (0)