diff options
Diffstat (limited to 'Userland/Libraries/LibJS/Bytecode/Op.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Op.cpp | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 55ff3b29d7..676267e4d2 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -23,7 +23,7 @@ String Instruction::to_string(Bytecode::Executable const& executable) const { #define __BYTECODE_OP(op) \ case Instruction::Type::op: \ - return static_cast<Bytecode::Op::op const&>(*this).to_string(executable); + return static_cast<Bytecode::Op::op const&>(*this).to_string_impl(executable); switch (type()) { ENUMERATE_BYTECODE_OPS(__BYTECODE_OP) @@ -38,17 +38,17 @@ String Instruction::to_string(Bytecode::Executable const& executable) const namespace JS::Bytecode::Op { -void Load::execute(Bytecode::Interpreter& interpreter) const +void Load::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.accumulator() = interpreter.reg(m_src); } -void LoadImmediate::execute(Bytecode::Interpreter& interpreter) const +void LoadImmediate::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.accumulator() = m_value; } -void Store::execute(Bytecode::Interpreter& interpreter) const +void Store::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.reg(m_dst) = interpreter.accumulator(); } @@ -74,13 +74,13 @@ static Value typed_equals(GlobalObject&, Value src1, Value src2) } #define JS_DEFINE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \ - void OpTitleCase::execute(Bytecode::Interpreter& interpreter) const \ + void OpTitleCase::execute_impl(Bytecode::Interpreter& interpreter) const \ { \ auto lhs = interpreter.reg(m_lhs_reg); \ auto rhs = interpreter.accumulator(); \ interpreter.accumulator() = op_snake_case(interpreter.global_object(), lhs, rhs); \ } \ - String OpTitleCase::to_string(Bytecode::Executable const&) const \ + String OpTitleCase::to_string_impl(Bytecode::Executable const&) const \ { \ return String::formatted(#OpTitleCase " {}", m_lhs_reg); \ } @@ -98,23 +98,23 @@ static Value typeof_(GlobalObject& global_object, Value value) } #define JS_DEFINE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \ - void OpTitleCase::execute(Bytecode::Interpreter& interpreter) const \ + void OpTitleCase::execute_impl(Bytecode::Interpreter& interpreter) const \ { \ interpreter.accumulator() = op_snake_case(interpreter.global_object(), interpreter.accumulator()); \ } \ - String OpTitleCase::to_string(Bytecode::Executable const&) const \ + String OpTitleCase::to_string_impl(Bytecode::Executable const&) const \ { \ return #OpTitleCase; \ } JS_ENUMERATE_COMMON_UNARY_OPS(JS_DEFINE_COMMON_UNARY_OP) -void NewBigInt::execute(Bytecode::Interpreter& interpreter) const +void NewBigInt::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.accumulator() = js_bigint(interpreter.vm().heap(), m_bigint); } -void NewArray::execute(Bytecode::Interpreter& interpreter) const +void NewArray::execute_impl(Bytecode::Interpreter& interpreter) const { Vector<Value> elements; elements.ensure_capacity(m_element_count); @@ -123,49 +123,49 @@ void NewArray::execute(Bytecode::Interpreter& interpreter) const interpreter.accumulator() = Array::create_from(interpreter.global_object(), elements); } -void NewString::execute(Bytecode::Interpreter& interpreter) const +void NewString::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.accumulator() = js_string(interpreter.vm(), interpreter.current_executable().get_string(m_string)); } -void NewObject::execute(Bytecode::Interpreter& interpreter) const +void NewObject::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.accumulator() = Object::create_empty(interpreter.global_object()); } -void ConcatString::execute(Bytecode::Interpreter& interpreter) const +void ConcatString::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.reg(m_lhs) = add(interpreter.global_object(), interpreter.reg(m_lhs), interpreter.accumulator()); } -void GetVariable::execute(Bytecode::Interpreter& interpreter) const +void GetVariable::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.accumulator() = interpreter.vm().get_variable(interpreter.current_executable().get_string(m_identifier), interpreter.global_object()); } -void SetVariable::execute(Bytecode::Interpreter& interpreter) const +void SetVariable::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.vm().set_variable(interpreter.current_executable().get_string(m_identifier), interpreter.accumulator(), interpreter.global_object()); } -void GetById::execute(Bytecode::Interpreter& interpreter) const +void GetById::execute_impl(Bytecode::Interpreter& interpreter) const { if (auto* object = interpreter.accumulator().to_object(interpreter.global_object())) interpreter.accumulator() = object->get(interpreter.current_executable().get_string(m_property)); } -void PutById::execute(Bytecode::Interpreter& interpreter) const +void PutById::execute_impl(Bytecode::Interpreter& interpreter) const { if (auto* object = interpreter.reg(m_base).to_object(interpreter.global_object())) object->put(interpreter.current_executable().get_string(m_property), interpreter.accumulator()); } -void Jump::execute(Bytecode::Interpreter& interpreter) const +void Jump::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.jump(*m_true_target); } -void JumpConditional::execute(Bytecode::Interpreter& interpreter) const +void JumpConditional::execute_impl(Bytecode::Interpreter& interpreter) const { VERIFY(m_true_target.has_value()); VERIFY(m_false_target.has_value()); @@ -176,7 +176,7 @@ void JumpConditional::execute(Bytecode::Interpreter& interpreter) const interpreter.jump(m_false_target.value()); } -void JumpNullish::execute(Bytecode::Interpreter& interpreter) const +void JumpNullish::execute_impl(Bytecode::Interpreter& interpreter) const { VERIFY(m_true_target.has_value()); VERIFY(m_false_target.has_value()); @@ -187,7 +187,7 @@ void JumpNullish::execute(Bytecode::Interpreter& interpreter) const interpreter.jump(m_false_target.value()); } -void Call::execute(Bytecode::Interpreter& interpreter) const +void Call::execute_impl(Bytecode::Interpreter& interpreter) const { auto callee = interpreter.reg(m_callee); if (!callee.is_function()) { @@ -215,18 +215,18 @@ void Call::execute(Bytecode::Interpreter& interpreter) const interpreter.accumulator() = return_value; } -void NewFunction::execute(Bytecode::Interpreter& interpreter) const +void NewFunction::execute_impl(Bytecode::Interpreter& interpreter) const { auto& vm = interpreter.vm(); interpreter.accumulator() = ScriptFunction::create(interpreter.global_object(), m_function_node.name(), m_function_node.body(), m_function_node.parameters(), m_function_node.function_length(), vm.current_scope(), m_function_node.kind(), m_function_node.is_strict_mode(), m_function_node.is_arrow_function()); } -void Return::execute(Bytecode::Interpreter& interpreter) const +void Return::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.do_return(interpreter.accumulator().value_or(js_undefined())); } -void Increment::execute(Bytecode::Interpreter& interpreter) const +void Increment::execute_impl(Bytecode::Interpreter& interpreter) const { auto old_value = interpreter.accumulator().to_numeric(interpreter.global_object()); if (interpreter.vm().exception()) @@ -238,7 +238,7 @@ void Increment::execute(Bytecode::Interpreter& interpreter) const interpreter.accumulator() = js_bigint(interpreter.vm().heap(), old_value.as_bigint().big_integer().plus(Crypto::SignedBigInteger { 1 })); } -void Decrement::execute(Bytecode::Interpreter& interpreter) const +void Decrement::execute_impl(Bytecode::Interpreter& interpreter) const { auto old_value = interpreter.accumulator().to_numeric(interpreter.global_object()); if (interpreter.vm().exception()) @@ -250,28 +250,28 @@ void Decrement::execute(Bytecode::Interpreter& interpreter) const interpreter.accumulator() = js_bigint(interpreter.vm().heap(), old_value.as_bigint().big_integer().minus(Crypto::SignedBigInteger { 1 })); } -void Throw::execute(Bytecode::Interpreter& interpreter) const +void Throw::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.vm().throw_exception(interpreter.global_object(), interpreter.accumulator()); } -void EnterUnwindContext::execute(Bytecode::Interpreter& interpreter) const +void EnterUnwindContext::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.enter_unwind_context(m_handler_target, m_finalizer_target); interpreter.jump(m_entry_point); } -void LeaveUnwindContext::execute(Bytecode::Interpreter& interpreter) const +void LeaveUnwindContext::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.leave_unwind_context(); } -void ContinuePendingUnwind::execute(Bytecode::Interpreter& interpreter) const +void ContinuePendingUnwind::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.continue_pending_unwind(m_resume_target); } -void PushLexicalEnvironment::execute(Bytecode::Interpreter& interpreter) const +void PushLexicalEnvironment::execute_impl(Bytecode::Interpreter& interpreter) const { HashMap<FlyString, Variable> resolved_variables; for (auto& it : m_variables) @@ -280,7 +280,7 @@ void PushLexicalEnvironment::execute(Bytecode::Interpreter& interpreter) const interpreter.vm().call_frame().scope = block_lexical_environment; } -void Yield::execute(Bytecode::Interpreter& interpreter) const +void Yield::execute_impl(Bytecode::Interpreter& interpreter) const { auto yielded_value = interpreter.accumulator().value_or(js_undefined()); auto object = JS::Object::create_empty(interpreter.global_object()); @@ -292,7 +292,7 @@ void Yield::execute(Bytecode::Interpreter& interpreter) const interpreter.do_return(object); } -void GetByValue::execute(Bytecode::Interpreter& interpreter) const +void GetByValue::execute_impl(Bytecode::Interpreter& interpreter) const { if (auto* object = interpreter.reg(m_base).to_object(interpreter.global_object())) { auto property_key = interpreter.accumulator().to_property_key(interpreter.global_object()); @@ -302,7 +302,7 @@ void GetByValue::execute(Bytecode::Interpreter& interpreter) const } } -void PutByValue::execute(Bytecode::Interpreter& interpreter) const +void PutByValue::execute_impl(Bytecode::Interpreter& interpreter) const { if (auto* object = interpreter.reg(m_base).to_object(interpreter.global_object())) { auto property_key = interpreter.reg(m_property).to_property_key(interpreter.global_object()); @@ -312,32 +312,32 @@ void PutByValue::execute(Bytecode::Interpreter& interpreter) const } } -void LoadArgument::execute(Bytecode::Interpreter& interpreter) const +void LoadArgument::execute_impl(Bytecode::Interpreter& interpreter) const { interpreter.accumulator() = interpreter.vm().argument(m_index); } -String Load::to_string(Bytecode::Executable const&) const +String Load::to_string_impl(Bytecode::Executable const&) const { return String::formatted("Load {}", m_src); } -String LoadImmediate::to_string(Bytecode::Executable const&) const +String LoadImmediate::to_string_impl(Bytecode::Executable const&) const { return String::formatted("LoadImmediate {}", m_value); } -String Store::to_string(Bytecode::Executable const&) const +String Store::to_string_impl(Bytecode::Executable const&) const { return String::formatted("Store {}", m_dst); } -String NewBigInt::to_string(Bytecode::Executable const&) const +String NewBigInt::to_string_impl(Bytecode::Executable const&) const { return String::formatted("NewBigInt \"{}\"", m_bigint.to_base10()); } -String NewArray::to_string(Bytecode::Executable const&) const +String NewArray::to_string_impl(Bytecode::Executable const&) const { StringBuilder builder; builder.append("NewArray"); @@ -353,63 +353,63 @@ String NewArray::to_string(Bytecode::Executable const&) const return builder.to_string(); } -String NewString::to_string(Bytecode::Executable const& executable) const +String NewString::to_string_impl(Bytecode::Executable const& executable) const { return String::formatted("NewString {} (\"{}\")", m_string, executable.string_table->get(m_string)); } -String NewObject::to_string(Bytecode::Executable const&) const +String NewObject::to_string_impl(Bytecode::Executable const&) const { return "NewObject"; } -String ConcatString::to_string(Bytecode::Executable const&) const +String ConcatString::to_string_impl(Bytecode::Executable const&) const { return String::formatted("ConcatString {}", m_lhs); } -String GetVariable::to_string(Bytecode::Executable const& executable) const +String GetVariable::to_string_impl(Bytecode::Executable const& executable) const { return String::formatted("GetVariable {} ({})", m_identifier, executable.string_table->get(m_identifier)); } -String SetVariable::to_string(Bytecode::Executable const& executable) const +String SetVariable::to_string_impl(Bytecode::Executable const& executable) const { return String::formatted("SetVariable {} ({})", m_identifier, executable.string_table->get(m_identifier)); } -String PutById::to_string(Bytecode::Executable const& executable) const +String PutById::to_string_impl(Bytecode::Executable const& executable) const { return String::formatted("PutById base:{}, property:{} ({})", m_base, m_property, executable.string_table->get(m_property)); } -String GetById::to_string(Bytecode::Executable const& executable) const +String GetById::to_string_impl(Bytecode::Executable const& executable) const { return String::formatted("GetById {} ({})", m_property, executable.string_table->get(m_property)); } -String Jump::to_string(Bytecode::Executable const&) const +String Jump::to_string_impl(Bytecode::Executable const&) const { if (m_true_target.has_value()) return String::formatted("Jump {}", *m_true_target); return String::formatted("Jump <empty>"); } -String JumpConditional::to_string(Bytecode::Executable const&) const +String JumpConditional::to_string_impl(Bytecode::Executable const&) const { auto true_string = m_true_target.has_value() ? String::formatted("{}", *m_true_target) : "<empty>"; auto false_string = m_false_target.has_value() ? String::formatted("{}", *m_false_target) : "<empty>"; return String::formatted("JumpConditional true:{} false:{}", true_string, false_string); } -String JumpNullish::to_string(Bytecode::Executable const&) const +String JumpNullish::to_string_impl(Bytecode::Executable const&) const { auto true_string = m_true_target.has_value() ? String::formatted("{}", *m_true_target) : "<empty>"; auto false_string = m_false_target.has_value() ? String::formatted("{}", *m_false_target) : "<empty>"; return String::formatted("JumpNullish null:{} nonnull:{}", true_string, false_string); } -String Call::to_string(Bytecode::Executable const&) const +String Call::to_string_impl(Bytecode::Executable const&) const { StringBuilder builder; builder.appendff("Call callee:{}, this:{}", m_callee, m_this_value); @@ -425,49 +425,49 @@ String Call::to_string(Bytecode::Executable const&) const return builder.to_string(); } -String NewFunction::to_string(Bytecode::Executable const&) const +String NewFunction::to_string_impl(Bytecode::Executable const&) const { return "NewFunction"; } -String Return::to_string(Bytecode::Executable const&) const +String Return::to_string_impl(Bytecode::Executable const&) const { return "Return"; } -String Increment::to_string(Bytecode::Executable const&) const +String Increment::to_string_impl(Bytecode::Executable const&) const { return "Increment"; } -String Decrement::to_string(Bytecode::Executable const&) const +String Decrement::to_string_impl(Bytecode::Executable const&) const { return "Decrement"; } -String Throw::to_string(Bytecode::Executable const&) const +String Throw::to_string_impl(Bytecode::Executable const&) const { return "Throw"; } -String EnterUnwindContext::to_string(Bytecode::Executable const&) const +String EnterUnwindContext::to_string_impl(Bytecode::Executable const&) const { auto handler_string = m_handler_target.has_value() ? String::formatted("{}", *m_handler_target) : "<empty>"; auto finalizer_string = m_finalizer_target.has_value() ? String::formatted("{}", *m_finalizer_target) : "<empty>"; return String::formatted("EnterUnwindContext handler:{} finalizer:{} entry:{}", handler_string, finalizer_string, m_entry_point); } -String LeaveUnwindContext::to_string(Bytecode::Executable const&) const +String LeaveUnwindContext::to_string_impl(Bytecode::Executable const&) const { return "LeaveUnwindContext"; } -String ContinuePendingUnwind::to_string(Bytecode::Executable const&) const +String ContinuePendingUnwind::to_string_impl(Bytecode::Executable const&) const { return String::formatted("ContinuePendingUnwind resume:{}", m_resume_target); } -String PushLexicalEnvironment::to_string(const Bytecode::Executable& executable) const +String PushLexicalEnvironment::to_string_impl(const Bytecode::Executable& executable) const { StringBuilder builder; builder.append("PushLexicalEnvironment"); @@ -482,24 +482,24 @@ String PushLexicalEnvironment::to_string(const Bytecode::Executable& executable) return builder.to_string(); } -String Yield::to_string(Bytecode::Executable const&) const +String Yield::to_string_impl(Bytecode::Executable const&) const { if (m_continuation_label.has_value()) return String::formatted("Yield continuation:@{}", m_continuation_label->block().name()); return String::formatted("Yield return"); } -String GetByValue::to_string(const Bytecode::Executable&) const +String GetByValue::to_string_impl(const Bytecode::Executable&) const { return String::formatted("GetByValue base:{}", m_base); } -String PutByValue::to_string(const Bytecode::Executable&) const +String PutByValue::to_string_impl(const Bytecode::Executable&) const { return String::formatted("PutByValue base:{}, property:{}", m_base, m_property); } -String LoadArgument::to_string(const Bytecode::Executable&) const +String LoadArgument::to_string_impl(const Bytecode::Executable&) const { return String::formatted("LoadArgument {}", m_index); } |