2015-06-19 13:23:56 +02:00
|
|
|
// Copyright 2015 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.
|
|
|
|
|
2022-09-21 13:28:42 +02:00
|
|
|
// Flags: --allow-natives-syntax --no-always-turbofan
|
2015-06-19 13:23:56 +02:00
|
|
|
|
2015-11-30 21:22:40 -08:00
|
|
|
function literals_sharing_test(warmup, optimize) {
|
|
|
|
function closure() {
|
|
|
|
// Ensure small array literals start in specific element kind mode.
|
2017-09-12 11:34:59 +02:00
|
|
|
assertTrue(%HasSmiElements([]));
|
|
|
|
assertTrue(%HasSmiElements([1]));
|
2019-08-16 11:32:46 +02:00
|
|
|
assertTrue(%HasSmiElements([1, 2]));
|
2017-09-12 11:34:59 +02:00
|
|
|
assertTrue(%HasDoubleElements([1.1]));
|
2019-08-16 11:32:46 +02:00
|
|
|
assertTrue(%HasDoubleElements([1.1, 2]));
|
2015-11-30 21:22:40 -08:00
|
|
|
|
|
|
|
var a = [1, 2, 3];
|
|
|
|
if (warmup) {
|
|
|
|
// Transition elements kind during warmup...
|
2017-09-12 11:34:59 +02:00
|
|
|
assertTrue(%HasSmiElements(a));
|
2015-11-30 21:22:40 -08:00
|
|
|
assertEquals(4, a.push(1.3));
|
|
|
|
}
|
|
|
|
// ... and ensure that the information about transitioning is
|
|
|
|
// propagated to the next closure.
|
2017-09-12 11:34:59 +02:00
|
|
|
assertTrue(%HasDoubleElements(a));
|
2015-11-30 21:22:40 -08:00
|
|
|
};
|
2019-08-16 11:32:46 +02:00
|
|
|
%PrepareFunctionForOptimization(closure);
|
|
|
|
;
|
2019-08-01 08:38:30 +02:00
|
|
|
%EnsureFeedbackVectorForFunction(closure);
|
2015-11-30 21:22:40 -08:00
|
|
|
if (optimize) %OptimizeFunctionOnNextCall(closure);
|
|
|
|
closure();
|
2015-06-19 13:23:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-30 21:22:40 -08:00
|
|
|
function test() {
|
|
|
|
var warmup = true;
|
|
|
|
for (var i = 0; i < 3; i++) {
|
2019-08-16 11:32:46 +02:00
|
|
|
print('iter: ' + i + ', warmup: ' + warmup);
|
2015-11-30 21:22:40 -08:00
|
|
|
literals_sharing_test(warmup, false);
|
|
|
|
warmup = false;
|
|
|
|
}
|
|
|
|
print("iter: " + i + ", opt: true");
|
|
|
|
literals_sharing_test(warmup, true);
|
|
|
|
}
|
2015-06-19 13:23:56 +02:00
|
|
|
|
2017-05-02 10:50:00 +02:00
|
|
|
test();
|