bec49d81df
Changes the Array(Includes|IndexOf)(Holey|Packed)Doubles builtins to first check the input array is not empty before attempting to cast it to a FixedDoubleArray as an empty array of doubles can be backed by a FixedArray. Bug: chromium:1004061 Change-Id: I12f302afa9596fb8a5581849662cd67fcc06f92b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1806676 Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Commit-Queue: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#63794}
56 lines
1.2 KiB
JavaScript
56 lines
1.2 KiB
JavaScript
// Copyright 2019 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 testPackedDoublesIncludes() {
|
|
arr = [1.5, 2.5];
|
|
arr.length = 0;
|
|
function f() {
|
|
return arr.includes(1);
|
|
};
|
|
%PrepareFunctionForOptimization(f);
|
|
assertEquals(f(), false);
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals(f(), false);
|
|
})();
|
|
|
|
(function testHoleyDoublesIncludes() {
|
|
arr = [1.1];
|
|
arr[3]= 1.5;
|
|
arr.length = 0;
|
|
function f() {
|
|
return arr.includes(1);
|
|
};
|
|
%PrepareFunctionForOptimization(f);
|
|
assertEquals(f(), false);
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals(f(), false);
|
|
})();
|
|
|
|
(function testPackedDoublesIndexOf() {
|
|
arr = [1.5, 2.5];
|
|
arr.length = 0;
|
|
function f() {
|
|
return arr.indexOf(1);
|
|
};
|
|
%PrepareFunctionForOptimization(f);
|
|
assertEquals(f(), -1);
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals(f(), -1);
|
|
})();
|
|
|
|
(function testHoleyDoublesIndexOf() {
|
|
arr = [1.1];
|
|
arr[3]= 1.5;
|
|
arr.length = 0;
|
|
function f() {
|
|
return arr.indexOf(1);
|
|
};
|
|
%PrepareFunctionForOptimization(f);
|
|
assertEquals(f(), -1);
|
|
%OptimizeFunctionOnNextCall(f);
|
|
assertEquals(f(), -1);
|
|
})();
|