asm.js throwing an exception when hitting an emcripten-generated 'true'/'false'

394 views
Skip to first unread message

Joe Bibbo

unread,
Aug 28, 2018, 5:22:20 PM8/28/18
to emscripten-discuss

After successfully building and verifying the functionality of a large C++ library, I was noticing that the code was running slower than expected. The browser was putting up a warning about
the emscripten-generated asm.js "Invalid asm.js: Undefined global variable"  I tracked it down to the asm.js code, and any place that the toolchain
had decided to use use a 'true' or 'false' constant. The browser would complain ( chrome, firefox ).

                  .
                 
.
                 
.
                        c
[(F + 48 | 0) + 8 >> 2] = 674;
                               Kk(0, 0, 184863, F + 48 | 0);
                               Eb()
                           }
                           if (true ? (c[m + 8 >> 2] & 32 | 0) == 0 : 0)
                               if ((d[m + 4 >> 0] | 0) < 2)
                                   a = 36;
                               else
                                   a = 37;
                           else
                               a = 36;

                   
.
                   



Building on mac,
emcc (Emscripten gcc/clang-like replacement) 1.38.5 (commit a4474e59db658cea570c78254fa71119cf688db5)

Any ideas on what I must do to avoid this type of generated code?

Thanks in advance for any help or advice.

Regards,
Joe

Alon Zakai

unread,
Aug 28, 2018, 7:21:47 PM8/28/18
to emscripten-discuss
What options did you compile with? And did you run anything on the JS afterwards?

That code sample looks a little like what closure compiler or another JS minifier might do. In emscripten, building with --closure 2 might lead to similar stuff - but we would disable asm.js validation in that case. If you run a minifier yourself on the output, without disabling that, then an error like this could occur.


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joe Bibbo

unread,
Aug 29, 2018, 8:07:31 AM8/29/18
to emscripten-discuss
Alon,

Brilliant! You are right. I was looking at the output after Webpack got a hold of it.

The output(.js) out of the emscripten tool chain produces clean asmjs code. It is a problem with my packaging tools.

Now, I just a need to figure out how to get Webpack to ignore the embedded asmjs code when merging it. But obviously not an emscripten issue.

Thanks for spotting my problem.

Regards,
Joe

Alon Zakai

unread,
Aug 29, 2018, 10:05:25 AM8/29/18
to emscripten-discuss
Cool, glad that was it.

Btw, the --separate-asm option might help here, it emits the asm.js in another file. Another option, if speed is not that important, is to disable asm.js validation (-s ASM_JS=0).

Reply all
Reply to author
Forward
0 new messages