Skip to content

Commit 8b490a9

Browse files
marjakhV8 LUCI CQ
authored andcommitted
[turbofan] Fix TransitionElementsKindOrCheckMap
Take into account that TransitionElementsKindOrCheckMap might change the map of an aliasing object. h/t dmercadier@ for figuring out the fix. Bug: 400052777 Change-Id: I07ac56058591619736dcc2d8f7355a7a34ecbbc7 Fixed: 400052777 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/6321930 Reviewed-by: Darius Mercadier <[email protected]> Commit-Queue: Marja Hölttä <[email protected]> Cr-Commit-Position: refs/heads/main@{#99049}
1 parent 8f51e03 commit 8b490a9

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/compiler/node-properties.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,9 @@ NodeProperties::InferMapsResult NodeProperties::InferMapsUnsafe(
458458
ElementsTransitionWithMultipleSourcesOf(effect->op()).target()};
459459
return result;
460460
}
461+
// `receiver` and `object` might alias, so
462+
// TransitionElementsKindOrCheckMaps might change receiver's map.
463+
result = kUnreliableMaps;
461464
break;
462465
}
463466
case IrOpcode::kJSCreate: {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2025 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 --turbofan --no-always-turbofan
6+
7+
function main() {
8+
function f0(v2, v3) {
9+
// TransitionElementsKindOrCheckMap: PACKED_SMI -> HOLEY_DOUBLE_ELEMENTS
10+
var v4 = v3[0];
11+
12+
// TransitionElementsKindOrCheckMap: HOLEY_DOUBLE_ELEMENTS -> HOLEY_ELEMENTS
13+
var v5 = v2[0];
14+
15+
// If v2 == v3, v3 doesn't have HOLEY_DOUBLE_ELEMENTS anymore.
16+
Array.prototype.indexOf.call(v3);
17+
}
18+
%PrepareFunctionForOptimization(f0);
19+
20+
const holey = new Array(1);
21+
holey[0] = 'tagged'; // HOLEY_ELEMENTS
22+
f0(holey, [1]);
23+
24+
const holey_double = new Array(1);
25+
holey_double[0] = 0.1; // HOLEY_DOUBLE_ELEMENTS
26+
27+
%OptimizeFunctionOnNextCall(f0);
28+
f0(holey_double, holey_double);
29+
}
30+
main();
31+
main();

0 commit comments

Comments
 (0)