mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +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:
committed by
Ali Mohammad Pur
parent
1c3050245e
commit
6b50f23242
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user