blob: b50038e1e68c2249fd274b36e6e5cd8fff396c02 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Flags: --allow-natives-syntax
6
7function assertDoubleBits(hi, lo, x) {
8 hi = hi | 0;
9 lo = lo | 0;
Ben Murdoch61f157c2016-09-16 13:49:30 +010010 assertEquals(x, %ConstructDouble(hi, lo));
Ben Murdochb8a8cc12014-11-26 15:28:44 +000011 assertEquals(hi, %_DoubleHi(x));
12 assertEquals(lo, %_DoubleLo(x));
Ben Murdoch61f157c2016-09-16 13:49:30 +010013 assertEquals(x, %ConstructDouble(%_DoubleHi(x), %_DoubleLo(x)));
Ben Murdochb8a8cc12014-11-26 15:28:44 +000014}
15
16
17var tests = [0x7ff00000, 0x00000000, Infinity,
18 0xfff00000, 0x00000000, -Infinity,
19 0x80000000, 0x00000000, -0,
20 0x400921fb, 0x54442d18, Math.PI,
21 0xc00921fb, 0x54442d18, -Math.PI,
22 0x4005bf0a, 0x8b145769, Math.E,
23 0xc005bf0a, 0x8b145769, -Math.E,
24 0xbfe80000, 0x00000000, -0.75];
25
26
27for (var i = 0; i < tests.length; i += 3) {
28 assertDoubleBits(tests[i], tests[i + 1], tests[i + 2]);
29}
30
31%OptimizeFunctionOnNextCall(assertDoubleBits);
32
33for (var i = 0; i < tests.length; i += 3) {
34 assertDoubleBits(tests[i], tests[i + 1], tests[i + 2]);
35 assertOptimized(assertDoubleBits);
36}