1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09: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:
Ali Mohammad Pur 2022-02-12 19:54:08 +03:30 committed by Linus Groh
parent 3a5f7cb524
commit 75aa900b83
Notes: sideshowbarker 2024-07-17 18:55:17 +09:00
10 changed files with 378 additions and 233 deletions

View file

@ -1024,7 +1024,13 @@ static bool parse_and_run(JS::Interpreter& interpreter, StringView source, Strin
script_or_module->parse_node().dump(0);
if (JS::Bytecode::g_dump_bytecode || s_run_bytecode) {
auto executable = JS::Bytecode::Generator::generate(script_or_module->parse_node());
auto executable_result = JS::Bytecode::Generator::generate(script_or_module->parse_node());
if (executable_result.is_error()) {
result = vm->throw_completion<JS::InternalError>(interpreter.global_object(), executable_result.error().to_string());
return ReturnEarly::No;
}
auto executable = executable_result.release_value();
executable->name = source_name;
if (s_opt_bytecode) {
auto& passes = JS::Bytecode::Interpreter::optimization_pipeline();