improve error handling in the BranchManager

This commit is contained in:
Volker Berlin 2020-04-10 13:40:55 +02:00
parent ea2a179161
commit 432168f002

View File

@ -1197,10 +1197,10 @@ class BranchManger {
} }
if( startBlock != null && startBlock.getOperation() == WasmBlockOperator.IF ) { if( startBlock != null && startBlock.getOperation() == WasmBlockOperator.IF ) {
try {
ArrayDeque<AnyType> stack = new ArrayDeque<>(); ArrayDeque<AnyType> stack = new ArrayDeque<>();
stack.push( ValueType.empty ); stack.push( ValueType.empty );
INSTRUCTIONS: INSTRUCTIONS: for( int i = startIdx; i < instructions.size(); i++ ) {
for( int i = startIdx; i < instructions.size(); i++ ) {
WasmInstruction instr = instructions.get( i ); WasmInstruction instr = instructions.get( i );
int codePos = instr.getCodePosition(); int codePos = instr.getCodePosition();
if( codePos >= endPos ) { if( codePos >= endPos ) {
@ -1233,6 +1233,9 @@ class BranchManger {
} }
} }
startBlock.setData( stack.pop() ); startBlock.setData( stack.pop() );
} catch( Throwable th ) {
throw WasmException.create( th, startBlock.getLineNumber() );
}
} }
} }