mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:17:42 +00:00
LibWasm+LibWeb: Sneak a JS::Completion into Wasm::Result
Imported functions in Wasm may throw JS exceptions, and we need to preserve these exceptions so we can pass them to the calling JS code. This also adds a `assert_wasm_result()` API to Result for cases where only Wasm traps or values are expected (e.g. internal uses) to avoid making LibWasm (pointlessly) handle JS exceptions that will never show up in reality.
This commit is contained in:
parent
1c3050245e
commit
6b50f23242
11 changed files with 95 additions and 35 deletions
|
@ -175,7 +175,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
entry.expression(),
|
||||
1,
|
||||
});
|
||||
auto result = config.execute(interpreter);
|
||||
auto result = config.execute(interpreter).assert_wasm_result();
|
||||
if (result.is_trap())
|
||||
instantiation_result = InstantiationError { DeprecatedString::formatted("Global value construction trapped: {}", result.trap().reason) };
|
||||
else
|
||||
|
@ -202,7 +202,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
entry,
|
||||
entry.instructions().size(),
|
||||
});
|
||||
auto result = config.execute(interpreter);
|
||||
auto result = config.execute(interpreter).assert_wasm_result();
|
||||
if (result.is_trap()) {
|
||||
instantiation_result = InstantiationError { DeprecatedString::formatted("Element construction trapped: {}", result.trap().reason) };
|
||||
return IterationDecision::Continue;
|
||||
|
@ -255,7 +255,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
active_ptr->expression,
|
||||
1,
|
||||
});
|
||||
auto result = config.execute(interpreter);
|
||||
auto result = config.execute(interpreter).assert_wasm_result();
|
||||
if (result.is_trap()) {
|
||||
instantiation_result = InstantiationError { DeprecatedString::formatted("Element section initialisation trapped: {}", result.trap().reason) };
|
||||
return IterationDecision::Break;
|
||||
|
@ -315,7 +315,7 @@ InstantiationResult AbstractMachine::instantiate(Module const& module, Vector<Ex
|
|||
data.offset,
|
||||
1,
|
||||
});
|
||||
auto result = config.execute(interpreter);
|
||||
auto result = config.execute(interpreter).assert_wasm_result();
|
||||
if (result.is_trap()) {
|
||||
instantiation_result = InstantiationError { DeprecatedString::formatted("Data section initialisation trapped: {}", result.trap().reason) };
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue