mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
[EH] Replace event with tag https://github.com/WebAssembly/exception-handling/pull/161
This commit is contained in:
parent
0ef00ba2ab
commit
1bfe16b17b
@ -132,7 +132,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
writeSection( SectionType.Function, functions.values() );
|
writeSection( SectionType.Function, functions.values() );
|
||||||
writeTableSection();
|
writeTableSection();
|
||||||
writeMemorySection();
|
writeMemorySection();
|
||||||
writeEventSection();
|
writeTagSection();
|
||||||
writeSection( SectionType.Global, globals.values() );
|
writeSection( SectionType.Global, globals.values() );
|
||||||
writeSection( SectionType.Export, exports );
|
writeSection( SectionType.Export, exports );
|
||||||
writeStartSection();
|
writeStartSection();
|
||||||
@ -238,21 +238,21 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the event section if needed.
|
* Write the tag section if needed.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* if any I/O error occur
|
* if any I/O error occur
|
||||||
*/
|
*/
|
||||||
private void writeEventSection() throws IOException {
|
private void writeTagSection() throws IOException {
|
||||||
if( exceptionSignatureIndex >= 0 ) {
|
if( exceptionSignatureIndex >= 0 ) {
|
||||||
WasmOutputStream stream = new WasmOutputStream( options );
|
WasmOutputStream stream = new WasmOutputStream( options );
|
||||||
stream.writeVaruint32( 1 );
|
stream.writeVaruint32( 1 );
|
||||||
|
|
||||||
// event declaration
|
// tag declaration
|
||||||
stream.writeVaruint32( 0 ); // event type: exception = 0
|
stream.writeVaruint32( 0 ); // tag type: exception = 0
|
||||||
stream.writeVaruint32( exceptionSignatureIndex );
|
stream.writeVaruint32( exceptionSignatureIndex );
|
||||||
|
|
||||||
wasm.writeSection( SectionType.Event, stream );
|
wasm.writeSection( SectionType.Tag, stream );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1351,7 +1351,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
case THROW:
|
case THROW:
|
||||||
if( options.useEH() ) {
|
if( options.useEH() ) {
|
||||||
codeStream.writeOpCode( THROW );
|
codeStream.writeOpCode( THROW );
|
||||||
codeStream.writeVaruint32( 0 ); // event/exception ever 0 because currently there is only one with signature anyref
|
codeStream.writeVaruint32( 0 ); // tag/exception ever 0 because currently there is only one with signature anyref
|
||||||
} else {
|
} else {
|
||||||
codeStream.writeOpCode( UNREACHABLE );
|
codeStream.writeOpCode( UNREACHABLE );
|
||||||
}
|
}
|
||||||
@ -1363,7 +1363,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
if( options.useEH() ) {
|
if( options.useEH() ) {
|
||||||
codeStream.writeOpCode( BR_ON_EXN );
|
codeStream.writeOpCode( BR_ON_EXN );
|
||||||
codeStream.writeVaruint32( (Integer)data ); // break depth
|
codeStream.writeVaruint32( (Integer)data ); // break depth
|
||||||
codeStream.writeVaruint32( 0 ); // event/exception ever 0 because currently there is only one with signature anyref
|
codeStream.writeVaruint32( 0 ); // tag/exception ever 0 because currently there is only one with signature anyref
|
||||||
} else {
|
} else {
|
||||||
codeStream.writeOpCode( UNREACHABLE );
|
codeStream.writeOpCode( UNREACHABLE );
|
||||||
}
|
}
|
||||||
|
@ -26,5 +26,5 @@ enum ExternalKind {
|
|||||||
Table,
|
Table,
|
||||||
Memory,
|
Memory,
|
||||||
Global,
|
Global,
|
||||||
Event,
|
Tag,
|
||||||
}
|
}
|
||||||
|
@ -32,5 +32,5 @@ enum SectionType {
|
|||||||
Code, // 10 Function bodies (code)
|
Code, // 10 Function bodies (code)
|
||||||
Data, // 11 Data segments
|
Data, // 11 Data segments
|
||||||
DataCount,//12 Count of data segments https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
|
DataCount,//12 Count of data segments https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
|
||||||
Event, // 13 Event declarations, Exceptions
|
Tag, // 13 Tag declarations, Exceptions
|
||||||
}
|
}
|
||||||
|
@ -277,9 +277,9 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
inset = 1;
|
inset = 1;
|
||||||
newline( output );
|
newline( output );
|
||||||
if( options.useGC() ) {
|
if( options.useGC() ) {
|
||||||
output.append( "(event (param (ref null $java/lang/Throwable)))" );
|
output.append( "(tag (param (ref null $java/lang/Throwable)))" );
|
||||||
} else {
|
} else {
|
||||||
output.append( "(event (param externref))" );
|
output.append( "(tag (param externref))" );
|
||||||
}
|
}
|
||||||
inset = oldInset;
|
inset = oldInset;
|
||||||
}
|
}
|
||||||
@ -851,13 +851,13 @@ public class TextModuleWriter extends ModuleWriter {
|
|||||||
insetAfter++;
|
insetAfter++;
|
||||||
break;
|
break;
|
||||||
case THROW:
|
case THROW:
|
||||||
name = options.useEH() ? "throw 0" : "unreachable"; // currently there is only one event/exception with externref
|
name = options.useEH() ? "throw 0" : "unreachable"; // currently there is only one tag/exception with externref
|
||||||
break;
|
break;
|
||||||
case RETHROW:
|
case RETHROW:
|
||||||
name = "rethrow";
|
name = "rethrow";
|
||||||
break;
|
break;
|
||||||
case BR_ON_EXN:
|
case BR_ON_EXN:
|
||||||
name = options.useEH() ? "br_on_exn " + data + " 0" : "unreachable"; // br_on_exn, break depth, event; // currently there is only one event/exception with externref
|
name = options.useEH() ? "br_on_exn " + data + " 0" : "unreachable"; // br_on_exn, break depth, tag; // currently there is only one tag/exception with externref
|
||||||
break;
|
break;
|
||||||
case MONITOR_ENTER:
|
case MONITOR_ENTER:
|
||||||
case MONITOR_EXIT:
|
case MONITOR_EXIT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user