@@ -120,13 +120,15 @@ var LibraryExceptions = {
120120 } ;
121121
122122 this . set_adjusted_ptr = function ( adjustedPtr ) {
123- var ptrSize = { { { Runtime . POINTER_SIZE } } } ;
124- { { { makeSetValue ( 'this.ptr' , 'ptrSize' , 'adjustedPtr' , '*' ) } } } ;
123+ { { { makeSetValue ( 'this.ptr' , Runtime . POINTER_SIZE , 'adjustedPtr' , '*' ) } } } ;
125124 } ;
126125
126+ this . get_adjusted_ptr_addr = function ( ) {
127+ return this . ptr + { { { Runtime . POINTER_SIZE } } } ;
128+ }
129+
127130 this . get_adjusted_ptr = function ( ) {
128- var ptrSize = { { { Runtime . POINTER_SIZE } } } ;
129- return { { { makeGetValue ( 'this.ptr' , 'ptrSize' , '*' ) } } } ;
131+ return { { { makeGetValue ( 'this.ptr' , Runtime . POINTER_SIZE , '*' ) } } } ;
130132 } ;
131133
132134 // Get pointer which is expected to be received by catch clause in C++ code. It may be adjusted
@@ -378,6 +380,7 @@ var LibraryExceptions = {
378380 var thrownType = info . get_type ( ) ;
379381 var catchInfo = new CatchInfo ( ) ;
380382 catchInfo . set_base_ptr ( thrown ) ;
383+ catchInfo . set_adjusted_ptr ( thrown ) ;
381384 if ( ! thrownType ) {
382385 // just pass through the thrown ptr
383386 { { { makeStructuralReturn ( [ 'catchInfo.ptr' , 0 ] ) } } } ;
@@ -388,9 +391,6 @@ var LibraryExceptions = {
388391#if EXCEPTION_DEBUG
389392 out ( "can_catch on " + [ thrown ] ) ;
390393#endif
391- var stackTop = stackSave ( ) ;
392- var exceptionThrowBuf = stackAlloc ( 4 ) ;
393- { { { makeSetValue ( 'exceptionThrowBuf' , '0' , 'thrown' , '*' ) } } } ;
394394 // The different catch blocks are denoted by different types.
395395 // Due to inheritance, those types may not precisely match the
396396 // type of the thrown object. Find one which matches, and
@@ -401,19 +401,13 @@ var LibraryExceptions = {
401401 // Catch all clause matched or exactly the same type is caught
402402 break ;
403403 }
404- if ( { { { exportedAsmFunc ( '___cxa_can_catch' ) } } } ( caughtType , thrownType , exceptionThrowBuf ) ) {
405- var adjusted = { { { makeGetValue ( 'exceptionThrowBuf' , '0' , '*' ) } } } ;
406- if ( thrown !== adjusted ) {
407- catchInfo . set_adjusted_ptr ( adjusted ) ;
408- }
404+ if ( { { { exportedAsmFunc ( '___cxa_can_catch' ) } } } ( caughtType , thrownType , catchInfo . get_adjusted_ptr_addr ( ) ) ) {
409405#if EXCEPTION_DEBUG
410- out ( " can_catch found " + [ adjusted , caughtType ] ) ;
406+ out ( " can_catch found " + [ catchInfo . get_adjusted_ptr ( ) , caughtType ] ) ;
411407#endif
412- stackRestore ( stackTop ) ;
413408 { { { makeStructuralReturn ( [ 'catchInfo.ptr' , 'caughtType' ] ) } } } ;
414409 }
415410 }
416- stackRestore ( stackTop ) ;
417411 { { { makeStructuralReturn ( [ 'catchInfo.ptr' , 'thrownType' ] ) } } } ;
418412 } ,
419413
0 commit comments