mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +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() );
|
||||
writeTableSection();
|
||||
writeMemorySection();
|
||||
writeEventSection();
|
||||
writeTagSection();
|
||||
writeSection( SectionType.Global, globals.values() );
|
||||
writeSection( SectionType.Export, exports );
|
||||
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
|
||||
* if any I/O error occur
|
||||
*/
|
||||
private void writeEventSection() throws IOException {
|
||||
private void writeTagSection() throws IOException {
|
||||
if( exceptionSignatureIndex >= 0 ) {
|
||||
WasmOutputStream stream = new WasmOutputStream( options );
|
||||
stream.writeVaruint32( 1 );
|
||||
|
||||
// event declaration
|
||||
stream.writeVaruint32( 0 ); // event type: exception = 0
|
||||
// tag declaration
|
||||
stream.writeVaruint32( 0 ); // tag type: exception = 0
|
||||
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:
|
||||
if( options.useEH() ) {
|
||||
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 {
|
||||
codeStream.writeOpCode( UNREACHABLE );
|
||||
}
|
||||
@ -1363,7 +1363,7 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
||||
if( options.useEH() ) {
|
||||
codeStream.writeOpCode( BR_ON_EXN );
|
||||
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 {
|
||||
codeStream.writeOpCode( UNREACHABLE );
|
||||
}
|
||||
|
@ -26,5 +26,5 @@ enum ExternalKind {
|
||||
Table,
|
||||
Memory,
|
||||
Global,
|
||||
Event,
|
||||
Tag,
|
||||
}
|
||||
|
@ -32,5 +32,5 @@ enum SectionType {
|
||||
Code, // 10 Function bodies (code)
|
||||
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
|
||||
Event, // 13 Event declarations, Exceptions
|
||||
Tag, // 13 Tag declarations, Exceptions
|
||||
}
|
||||
|
@ -277,9 +277,9 @@ public class TextModuleWriter extends ModuleWriter {
|
||||
inset = 1;
|
||||
newline( output );
|
||||
if( options.useGC() ) {
|
||||
output.append( "(event (param (ref null $java/lang/Throwable)))" );
|
||||
output.append( "(tag (param (ref null $java/lang/Throwable)))" );
|
||||
} else {
|
||||
output.append( "(event (param externref))" );
|
||||
output.append( "(tag (param externref))" );
|
||||
}
|
||||
inset = oldInset;
|
||||
}
|
||||
@ -851,13 +851,13 @@ public class TextModuleWriter extends ModuleWriter {
|
||||
insetAfter++;
|
||||
break;
|
||||
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;
|
||||
case RETHROW:
|
||||
name = "rethrow";
|
||||
break;
|
||||
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;
|
||||
case MONITOR_ENTER:
|
||||
case MONITOR_EXIT:
|
||||
|
Loading…
x
Reference in New Issue
Block a user