Skip to content

Commit

Permalink
Remove allocation form __cxa_find_matching_catch
Browse files Browse the repository at this point in the history
Turns out this is a pointer that is only used locally so I guess
we can just stackAlloc it?

Fixes: #12226
  • Loading branch information
sbc100 committed Sep 15, 2020
1 parent ee7fc55 commit 8e5e911
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/library_exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
var LibraryExceptions = {
$exceptionLast: '0',
$exceptionCaught: ' []',
$exceptionThrowBuf: '0',

// Static fields for ExceptionInfo class.
$ExceptionInfoAttrs: {
Expand Down Expand Up @@ -396,7 +395,7 @@ var LibraryExceptions = {
// unwinding using 'if' blocks around each function, so the remaining
// functionality boils down to picking a suitable 'catch' block.
// We'll do that here, instead, to keep things simpler.
__cxa_find_matching_catch__deps: ['$exceptionLast', '$ExceptionInfo', '$CatchInfo', '__resumeException', '$exceptionThrowBuf'],
__cxa_find_matching_catch__deps: ['$exceptionLast', '$ExceptionInfo', '$CatchInfo', '__resumeException'],
__cxa_find_matching_catch: function() {
var thrown = exceptionLast;
if (!thrown) {
Expand All @@ -417,9 +416,8 @@ var LibraryExceptions = {
#if EXCEPTION_DEBUG
out("can_catch on " + [thrown]);
#endif
if (!exceptionThrowBuf) {
exceptionThrowBuf = _malloc(4);
}
var stackTop = stackSave();
var exceptionThrowBuf = stackAlloc(4);
{{{ makeSetValue('exceptionThrowBuf', '0', 'thrown', '*') }}};
// The different catch blocks are denoted by different types.
// Due to inheritance, those types may not precisely match the
Expand All @@ -442,6 +440,7 @@ var LibraryExceptions = {
{{{ makeStructuralReturn(['catchInfo.ptr', 'caughtType']) }}};
}
}
stackRestore(stackTop);
{{{ makeStructuralReturn(['catchInfo.ptr', 'thrownType']) }}};
},

Expand Down

0 comments on commit 8e5e911

Please sign in to comment.