516c25b412
This also introduces two new simplified operators, NumberIsFinite and ObjectIsFiniteNumber; the latter handles all values, and the former is a fast-path of the fast-path that is inserted by typed optimization if we know the input has Type::Number. Bug: v8:7340, v8:7250 Change-Id: I1b4812c01bf470bbff40fb3da6e11da543a22cd2 Reviewed-on: https://chromium-review.googlesource.com/951244 Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Cr-Commit-Position: refs/heads/master@{#51980}
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
// 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 test(f) {
|
|
assertTrue(f(0));
|
|
assertTrue(f(Number.MIN_VALUE));
|
|
assertTrue(f(Number.MAX_VALUE));
|
|
assertTrue(f(Number.MIN_SAFE_INTEGER));
|
|
assertTrue(f(Number.MIN_SAFE_INTEGER - 13));
|
|
assertTrue(f(Number.MAX_SAFE_INTEGER));
|
|
assertTrue(f(Number.MAX_SAFE_INTEGER + 23));
|
|
assertTrue(f(0));
|
|
assertTrue(f(-1));
|
|
assertTrue(f(123456));
|
|
assertFalse(f(Number.NaN));
|
|
assertFalse(f(Number.POSITIVE_INFINITY));
|
|
assertFalse(f(Number.NEGATIVE_INFINITY));
|
|
assertFalse(f(1 / 0));
|
|
assertFalse(f(-1 / 0));
|
|
}
|
|
|
|
function f(x) {
|
|
return Number.isFinite(+x);
|
|
}
|
|
|
|
test(f);
|
|
test(f);
|
|
%OptimizeFunctionOnNextCall(f);
|
|
test(f);
|
|
|
|
|
|
function test2(f) {
|
|
assertFalse(f({}));
|
|
assertFalse(f("abc"));
|
|
assertTrue(f(0));
|
|
assertTrue(f(Number.MIN_VALUE));
|
|
assertTrue(f(Number.MAX_VALUE));
|
|
assertTrue(f(Number.MIN_SAFE_INTEGER));
|
|
assertTrue(f(Number.MIN_SAFE_INTEGER - 13));
|
|
assertTrue(f(Number.MAX_SAFE_INTEGER));
|
|
assertTrue(f(Number.MAX_SAFE_INTEGER + 23));
|
|
assertTrue(f(0));
|
|
assertTrue(f(-1));
|
|
assertTrue(f(123456));
|
|
assertFalse(f(Number.NaN));
|
|
assertFalse(f(Number.POSITIVE_INFINITY));
|
|
assertFalse(f(Number.NEGATIVE_INFINITY));
|
|
assertFalse(f(1 / 0));
|
|
assertFalse(f(-1 / 0));
|
|
}
|
|
|
|
function f2(x) {
|
|
return Number.isFinite(x);
|
|
}
|
|
|
|
test2(f2);
|
|
test2(f2);
|
|
%OptimizeFunctionOnNextCall(f2);
|
|
test2(f2);
|