@@ -687,12 +687,11 @@ def make_invoke(sig, named=True):
687687 args = ['index' ] + ['a' + str (i ) for i in range (1 , len (legal_sig ))]
688688 ret = 'return ' if sig [0 ] != 'v' else ''
689689 body = '%s%s;' % (ret , JS .make_dynCall (sig , args ))
690- # C++ exceptions are numbers, and longjmp is a string 'longjmp'
691- if settings .SUPPORT_LONGJMP :
692- rethrow = "if (e !== e+0 && e !== 'longjmp') throw e;"
693- else :
694- rethrow = "if (e !== e+0) throw e;"
695-
690+ # Exceptions thrown from C++ exception will be integer numbers.
691+ # longjmp will throw the number Infinity.
692+ # Create a try-catch guard that rethrows the exception if anything else
693+ # than a Number was thrown. To do that quickly and in a code size conserving
694+ # manner, use the compact test "e !== e+0" to check if e was not a Number.
696695 name = (' invoke_' + sig ) if named else ''
697696 ret = '''\
698697 function%s(%s) {
@@ -701,10 +700,10 @@ def make_invoke(sig, named=True):
701700 %s
702701 } catch(e) {
703702 stackRestore(sp);
704- %s
703+ if (e !== e+0) throw e;
705704 _setThrew(1, 0);
706705 }
707- }''' % (name , ',' .join (args ), body , rethrow )
706+ }''' % (name , ',' .join (args ), body )
708707
709708 return ret
710709
0 commit comments