mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 17:51:35 +00:00

PR-URL: https://github.com/nodejs/node/pull/52293 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
34 lines
786 B
JavaScript
34 lines
786 B
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: --const-tracking-let --allow-natives-syntax
|
|
// Flags: --turbofan --no-always-turbofan --maglev --no-stress-maglev
|
|
// Flags: --sparkplug --no-always-sparkplug
|
|
|
|
class A {}
|
|
|
|
var origA = A;
|
|
|
|
function create() {
|
|
return new A();
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(create);
|
|
create();
|
|
|
|
%OptimizeFunctionOnNextCall(create);
|
|
var o1 = create();
|
|
assertOptimized(create);
|
|
assertTrue(o1 instanceof A);
|
|
|
|
// Change what A is.
|
|
var newACalled = false;
|
|
A = function() { newACalled = true; }
|
|
|
|
assertUnoptimized(create);
|
|
var o2 = create();
|
|
assertFalse(o2 instanceof origA);
|
|
assertTrue(o2 instanceof A);
|
|
assertTrue(newACalled);
|