1// Copyright 2015 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 7var stdlib = this; 8var foreign = {}; 9var heap = new ArrayBuffer(64 * 1024); 10 11 12var m = (function(stdlib, foreign, heap) { 13 "use asm"; 14 function hi1(i) { 15 i = +i; 16 return %_DoubleHi(i)|0; 17 } 18 function hi2(i, j) { 19 i = +i; 20 j = +j; 21 return %_DoubleHi(i)+%_DoubleHi(j)|0; 22 } 23 return { hi1: hi1, hi2: hi2 }; 24})(stdlib, foreign, heap); 25 26assertEquals(0, m.hi1(0.0)); 27assertEquals(-2147483648, m.hi1(-0.0)); 28assertEquals(2146435072, m.hi1(Infinity)); 29assertEquals(-1048576, m.hi1(-Infinity)); 30assertEquals(0, m.hi2(0.0, 0.0)); 31assertEquals(-2147483648, m.hi2(0.0, -0.0)); 32assertEquals(-2147483648, m.hi2(-0.0, 0.0)); 33assertEquals(0, m.hi2(-0.0, -0.0)); 34for (var i = -2147483648; i < 2147483648; i += 3999773) { 35 assertEquals(%_DoubleHi(i), m.hi1(i)); 36 assertEquals(i, m.hi1(%ConstructDouble(i, 0))); 37 assertEquals(i, m.hi1(%ConstructDouble(i, i))); 38 assertEquals(i+i|0, m.hi2(%ConstructDouble(i, 0), %ConstructDouble(i, 0))); 39 assertEquals(i+i|0, m.hi2(%ConstructDouble(i, i), %ConstructDouble(i, i))); 40} 41