From 1a42e3f266e128c4d50dee6f4d83c13efcfffad8 Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Wed, 22 Oct 2014 11:11:50 -0500 Subject: [PATCH] Bug 1085680 - OdinMonkey: change return type of Math.clz32 to fixnum (r=bbouvier) --HG-- extra : rebase_source : 105e21029b6b1f6eabd23b78fe2caea3ec21bcb7 --- js/src/asmjs/AsmJSValidate.cpp | 2 +- js/src/jit-test/tests/asm.js/testMathLib.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/js/src/asmjs/AsmJSValidate.cpp b/js/src/asmjs/AsmJSValidate.cpp index 7ace79ac5527..3134ac6320ed 100644 --- a/js/src/asmjs/AsmJSValidate.cpp +++ b/js/src/asmjs/AsmJSValidate.cpp @@ -4424,7 +4424,7 @@ CheckMathClz32(FunctionCompiler &f, ParseNode *call, MDefinition **def, Type *ty return f.failf(arg, "%s is not a subtype of intish", argType.toChars()); *def = f.unary(argDef); - *type = Type::Signed; + *type = Type::Fixnum; return true; } diff --git a/js/src/jit-test/tests/asm.js/testMathLib.js b/js/src/jit-test/tests/asm.js/testMathLib.js index af566fbb5691..5c2eb9db462e 100644 --- a/js/src/jit-test/tests/asm.js/testMathLib.js +++ b/js/src/jit-test/tests/asm.js/testMathLib.js @@ -64,11 +64,13 @@ for (n of [-Math.pow(2,31)-1, -Math.pow(2,31), -Math.pow(2,31)+1, -1, 0, 1, Math var f = asmLink(asmCompile('glob', USE_ASM + 'var clz32=glob.Math.clz32; function f(i) { i=i|0; return clz32(i)|0 } return f'), this); for (n of [0, 1, 2, 15, 16, Math.pow(2,31)-1, Math.pow(2,31), Math.pow(2,31)+1, Math.pow(2,32)-1, Math.pow(2,32), Math.pow(2,32)+1]) assertEq(f(n), Math.clz32(n|0)); +assertEq(asmLink(asmCompile('glob', USE_ASM + 'var clz32=glob.Math.clz32; function f(i, j) { i=i|0;j=j|0; return (clz32(i) < (j|0))|0 } return f'), this)(0x1, 30), 0); +assertEq(asmLink(asmCompile('glob', USE_ASM + 'var clz32=glob.Math.clz32; function f(i, j) { i=i|0;j=j|0; return (clz32(i) < (j>>>0))|0 } return f'), this)(0x1, 30), 0); var doubleNumbers = [NaN, Infinity, -Infinity, -10000, -3.4, -0, 0, 3.4, 10000]; var floatNumbers = []; for (var x of doubleNumbers) floatNumbers.push(Math.fround(x)); -var intNumbers = [-Math.pow(2,31), -10000, -3, -1, 0, 3, 10000, Math.pow(2,31)]; +var intNumbers = [-Math.pow(2,31), -10000, -3, -1, 0, 3, 10000, Math.pow(2,31), Math.pow(2,31)+1]; function testBinary(f, g, numbers) { for (n of numbers)