1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 16:45:08 +00:00

LibJS: Rename Bytecode::ExecutionUnit => Bytecode::Executable

This commit is contained in:
Andreas Kling 2021-06-09 09:11:20 +02:00
parent 597e0d95fe
commit b61f198d22
6 changed files with 14 additions and 14 deletions

View file

@ -21,7 +21,7 @@ Generator::~Generator()
{ {
} }
ExecutionUnit Generator::generate(ASTNode const& node) Executable Generator::generate(ASTNode const& node)
{ {
Generator generator; Generator generator;
generator.switch_to_basic_block(generator.make_block()); generator.switch_to_basic_block(generator.make_block());

View file

@ -16,14 +16,14 @@
namespace JS::Bytecode { namespace JS::Bytecode {
struct ExecutionUnit { struct Executable {
NonnullOwnPtrVector<BasicBlock> basic_blocks; NonnullOwnPtrVector<BasicBlock> basic_blocks;
size_t number_of_registers { 0 }; size_t number_of_registers { 0 };
}; };
class Generator { class Generator {
public: public:
static ExecutionUnit generate(ASTNode const&); static Executable generate(ASTNode const&);
Register allocate_register(); Register allocate_register();

View file

@ -33,9 +33,9 @@ Interpreter::~Interpreter()
s_current = nullptr; s_current = nullptr;
} }
Value Interpreter::run(ExecutionUnit const& execution_unit) Value Interpreter::run(Executable const& executable)
{ {
dbgln_if(JS_BYTECODE_DEBUG, "Bytecode::Interpreter will run unit {:p}", &execution_unit); dbgln_if(JS_BYTECODE_DEBUG, "Bytecode::Interpreter will run unit {:p}", &executable);
CallFrame global_call_frame; CallFrame global_call_frame;
if (vm().call_stack().is_empty()) { if (vm().call_stack().is_empty()) {
@ -50,9 +50,9 @@ Value Interpreter::run(ExecutionUnit const& execution_unit)
VERIFY(!vm().exception()); VERIFY(!vm().exception());
} }
auto block = &execution_unit.basic_blocks.first(); auto block = &executable.basic_blocks.first();
m_register_windows.append(make<RegisterWindow>()); m_register_windows.append(make<RegisterWindow>());
registers().resize(execution_unit.number_of_registers); registers().resize(executable.number_of_registers);
for (;;) { for (;;) {
Bytecode::InstructionStreamIterator pc(block->instruction_stream()); Bytecode::InstructionStreamIterator pc(block->instruction_stream());
@ -80,7 +80,7 @@ Value Interpreter::run(ExecutionUnit const& execution_unit)
break; break;
} }
dbgln_if(JS_BYTECODE_DEBUG, "Bytecode::Interpreter did run unit {:p}", &execution_unit); dbgln_if(JS_BYTECODE_DEBUG, "Bytecode::Interpreter did run unit {:p}", &executable);
if constexpr (JS_BYTECODE_DEBUG) { if constexpr (JS_BYTECODE_DEBUG) {
for (size_t i = 0; i < registers().size(); ++i) { for (size_t i = 0; i < registers().size(); ++i) {

View file

@ -28,7 +28,7 @@ public:
GlobalObject& global_object() { return m_global_object; } GlobalObject& global_object() { return m_global_object; }
VM& vm() { return m_vm; } VM& vm() { return m_vm; }
Value run(Bytecode::ExecutionUnit const&); Value run(Bytecode::Executable const&);
ALWAYS_INLINE Value& accumulator() { return reg(Register::accumulator()); } ALWAYS_INLINE Value& accumulator() { return reg(Register::accumulator()); }
Value& reg(Register const& r) { return registers()[r.index()]; } Value& reg(Register const& r) { return registers()[r.index()]; }

View file

@ -151,15 +151,15 @@ Value ScriptFunction::execute_function_body()
if (bytecode_interpreter) { if (bytecode_interpreter) {
prepare_arguments(); prepare_arguments();
if (!m_bytecode_execution_unit.has_value()) { if (!m_bytecode_executable.has_value()) {
m_bytecode_execution_unit = Bytecode::Generator::generate(m_body); m_bytecode_executable = Bytecode::Generator::generate(m_body);
if constexpr (JS_BYTECODE_DEBUG) { if constexpr (JS_BYTECODE_DEBUG) {
dbgln("Compiled Bytecode::Block for function '{}':", m_name); dbgln("Compiled Bytecode::Block for function '{}':", m_name);
for (auto& block : m_bytecode_execution_unit->basic_blocks) for (auto& block : m_bytecode_executable->basic_blocks)
block.dump(); block.dump();
} }
} }
return bytecode_interpreter->run(*m_bytecode_execution_unit); return bytecode_interpreter->run(*m_bytecode_executable);
} else { } else {
OwnPtr<Interpreter> local_interpreter; OwnPtr<Interpreter> local_interpreter;
ast_interpreter = vm.interpreter_if_exists(); ast_interpreter = vm.interpreter_if_exists();

View file

@ -48,7 +48,7 @@ private:
FlyString m_name; FlyString m_name;
NonnullRefPtr<Statement> m_body; NonnullRefPtr<Statement> m_body;
const Vector<FunctionNode::Parameter> m_parameters; const Vector<FunctionNode::Parameter> m_parameters;
Optional<Bytecode::ExecutionUnit> m_bytecode_execution_unit; Optional<Bytecode::Executable> m_bytecode_executable;
ScopeObject* m_parent_scope { nullptr }; ScopeObject* m_parent_scope { nullptr };
i32 m_function_length { 0 }; i32 m_function_length { 0 };
bool m_is_strict { false }; bool m_is_strict { false };