2015-06-12 12:36:36 +00: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.
|
|
|
|
|
2017-01-26 17:39:09 +00:00
|
|
|
// Flags: --allow-natives-syntax --no-always-opt
|
2015-06-12 12:36:36 +00:00
|
|
|
|
2015-09-23 08:46:09 +00:00
|
|
|
function literals_sharing_test(warmup, optimize) {
|
|
|
|
function closure() {
|
|
|
|
// Ensure small array literals start in specific element kind mode.
|
2017-06-30 18:00:44 +00:00
|
|
|
assertTrue(%HasSmiElements([]));
|
|
|
|
assertTrue(%HasSmiElements([1]));
|
2019-06-12 14:00:50 +00:00
|
|
|
assertTrue(%HasSmiElements([1, 2]));
|
2017-06-30 18:00:44 +00:00
|
|
|
assertTrue(%HasDoubleElements([1.1]));
|
2019-06-12 14:00:50 +00:00
|
|
|
assertTrue(%HasDoubleElements([1.1, 2]));
|
2015-09-23 08:46:09 +00:00
|
|
|
|
|
|
|
var a = [1, 2, 3];
|
|
|
|
if (warmup) {
|
|
|
|
// Transition elements kind during warmup...
|
2017-06-30 18:00:44 +00:00
|
|
|
assertTrue(%HasSmiElements(a));
|
2015-09-23 08:46:09 +00:00
|
|
|
assertEquals(4, a.push(1.3));
|
|
|
|
}
|
|
|
|
// ... and ensure that the information about transitioning is
|
|
|
|
// propagated to the next closure.
|
2017-06-30 18:00:44 +00:00
|
|
|
assertTrue(%HasDoubleElements(a));
|
2015-09-23 08:46:09 +00:00
|
|
|
};
|
2019-06-12 14:00:50 +00:00
|
|
|
%PrepareFunctionForOptimization(closure);
|
|
|
|
;
|
2019-05-03 14:32:12 +00:00
|
|
|
%EnsureFeedbackVectorForFunction(closure);
|
2015-09-23 08:46:09 +00:00
|
|
|
if (optimize) %OptimizeFunctionOnNextCall(closure);
|
|
|
|
closure();
|
2015-06-12 12:36:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-23 08:46:09 +00:00
|
|
|
function test() {
|
2017-07-12 11:27:10 +00:00
|
|
|
var warmup = true;
|
2015-09-23 08:46:09 +00:00
|
|
|
for (var i = 0; i < 3; i++) {
|
2019-06-12 14:00:50 +00:00
|
|
|
print('iter: ' + i + ', warmup: ' + warmup);
|
2015-09-23 08:46:09 +00:00
|
|
|
literals_sharing_test(warmup, false);
|
2017-07-12 11:27:10 +00:00
|
|
|
warmup = false;
|
2015-09-23 08:46:09 +00:00
|
|
|
}
|
|
|
|
print("iter: " + i + ", opt: true");
|
|
|
|
literals_sharing_test(warmup, true);
|
|
|
|
}
|
2015-06-12 12:36:36 +00:00
|
|
|
|
2017-01-26 17:39:09 +00:00
|
|
|
test();
|