00f7d1f5f8
By now only the default %TypedArray%.prototype.sort compare function and the JS implementation of SameValueZero were still using the odd %_IsMinusZero intrinsic, whose semantics both included a number check (actually HeapNumber test) plus testing if the heap number stores the special -0 value. In both cases we already know that we deal with number so we can reduce it to a simple number test for -0, which can be expressed via dividing 1 by that value and checking the sign of the result. In case of the compare function, we can be even smarter and work with the reciprocal values in case x and y are equal to 0 (although long term we should probably rewrite the fast case for the typed array sorting function in C++ anyway, which will be way, way faster than our handwritten callback-style, type-feedback polluted JS implementation). R=yangguo@chromium.org Review URL: https://codereview.chromium.org/1680783002 Cr-Commit-Position: refs/heads/master@{#33833}
36 lines
920 B
JavaScript
36 lines
920 B
JavaScript
// Copyright 2014 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 --fold-constants
|
|
|
|
function test() {
|
|
assertEquals("string", typeof "");
|
|
assertEquals("number", typeof 1.1);
|
|
assertEquals("number", typeof 1);
|
|
assertEquals("boolean", typeof true);
|
|
assertEquals("function", typeof function() {});
|
|
assertEquals("object", typeof null);
|
|
assertEquals("object", typeof {});
|
|
assertEquals("object", typeof /regex/);
|
|
|
|
assertTrue(%_IsSmi(1));
|
|
assertFalse(%_IsSmi(1.1));
|
|
assertFalse(%_IsSmi({}));
|
|
|
|
assertTrue(%_IsRegExp(/regexp/));
|
|
assertFalse(%_IsRegExp({}));
|
|
|
|
assertTrue(%_IsArray([1]));
|
|
assertFalse(%_IsArray(function() {}));
|
|
|
|
assertTrue(%_IsJSReceiver(new Date()));
|
|
assertFalse(%_IsJSReceiver(1));
|
|
}
|
|
|
|
|
|
test();
|
|
test();
|
|
%OptimizeFunctionOnNextCall(test);
|
|
test();
|