it would effectively make a js -> asm.js compiler
Using previous runs to inform the JIT of expected types is entirely reasonable though, and think various JS implementations already do this.
none of that should matter. if the resulting JIT'd code is faster with the traps than the plain js without them, so be it.
I don't know how desirable it would be - you'd be shifting the burden from the compiler to the network, basically.
In particular, you'd still have to compile it, which means that all you're gaining is the time before JIT decides that the code's super hot.
A nicer approach might be like Oracle hints - you have a small comment you place above a function that tells the JIT how you want it compiled. You test your software using an instrumented browser, and that adds the comments between you finishing and it running.
It kinda ups the complexity by loads, though - and I bet the benefits would be relatively small. Stuff like minifying and compressed assets has really tangible benefits, but here you have something that can easily be done wrong, and really only improves the execution of a very small overall percentage of functions.
After a while, if a chunk of code is identified as "hot", a second-stage compilation kicks in. The code is recompiled to optimized machine code that takes advantage of the types that it previously saw the code use (with fallbacks in case those assumptions later fail).