From 13dfadba797799f66c2c369cc5fb489c35184c02 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 17 Mar 2023 10:44:47 -0400 Subject: [PATCH] LibJS: Propagate errors from VM creation --- Meta/Lagom/Fuzzers/FuzzJs.cpp | 2 +- Meta/Lagom/Fuzzers/FuzzilliJs.cpp | 2 +- Meta/Lagom/Wasm/js_repl.cpp | 2 +- Tests/LibJS/test-bytecode-js.cpp | 2 +- Tests/LibJS/test262-runner.cpp | 2 +- Userland/Applications/Assistant/Providers.cpp | 2 +- Userland/Applications/Spreadsheet/Workbook.cpp | 2 +- Userland/Libraries/LibJS/Runtime/VM.cpp | 6 +++--- Userland/Libraries/LibJS/Runtime/VM.h | 2 +- Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp | 2 +- Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp | 2 +- Userland/Libraries/LibWeb/HTML/Worker.cpp | 2 +- Userland/Utilities/js.cpp | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Meta/Lagom/Fuzzers/FuzzJs.cpp b/Meta/Lagom/Fuzzers/FuzzJs.cpp index 602a9d52f82..90fe12330df 100644 --- a/Meta/Lagom/Fuzzers/FuzzJs.cpp +++ b/Meta/Lagom/Fuzzers/FuzzJs.cpp @@ -15,7 +15,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size) { auto js = StringView(static_cast(data), size); - auto vm = JS::VM::create(); + auto vm = MUST(JS::VM::create()); auto interpreter = JS::Interpreter::create(*vm); auto parse_result = JS::Script::parse(js, interpreter->realm()); if (!parse_result.is_error()) diff --git a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp index 3cc19f35aed..0ce08ccc665 100644 --- a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp +++ b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp @@ -190,7 +190,7 @@ int main(int, char**) reprl_input = (char*)mmap(0, REPRL_MAX_DATA_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, REPRL_DRFD, 0); VERIFY(reprl_input != MAP_FAILED); - auto vm = JS::VM::create(); + auto vm = MUST(JS::VM::create()); auto interpreter = JS::Interpreter::create(*vm); while (true) { diff --git a/Meta/Lagom/Wasm/js_repl.cpp b/Meta/Lagom/Wasm/js_repl.cpp index 356ef65b4a1..9800037118e 100644 --- a/Meta/Lagom/Wasm/js_repl.cpp +++ b/Meta/Lagom/Wasm/js_repl.cpp @@ -359,7 +359,7 @@ extern "C" int initialize_repl(char const* time_zone) if (time_zone) setenv("TZ", time_zone, 1); - g_vm = JS::VM::create(); + g_vm = MUST(JS::VM::create()); g_vm->enable_default_host_import_module_dynamically_hook(); // NOTE: These will print out both warnings when using something like Promise.reject().catch(...) - diff --git a/Tests/LibJS/test-bytecode-js.cpp b/Tests/LibJS/test-bytecode-js.cpp index e19bdc02c12..57eade2d0d2 100644 --- a/Tests/LibJS/test-bytecode-js.cpp +++ b/Tests/LibJS/test-bytecode-js.cpp @@ -13,7 +13,7 @@ #include #define SETUP_AND_PARSE(source) \ - auto vm = JS::VM::create(); \ + auto vm = MUST(JS::VM::create()); \ auto ast_interpreter = JS::Interpreter::create(*vm); \ \ auto script_or_error = JS::Script::parse(source##sv, ast_interpreter->realm()); \ diff --git a/Tests/LibJS/test262-runner.cpp b/Tests/LibJS/test262-runner.cpp index 898930a1ff8..4747b44c943 100644 --- a/Tests/LibJS/test262-runner.cpp +++ b/Tests/LibJS/test262-runner.cpp @@ -232,7 +232,7 @@ static Result run_test(StringView source, StringView filepath, return {}; } - auto vm = JS::VM::create(); + auto vm = MUST(JS::VM::create()); vm->enable_default_host_import_module_dynamically_hook(); auto ast_interpreter = JS::Interpreter::create(*vm); auto& realm = ast_interpreter->realm(); diff --git a/Userland/Applications/Assistant/Providers.cpp b/Userland/Applications/Assistant/Providers.cpp index 566e0596ba7..d1cbbadfcfe 100644 --- a/Userland/Applications/Assistant/Providers.cpp +++ b/Userland/Applications/Assistant/Providers.cpp @@ -88,7 +88,7 @@ void CalculatorProvider::query(DeprecatedString const& query, Function