Update the exception handling support to the current proposal

This commit is contained in:
Volker Berlin 2021-02-27 22:22:24 +01:00
parent cf7e66901d
commit d3261149e6
3 changed files with 11 additions and 10 deletions

View File

@ -1342,6 +1342,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
case CATCH:
if( options.useEH() ) {
codeStream.writeOpCode( CATCH );
codeStream.writeVaruint32( (Integer)data );
} else {
codeStream.writeOpCode( BR );
codeStream.writeVaruint32( 0 );

View File

@ -978,7 +978,7 @@ class BranchManger {
parent.add( tryNode );
calculate( tryNode, parsedOperations.subList( 0, idx ) );
BranchNode catchNode = new BranchNode( catchPos, endPos, WasmBlockOperator.CATCH, WasmBlockOperator.END );
BranchNode catchNode = new BranchNode( catchPos, endPos, WasmBlockOperator.CATCH, WasmBlockOperator.END, 0 );
parent.add( catchNode );
// Create a block/end structure for every CATCH without the first CATCH
@ -1097,14 +1097,14 @@ class BranchManger {
catchNode.add( 0, unBoxing );
return;
}
AnyType excepType = getCatchType( tryCatch );
BlockType blockType = options.types.blockType( Arrays.asList( ValueType.exnref ), Arrays.asList( excepType ) );
BranchNode unBoxing = new BranchNode( catchPos, catchPos, WasmBlockOperator.BLOCK, WasmBlockOperator.END, blockType );
catchNode.add( 0, unBoxing );
//TODO localVariables.getTempVariable( ValueType.exnref, catchPos, endPos ); https://github.com/WebAssembly/wabt/issues/1388
unBoxing.add( new BranchNode( catchPos, catchPos, WasmBlockOperator.BR_ON_EXN, null, 0 ) );
unBoxing.add( new BranchNode( catchPos, catchPos, WasmBlockOperator.RETHROW, null ) );
// AnyType excepType = getCatchType( tryCatch );
// BlockType blockType = options.types.blockType( Arrays.asList( ValueType.exnref ), Arrays.asList( excepType ) );
// BranchNode unBoxing = new BranchNode( catchPos, catchPos, WasmBlockOperator.BLOCK, WasmBlockOperator.END, blockType );
// catchNode.add( 0, unBoxing );
//
// //TODO localVariables.getTempVariable( ValueType.exnref, catchPos, endPos ); https://github.com/WebAssembly/wabt/issues/1388
// unBoxing.add( new BranchNode( catchPos, catchPos, WasmBlockOperator.BR_ON_EXN, null, 0 ) );
// unBoxing.add( new BranchNode( catchPos, catchPos, WasmBlockOperator.RETHROW, null ) );
}
private AnyType getCatchType( TryCatchFinally tryCatch ) {

View File

@ -831,7 +831,7 @@ public class TextModuleWriter extends ModuleWriter {
break;
case CATCH:
inset--;
name = options.useEH() ? "catch" : "br 0";
name = options.useEH() ? "catch " + data : "br 0";
insetAfter++;
break;
case THROW: