convert try/catch to block/br 0 if exception handling is disabled

This commit is contained in:
Volker Berlin 2020-04-13 12:01:21 +02:00
parent cbf27fdfa6
commit 02f41dd52a
2 changed files with 9 additions and 4 deletions

View File

@ -1302,11 +1302,16 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
codeStream.writeOpCode( UNREACHABLE );
break;
case TRY:
codeStream.writeOpCode( TRY );
codeStream.writeOpCode( options.useEH() ? TRY : BLOCK );
codeStream.writeValueType( ValueType.empty ); // void; the return type of the try. currently we does not use it
break;
case CATCH:
codeStream.writeOpCode( CATCH );
if( options.useEH() ) {
codeStream.writeOpCode( CATCH );
} else {
codeStream.writeOpCode( BR );
codeStream.writeVaruint32( 0 );
}
break;
case THROW:
if( options.useEH() ) {

View File

@ -768,12 +768,12 @@ public class TextModuleWriter extends ModuleWriter {
name = "unreachable";
break;
case TRY:
name = "try";
name = options.useEH() ? "try" : "block";
insetAfter++;
break;
case CATCH:
inset--;
name = "catch";
name = options.useEH() ? "catch" : "br 0";
insetAfter++;
break;
case THROW: