mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +00:00
LibJS: Make ASTNode::generate_bytecode() fallible
Instead of crashing on the spot, return a descriptive error that will eventually continue its days as a javascript "InternalError" exception. This should make random crashes with BC less likely.
This commit is contained in:
parent
3a5f7cb524
commit
75aa900b83
Notes:
sideshowbarker
2024-07-17 18:55:17 +09:00
Author: https://github.com/alimpfard
Commit: 75aa900b83
Pull-request: https://github.com/SerenityOS/serenity/pull/12468
Reviewed-by: https://github.com/linusg ✅
10 changed files with 378 additions and 233 deletions
|
@ -346,7 +346,7 @@ inline JSFileResult TestRunner::run_file_test(const String& test_path)
|
|||
auto test_script = result.release_value();
|
||||
|
||||
if (g_run_bytecode) {
|
||||
auto executable = JS::Bytecode::Generator::generate(test_script->parse_node());
|
||||
auto executable = MUST(JS::Bytecode::Generator::generate(test_script->parse_node()));
|
||||
executable->name = test_path;
|
||||
if (JS::Bytecode::g_dump_bytecode)
|
||||
executable->dump();
|
||||
|
@ -362,12 +362,15 @@ inline JSFileResult TestRunner::run_file_test(const String& test_path)
|
|||
if (file_script.is_error())
|
||||
return { test_path, file_script.error() };
|
||||
if (g_run_bytecode) {
|
||||
auto executable = JS::Bytecode::Generator::generate(file_script.value()->parse_node());
|
||||
executable->name = test_path;
|
||||
if (JS::Bytecode::g_dump_bytecode)
|
||||
executable->dump();
|
||||
JS::Bytecode::Interpreter bytecode_interpreter(interpreter->global_object(), interpreter->realm());
|
||||
(void)bytecode_interpreter.run(*executable);
|
||||
auto executable_result = JS::Bytecode::Generator::generate(file_script.value()->parse_node());
|
||||
if (!executable_result.is_error()) {
|
||||
auto executable = executable_result.release_value();
|
||||
executable->name = test_path;
|
||||
if (JS::Bytecode::g_dump_bytecode)
|
||||
executable->dump();
|
||||
JS::Bytecode::Interpreter bytecode_interpreter(interpreter->global_object(), interpreter->realm());
|
||||
(void)bytecode_interpreter.run(*executable);
|
||||
}
|
||||
} else {
|
||||
g_vm->push_execution_context(global_execution_context, interpreter->global_object());
|
||||
(void)interpreter->run(file_script.value());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue