nodejs/deps/v8/test/mjsunit/maglev/no-deopt-deprecated-map.js
Michaël Zasso 918fe04351
deps: update V8 to 13.6.233.8
PR-URL: https://github.com/nodejs/node/pull/58070
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2025-05-02 15:06:53 +02:00

42 lines
1.0 KiB
JavaScript

// Copyright 2024 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Flags: --maglev --allow-natives-syntax
// Flags: --no-optimize-maglev-optimizes-to-turbofan
// This object will later have a deprecated map.
let o1 = {y: 0, a: 1};
// These 2 objects will always have the same map. We use two
// of them to make sure we're not embedding the object itself
// as a constant.
let o2_1 = {y: 0, a: 1};
let o2_2 = {y: 0, a: 1};
// An unrelated object just to make the IC polymorphic.
let o3 = {x: 0, y: 0, a: 1};
// Make o1's map deprecated. o2_1 and o2_2 have the same map.
o2_1.a = 3.1415;
o2_2.a = 4.12;
function foo(o) {
o.y = 2; // Polymorpic property store.
}
%PrepareFunctionForOptimization(foo);
// Collect the feedback.
foo(o2_1);
foo(o2_2);
foo(o3); // Make it polymorphic.
%OptimizeMaglevOnNextCall(foo);
foo(o2_1);
assertTrue(isMaglevved(foo));
// Calling foo with a deprecated map should not deopt.
foo(o1);
assertTrue(isMaglevved(foo));