2015-04-30 12:34:02 +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.
|
|
|
|
|
2020-06-03 20:17:51 +00:00
|
|
|
// The flags are processed left to right. --no-abort-on-contradictory-flags
|
|
|
|
// disables the checking for conflicts, then we process --noverify-heap and
|
|
|
|
// --noenable-slow-asserts, which the test runner already set to true before.
|
|
|
|
// This causes the flags to be overwritten while silencing the error. Then we
|
|
|
|
// re-enable --abort-on-contradictory-flags to make sure that the processing of
|
|
|
|
// other flags and flag implications, which happens later, still produces
|
|
|
|
// errors.
|
|
|
|
// Flags: --no-abort-on-contradictory-flags --noverify-heap --noenable-slow-asserts --abort-on-contradictory-flags
|
|
|
|
// Flags: --allow-natives-syntax --opt --no-always-opt
|
2015-04-30 12:34:02 +00:00
|
|
|
|
2017-01-26 17:39:09 +00:00
|
|
|
// --noverify-heap and --noenable-slow-asserts are set because the test is too
|
|
|
|
// slow with it on.
|
2015-04-30 12:34:02 +00:00
|
|
|
|
2017-01-26 17:39:09 +00:00
|
|
|
// Ensure that keyed stores work, and optimized functions learn if the
|
|
|
|
// store required change to dictionary mode. Verify that stores that grow
|
|
|
|
// the array into large object space don't cause a deopt.
|
2015-04-30 12:34:02 +00:00
|
|
|
(function() {
|
|
|
|
var a = [];
|
|
|
|
|
|
|
|
function foo(a, i) {
|
|
|
|
a[i] = 5.3;
|
|
|
|
}
|
|
|
|
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2015-04-30 12:34:02 +00:00
|
|
|
foo(a, 1);
|
|
|
|
foo(a, 2);
|
|
|
|
foo(a, 3);
|
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
a[3] = 0;
|
|
|
|
foo(a, 3);
|
|
|
|
assertEquals(a[3], 5.3);
|
|
|
|
foo(a, 50000);
|
|
|
|
assertUnoptimized(foo);
|
|
|
|
assertTrue(%HasDictionaryElements(a));
|
|
|
|
|
2019-05-03 14:32:12 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2015-04-30 12:34:02 +00:00
|
|
|
var b = [];
|
|
|
|
foo(b, 1);
|
|
|
|
foo(b, 2);
|
|
|
|
// Put b in dictionary mode.
|
|
|
|
b[10000] = 5;
|
|
|
|
assertTrue(%HasDictionaryElements(b));
|
|
|
|
foo(b, 3);
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(foo);
|
2015-04-30 12:34:02 +00:00
|
|
|
%OptimizeFunctionOnNextCall(foo);
|
|
|
|
foo(b, 50000);
|
|
|
|
assertOptimized(foo);
|
|
|
|
assertTrue(%HasDictionaryElements(b));
|
|
|
|
|
|
|
|
// Clearing feedback for the StoreIC in foo is important for runs with
|
|
|
|
// flag --stress-opt.
|
2017-02-14 15:53:34 +00:00
|
|
|
%ClearFunctionFeedback(foo);
|
2015-04-30 12:34:02 +00:00
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
var a = new Array(10);
|
|
|
|
|
|
|
|
function foo2(a, i) {
|
|
|
|
a[i] = 50;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The KeyedStoreIC will learn GROW_MODE.
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(foo2);
|
2015-04-30 12:34:02 +00:00
|
|
|
foo2(a, 10);
|
|
|
|
foo2(a, 12);
|
|
|
|
foo2(a, 31);
|
|
|
|
%OptimizeFunctionOnNextCall(foo2);
|
|
|
|
foo2(a, 40);
|
|
|
|
|
2017-01-26 17:39:09 +00:00
|
|
|
assertOptimized(foo2);
|
2017-06-30 18:00:44 +00:00
|
|
|
assertTrue(%HasSmiElements(a));
|
2017-01-26 15:04:47 +00:00
|
|
|
|
2017-01-26 17:39:09 +00:00
|
|
|
// Grow a large array into large object space through the keyed store
|
2017-04-21 17:31:29 +00:00
|
|
|
// without deoptimizing. Grow by 9s. If we set elements too sparsely, the
|
2017-01-26 17:39:09 +00:00
|
|
|
// array will convert to dictionary mode.
|
|
|
|
a = new Array(99999);
|
2017-06-30 18:00:44 +00:00
|
|
|
assertTrue(%HasSmiElements(a));
|
2017-04-21 17:31:29 +00:00
|
|
|
for (var i = 0; i < 263000; i += 9) {
|
2017-01-26 17:39:09 +00:00
|
|
|
foo2(a, i);
|
2015-04-30 12:34:02 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 17:39:09 +00:00
|
|
|
// Verify that we are over 1 page in size, and foo2 remains optimized.
|
|
|
|
// This means we've smoothly transitioned to allocating in large object
|
|
|
|
// space.
|
2017-06-30 18:00:44 +00:00
|
|
|
assertTrue(%HasSmiElements(a));
|
2017-01-26 17:39:09 +00:00
|
|
|
assertTrue(a.length * 4 > (1024 * 1024));
|
|
|
|
assertOptimized(foo2);
|
|
|
|
|
2017-02-14 15:53:34 +00:00
|
|
|
%ClearFunctionFeedback(foo2);
|
2015-04-30 12:34:02 +00:00
|
|
|
})();
|