PR-URL: https://github.com/nodejs/node/pull/47251 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
35 lines
778 B
JavaScript
35 lines
778 B
JavaScript
// Copyright 2023 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: --allow-natives-syntax
|
|
|
|
function f() { this.x = 1; }
|
|
for (var i = 0; i < 10; i++) new f();
|
|
|
|
function foo() {
|
|
var obj = new f();
|
|
obj.y = -1073741825;
|
|
return obj;
|
|
}
|
|
|
|
function bar(t) {
|
|
var arr = [];
|
|
for (var p in t){
|
|
arr.push([ t[p]]);
|
|
}
|
|
return arr;
|
|
}
|
|
|
|
function test() {
|
|
return bar(foo());
|
|
}
|
|
|
|
%PrepareFunctionForOptimization(f);
|
|
%PrepareFunctionForOptimization(foo);
|
|
%PrepareFunctionForOptimization(bar);
|
|
%PrepareFunctionForOptimization(test);
|
|
assertEquals([[1], [-1073741825]], test(foo, bar));
|
|
%OptimizeFunctionOnNextCall(test);
|
|
assertEquals([[1], [-1073741825]], test(foo, bar));
|