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 ); codeStream.writeOpCode( UNREACHABLE );
break; break;
case TRY: 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 codeStream.writeValueType( ValueType.empty ); // void; the return type of the try. currently we does not use it
break; break;
case CATCH: case CATCH:
codeStream.writeOpCode( CATCH ); if( options.useEH() ) {
codeStream.writeOpCode( CATCH );
} else {
codeStream.writeOpCode( BR );
codeStream.writeVaruint32( 0 );
}
break; break;
case THROW: case THROW:
if( options.useEH() ) { if( options.useEH() ) {

View File

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