7
7
var LibraryExceptions = {
8
8
$exceptionLast : '0' ,
9
9
$exceptionCaught : ' []' ,
10
+ $exceptionThrowBuf : '0' ,
10
11
11
12
// Static fields for ExceptionInfo class.
12
13
$ExceptionInfoAttrs : {
@@ -395,7 +396,7 @@ var LibraryExceptions = {
395
396
// unwinding using 'if' blocks around each function, so the remaining
396
397
// functionality boils down to picking a suitable 'catch' block.
397
398
// We'll do that here, instead, to keep things simpler.
398
- __cxa_find_matching_catch__deps : [ '$exceptionLast' , '$ExceptionInfo' , '$CatchInfo' , '__resumeException' ] ,
399
+ __cxa_find_matching_catch__deps : [ '$exceptionLast' , '$ExceptionInfo' , '$CatchInfo' , '__resumeException' , '$exceptionThrowBuf' ] ,
399
400
__cxa_find_matching_catch : function ( ) {
400
401
var thrown = exceptionLast ;
401
402
if ( ! thrown ) {
@@ -416,12 +417,10 @@ var LibraryExceptions = {
416
417
#if EXCEPTION_DEBUG
417
418
out ( "can_catch on " + [ thrown ] ) ;
418
419
#endif
419
- #if DISABLE_EXCEPTION_CATCHING == 1
420
- var thrownBuf = 0 ;
421
- #else
422
- var thrownBuf = { { { makeStaticAlloc ( 4 ) } } } ;
423
- #endif
424
- { { { makeSetValue ( 'thrownBuf' , '0' , 'thrown' , '*' ) } } } ;
420
+ if ( ! exceptionThrowBuf ) {
421
+ exceptionThrowBuf = _malloc ( 4 ) ;
422
+ }
423
+ { { { makeSetValue ( 'exceptionThrowBuf' , '0' , 'thrown' , '*' ) } } } ;
425
424
// The different catch blocks are denoted by different types.
426
425
// Due to inheritance, those types may not precisely match the
427
426
// type of the thrown object. Find one which matches, and
@@ -432,8 +431,8 @@ var LibraryExceptions = {
432
431
// Catch all clause matched or exactly the same type is caught
433
432
break ;
434
433
}
435
- if ( { { { exportedAsmFunc ( '___cxa_can_catch' ) } } } ( caughtType , thrownType , thrownBuf ) ) {
436
- var adjusted = { { { makeGetValue ( 'thrownBuf ' , '0' , '*' ) } } } ;
434
+ if ( { { { exportedAsmFunc ( '___cxa_can_catch' ) } } } ( caughtType , thrownType , exceptionThrowBuf ) ) {
435
+ var adjusted = { { { makeGetValue ( 'exceptionThrowBuf ' , '0' , '*' ) } } } ;
437
436
if ( thrown !== adjusted ) {
438
437
catchInfo . set_adjusted_ptr ( adjusted ) ;
439
438
}
0 commit comments