asm-js / validator

A reference validator for asm.js.
Apache License 2.0
1.78k stars 148 forks source link

Unsigned conversion is lost when passing to external functions #48

Closed jlongster closed 11 years ago

jlongster commented 11 years ago

I might be missing something, but I would expect to see 4294967295 and not -1 in the following test case. It appears the the unsigned conversion (-1 >>> 0) is lost if it's passed directly to an external function. It works fine if you assign it to a variable first.


function asmModule(global, env, buffer) {
    "use asm";

    var U4 = new global.Uint32Array(buffer);
    var print = env.print;

    function foo() {
         // outputs -1, but if we assign this to a variable and print it we get the expected 4294967295
        print(-1 >>> 0);
    }

    return { foo: foo };
}

var fast = asmModule(
    this, 
    { print: function(x) { print(x); } },
    new ArrayBuffer(1024*8)
);

fast.foo();
jlongster commented 11 years ago

The thing that's most disconcerting is that it behaves correctly as normal javascript, so the semantics differ, which smells like a bug.

kripken commented 11 years ago

Looks like a bug in odinmonkey, please file an issue on odinmonkey (js engine on bugzilla) where luke will see it.

jlongster commented 11 years ago

ok, done

https://bugzilla.mozilla.org/show_bug.cgi?id=854396