| Index: test/mjsunit/nans.js
|
| diff --git a/test/mjsunit/compiler/property-static.js b/test/mjsunit/nans.js
|
| similarity index 52%
|
| copy from test/mjsunit/compiler/property-static.js
|
| copy to test/mjsunit/nans.js
|
| index 07021340cd7aa94440638f925eeed921ee78c9c7..d212afdeeda250d550bd10462f5a87a9b2e8f663 100644
|
| --- a/test/mjsunit/compiler/property-static.js
|
| +++ b/test/mjsunit/nans.js
|
| @@ -27,43 +27,77 @@
|
|
|
| // Flags: --allow-natives-syntax
|
|
|
| -// Test usage of static type information for loads that would otherwise
|
| -// turn into polymorphic or generic loads.
|
| -
|
| -// Prepare a highly polymorphic load to be used by all tests.
|
| -Object.prototype.load = function() { return this.property; };
|
| -Object.prototype.load.call({ A:0, property:10 });
|
| -Object.prototype.load.call({ A:0, B:0, property:11 });
|
| -Object.prototype.load.call({ A:0, B:0, C:0, property:12 });
|
| -Object.prototype.load.call({ A:0, B:0, C:0, D:0, property:13 });
|
| -Object.prototype.load.call({ A:0, B:0, C:0, D:0, E:0, property:14 });
|
| -Object.prototype.load.call({ A:0, B:0, C:0, D:0, E:0, F:0, property:15 });
|
| -
|
| -// Test for object literals.
|
| -(function() {
|
| - function f(x) {
|
| - var object = { property:x };
|
| - return object.load();
|
| - }
|
|
|
| - assertSame(1, f(1));
|
| - assertSame(2, f(2));
|
| +// Test that both kinds of NaNs (signaling or quiet) do not signal
|
| +
|
| +function TestAllModes(f) {
|
| + f(); // Runtime
|
| + f(); // IC
|
| + f(); // IC second time
|
| %OptimizeFunctionOnNextCall(f);
|
| - assertSame(3, f(3));
|
| -})();
|
| + f(); // hydrogen
|
| +}
|
| +
|
| +function TestDoubleSignalingNan() {
|
| + // NaN with signal bit set
|
| + function f() {
|
| + var bytes = new Uint32Array([1, 0x7FF00000]);
|
| + var doubles = new Float64Array(bytes.buffer);
|
| + assertTrue(isNaN(doubles[0]));
|
| + assertTrue(isNaN(doubles[0]*2.0));
|
| + assertTrue(isNaN(doubles[0] + 0.5));
|
| + }
|
| +
|
| + TestAllModes(f);
|
| +}
|
|
|
| -// Test for inlined constructors.
|
| -(function() {
|
| - function c(x) {
|
| - this.property = x;
|
| +TestDoubleSignalingNan();
|
| +
|
| +function TestDoubleQuietNan() {
|
| + // NaN with signal bit cleared
|
| + function f() {
|
| + var bytes = new Uint32Array([0, 0x7FF80000]);
|
| + var doubles = new Float64Array(bytes.buffer);
|
| + assertTrue(isNaN(doubles[0]));
|
| + assertTrue(isNaN(doubles[0]*2.0));
|
| + assertTrue(isNaN(doubles[0] + 0.5));
|
| }
|
| - function f(x) {
|
| - var object = new c(x);
|
| - return object.load();
|
| +
|
| + TestAllModes(f);
|
| +}
|
| +
|
| +TestDoubleQuietNan();
|
| +
|
| +function TestFloatSignalingNan() {
|
| + // NaN with signal bit set
|
| + function f() {
|
| + var bytes = new Uint32Array([0x7F800001]);
|
| + var floats = new Float32Array(bytes.buffer);
|
| + assertTrue(isNaN(floats[0]));
|
| + assertTrue(isNaN(floats[0]*2.0));
|
| + assertTrue(isNaN(floats[0] + 0.5));
|
| }
|
|
|
| - assertSame(1, f(1));
|
| - assertSame(2, f(2));
|
| - %OptimizeFunctionOnNextCall(f);
|
| - assertSame(3, f(3));
|
| -})();
|
| + TestAllModes(f);
|
| +}
|
| +
|
| +TestFloatSignalingNan();
|
| +
|
| +function TestFloatQuietNan() {
|
| + // NaN with signal bit cleared
|
| + function f() {
|
| + var bytes = new Uint32Array([0x7FC00000]);
|
| + var floats = new Float32Array(bytes.buffer);
|
| + assertTrue(isNaN(floats[0]));
|
| + assertTrue(isNaN(floats[0]*2.0));
|
| + assertTrue(isNaN(floats[0] + 0.5));
|
| + }
|
| +
|
| + TestAllModes(f);
|
| +}
|
| +
|
| +TestFloatQuietNan();
|
| +
|
| +
|
| +
|
| +
|
|
|