@@ -1920,7 +1920,7 @@ void WasmBinaryBuilder::readFunctions() {
19201920 // process body
19211921 assert (breakStack.empty ());
19221922 assert (breakTargetNames.empty ());
1923- assert (delegateTargetNames .empty ());
1923+ assert (exceptionTargetNames .empty ());
19241924 assert (breakStack.empty ());
19251925 assert (expressionStack.empty ());
19261926 assert (controlFlowStack.empty ());
@@ -1930,7 +1930,7 @@ void WasmBinaryBuilder::readFunctions() {
19301930 assert (depth == 0 );
19311931 assert (breakStack.empty ());
19321932 assert (breakTargetNames.empty ());
1933- assert (delegateTargetNames .empty ());
1933+ assert (exceptionTargetNames .empty ());
19341934 if (!expressionStack.empty ()) {
19351935 throwError (" stack not empty on function exit" );
19361936 }
@@ -3389,7 +3389,7 @@ Expression* WasmBinaryBuilder::getBlockOrSingleton(Type type) {
33893389 block->finalize (type);
33903390 // maybe we don't need a block here?
33913391 if (breakTargetNames.find (block->name ) == breakTargetNames.end () &&
3392- delegateTargetNames .find (block->name ) == delegateTargetNames .end ()) {
3392+ exceptionTargetNames .find (block->name ) == exceptionTargetNames .end ()) {
33933393 block->name = Name ();
33943394 if (block->list .size () == 1 ) {
33953395 return block->list [0 ];
@@ -3465,8 +3465,8 @@ WasmBinaryBuilder::getBreakTarget(int32_t offset) {
34653465 return ret;
34663466}
34673467
3468- Name WasmBinaryBuilder::getDelegateTargetName (int32_t offset) {
3469- BYN_TRACE (" getDelegateTarget " << offset << std::endl);
3468+ Name WasmBinaryBuilder::getExceptionTargetName (int32_t offset) {
3469+ BYN_TRACE (" getExceptionTarget " << offset << std::endl);
34703470 // We always start parsing a function by creating a block label and pushing it
34713471 // in breakStack in getBlockOrSingleton, so if a 'delegate''s target is that
34723472 // block, it does not mean it targets that block; it throws to the caller.
@@ -3482,7 +3482,7 @@ Name WasmBinaryBuilder::getDelegateTargetName(int32_t offset) {
34823482 // if the delegate is in literally unreachable code, then we will not emit it
34833483 // anyhow, so do not note that the target has delegate to it
34843484 if (!willBeIgnored) {
3485- delegateTargetNames .insert (ret.name );
3485+ exceptionTargetNames .insert (ret.name );
34863486 }
34873487 return ret.name ;
34883488}
@@ -5832,7 +5832,7 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) {
58325832 breakStack.pop_back ();
58335833
58345834 if (lastSeparator == BinaryConsts::Delegate) {
5835- curr->delegateTarget = getDelegateTargetName (getU32LEB ());
5835+ curr->delegateTarget = getExceptionTargetName (getU32LEB ());
58365836 }
58375837
58385838 // For simplicity, we make try's labels only can be targeted by delegates, and
@@ -5843,21 +5843,22 @@ void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) {
58435843 curr->name = getNextLabel ();
58445844 if (auto * block = curr->body ->dynCast <Block>()) {
58455845 if (block->name .is ()) {
5846- if (delegateTargetNames.find (block->name ) != delegateTargetNames.end ()) {
5847- BranchUtils::replaceDelegateTargets (block, block->name , curr->name );
5848- delegateTargetNames.erase (block->name );
5846+ if (exceptionTargetNames.find (block->name ) !=
5847+ exceptionTargetNames.end ()) {
5848+ BranchUtils::replaceExceptionTargets (block, block->name , curr->name );
5849+ exceptionTargetNames.erase (block->name );
58495850 }
58505851 // maybe we don't need a block here?
58515852 if (block->list .size () == 1 ) {
58525853 curr->body = block->list [0 ];
58535854 }
58545855 }
58555856 }
5856- if (delegateTargetNames .find (catchLabel) != delegateTargetNames .end ()) {
5857+ if (exceptionTargetNames .find (catchLabel) != exceptionTargetNames .end ()) {
58575858 for (auto * catchBody : curr->catchBodies ) {
5858- BranchUtils::replaceDelegateTargets (catchBody, catchLabel, curr->name );
5859+ BranchUtils::replaceExceptionTargets (catchBody, catchLabel, curr->name );
58595860 }
5860- delegateTargetNames .erase (catchLabel);
5861+ exceptionTargetNames .erase (catchLabel);
58615862 }
58625863 curr->finalize (curr->type );
58635864
0 commit comments