2017-02-07 20:43:17 +00:00
|
|
|
// Copyright 2016 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-context-specialization
|
|
|
|
|
|
|
|
function f(n) {
|
|
|
|
var a = [];
|
2019-06-12 14:00:50 +00:00
|
|
|
function g() {
|
|
|
|
return x;
|
|
|
|
};
|
2017-02-07 20:43:17 +00:00
|
|
|
for (var i = 0; i < n; ++i) {
|
|
|
|
var x = i;
|
|
|
|
a[i] = g;
|
2019-06-14 16:27:09 +00:00
|
|
|
%PrepareFunctionForOptimization(g);
|
2017-02-07 20:43:17 +00:00
|
|
|
%OptimizeFunctionOnNextCall(g);
|
|
|
|
g();
|
|
|
|
}
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
var a = f(3);
|
|
|
|
assertEquals(3, a.length);
|
|
|
|
assertEquals(2, a[0]());
|
|
|
|
assertEquals(2, a[1]());
|
|
|
|
assertEquals(2, a[2]());
|