1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 12:55:09 +00:00

LibJS: Make Bytecode::Executable GC-allocated

This is a step towards making ExecutionContext easier to allocate.
This commit is contained in:
Andreas Kling 2023-11-27 13:23:59 +01:00
parent ece961f882
commit ecfcc9aef3
13 changed files with 34 additions and 19 deletions

View file

@ -11,6 +11,7 @@
#include <LibJS/Bytecode/Instruction.h>
#include <LibJS/Bytecode/Op.h>
#include <LibJS/Bytecode/Register.h>
#include <LibJS/Runtime/VM.h>
namespace JS::Bytecode {
@ -21,7 +22,7 @@ Generator::Generator()
{
}
CodeGenerationErrorOr<NonnullRefPtr<Executable>> Generator::generate(ASTNode const& node, FunctionKind enclosing_function_kind)
CodeGenerationErrorOr<NonnullGCPtr<Executable>> Generator::generate(VM& vm, ASTNode const& node, FunctionKind enclosing_function_kind)
{
Generator generator;
generator.switch_to_basic_block(generator.make_block());
@ -57,7 +58,7 @@ CodeGenerationErrorOr<NonnullRefPtr<Executable>> Generator::generate(ASTNode con
else if (is<FunctionExpression>(node))
is_strict_mode = static_cast<FunctionExpression const&>(node).is_strict_mode();
auto executable = adopt_ref(*new Executable(
auto executable = vm.heap().allocate_without_realm<Executable>(
move(generator.m_identifier_table),
move(generator.m_string_table),
move(generator.m_regex_table),
@ -67,7 +68,7 @@ CodeGenerationErrorOr<NonnullRefPtr<Executable>> Generator::generate(ASTNode con
generator.m_next_environment_variable_cache,
generator.m_next_register,
move(generator.m_root_basic_blocks),
is_strict_mode));
is_strict_mode);
return executable;
}