瀏覽代碼

LibJS: Rename the overridden Instruction methods to foo_impl

These are pretty hairy if someone forgets to override one, as the
catchall function in Instruction will keep calling itself over and over
again, leading to really hard-to-debug situations.
Ali Mohammad Pur 4 年之前
父節點
當前提交
e81fd7106b
共有 2 個文件被更改,包括 150 次插入150 次删除
  1. 63 63
      Userland/Libraries/LibJS/Bytecode/Op.cpp
  2. 87 87
      Userland/Libraries/LibJS/Bytecode/Op.h

+ 63 - 63
Userland/Libraries/LibJS/Bytecode/Op.cpp

@@ -23,7 +23,7 @@ String Instruction::to_string(Bytecode::Executable const& executable) const
 {
 {
 #define __BYTECODE_OP(op)       \
 #define __BYTECODE_OP(op)       \
     case Instruction::Type::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()) {
     switch (type()) {
         ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
         ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
@@ -38,17 +38,17 @@ String Instruction::to_string(Bytecode::Executable const& executable) const
 
 
 namespace JS::Bytecode::Op {
 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);
     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;
     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();
     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)                            \
 #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 lhs = interpreter.reg(m_lhs_reg);                                            \
         auto rhs = interpreter.accumulator();                                             \
         auto rhs = interpreter.accumulator();                                             \
         interpreter.accumulator() = op_snake_case(interpreter.global_object(), lhs, rhs); \
         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);                          \
         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)                                              \
 #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()); \
         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;                                                                               \
         return #OpTitleCase;                                                                               \
     }
     }
 
 
 JS_ENUMERATE_COMMON_UNARY_OPS(JS_DEFINE_COMMON_UNARY_OP)
 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);
     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;
     Vector<Value> elements;
     elements.ensure_capacity(m_element_count);
     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);
     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));
     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());
     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());
     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());
     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());
     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()))
     if (auto* object = interpreter.accumulator().to_object(interpreter.global_object()))
         interpreter.accumulator() = object->get(interpreter.current_executable().get_string(m_property));
         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()))
     if (auto* object = interpreter.reg(m_base).to_object(interpreter.global_object()))
         object->put(interpreter.current_executable().get_string(m_property), interpreter.accumulator());
         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);
     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_true_target.has_value());
     VERIFY(m_false_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());
         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_true_target.has_value());
     VERIFY(m_false_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());
         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);
     auto callee = interpreter.reg(m_callee);
     if (!callee.is_function()) {
     if (!callee.is_function()) {
@@ -215,18 +215,18 @@ void Call::execute(Bytecode::Interpreter& interpreter) const
     interpreter.accumulator() = return_value;
     interpreter.accumulator() = return_value;
 }
 }
 
 
-void NewFunction::execute(Bytecode::Interpreter& interpreter) const
+void NewFunction::execute_impl(Bytecode::Interpreter& interpreter) const
 {
 {
     auto& vm = interpreter.vm();
     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());
     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()));
     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());
     auto old_value = interpreter.accumulator().to_numeric(interpreter.global_object());
     if (interpreter.vm().exception())
     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 }));
         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());
     auto old_value = interpreter.accumulator().to_numeric(interpreter.global_object());
     if (interpreter.vm().exception())
     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 }));
         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());
     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.enter_unwind_context(m_handler_target, m_finalizer_target);
     interpreter.jump(m_entry_point);
     interpreter.jump(m_entry_point);
 }
 }
 
 
-void LeaveUnwindContext::execute(Bytecode::Interpreter& interpreter) const
+void LeaveUnwindContext::execute_impl(Bytecode::Interpreter& interpreter) const
 {
 {
     interpreter.leave_unwind_context();
     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);
     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;
     HashMap<FlyString, Variable> resolved_variables;
     for (auto& it : m_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;
     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 yielded_value = interpreter.accumulator().value_or(js_undefined());
     auto object = JS::Object::create_empty(interpreter.global_object());
     auto object = JS::Object::create_empty(interpreter.global_object());
@@ -292,7 +292,7 @@ void Yield::execute(Bytecode::Interpreter& interpreter) const
     interpreter.do_return(object);
     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())) {
     if (auto* object = interpreter.reg(m_base).to_object(interpreter.global_object())) {
         auto property_key = interpreter.accumulator().to_property_key(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())) {
     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());
         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);
     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);
     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);
     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);
     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());
     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;
     StringBuilder builder;
     builder.append("NewArray");
     builder.append("NewArray");
@@ -353,63 +353,63 @@ String NewArray::to_string(Bytecode::Executable const&) const
     return builder.to_string();
     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));
     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";
     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);
     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));
     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));
     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));
     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));
     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())
     if (m_true_target.has_value())
         return String::formatted("Jump {}", *m_true_target);
         return String::formatted("Jump {}", *m_true_target);
     return String::formatted("Jump <empty>");
     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 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>";
     auto false_string = m_false_target.has_value() ? String::formatted("{}", *m_false_target) : "<empty>";
     return String::formatted("JumpConditional true:{} false:{}", true_string, false_string);
     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 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>";
     auto false_string = m_false_target.has_value() ? String::formatted("{}", *m_false_target) : "<empty>";
     return String::formatted("JumpNullish null:{} nonnull:{}", true_string, false_string);
     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;
     StringBuilder builder;
     builder.appendff("Call callee:{}, this:{}", m_callee, m_this_value);
     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();
     return builder.to_string();
 }
 }
 
 
-String NewFunction::to_string(Bytecode::Executable const&) const
+String NewFunction::to_string_impl(Bytecode::Executable const&) const
 {
 {
     return "NewFunction";
     return "NewFunction";
 }
 }
 
 
-String Return::to_string(Bytecode::Executable const&) const
+String Return::to_string_impl(Bytecode::Executable const&) const
 {
 {
     return "Return";
     return "Return";
 }
 }
 
 
-String Increment::to_string(Bytecode::Executable const&) const
+String Increment::to_string_impl(Bytecode::Executable const&) const
 {
 {
     return "Increment";
     return "Increment";
 }
 }
 
 
-String Decrement::to_string(Bytecode::Executable const&) const
+String Decrement::to_string_impl(Bytecode::Executable const&) const
 {
 {
     return "Decrement";
     return "Decrement";
 }
 }
 
 
-String Throw::to_string(Bytecode::Executable const&) const
+String Throw::to_string_impl(Bytecode::Executable const&) const
 {
 {
     return "Throw";
     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 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>";
     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);
     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";
     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);
     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;
     StringBuilder builder;
     builder.append("PushLexicalEnvironment");
     builder.append("PushLexicalEnvironment");
@@ -482,24 +482,24 @@ String PushLexicalEnvironment::to_string(const Bytecode::Executable& executable)
     return builder.to_string();
     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())
     if (m_continuation_label.has_value())
         return String::formatted("Yield continuation:@{}", m_continuation_label->block().name());
         return String::formatted("Yield continuation:@{}", m_continuation_label->block().name());
     return String::formatted("Yield return");
     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);
     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);
     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);
     return String::formatted("LoadArgument {}", m_index);
 }
 }

+ 87 - 87
Userland/Libraries/LibJS/Bytecode/Op.h

@@ -27,8 +27,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     Register m_src;
     Register m_src;
@@ -42,8 +42,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     Value m_value;
     Value m_value;
@@ -57,8 +57,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     Register m_dst;
     Register m_dst;
@@ -88,20 +88,20 @@ private:
     O(RightShift, right_shift)                \
     O(RightShift, right_shift)                \
     O(UnsignedRightShift, unsigned_right_shift)
     O(UnsignedRightShift, unsigned_right_shift)
 
 
-#define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case) \
-    class OpTitleCase final : public Instruction {              \
-    public:                                                     \
-        explicit OpTitleCase(Register lhs_reg)                  \
-            : Instruction(Type::OpTitleCase)                    \
-            , m_lhs_reg(lhs_reg)                                \
-        {                                                       \
-        }                                                       \
-                                                                \
-        void execute(Bytecode::Interpreter&) const;             \
-        String to_string(Bytecode::Executable const&) const;    \
-                                                                \
-    private:                                                    \
-        Register m_lhs_reg;                                     \
+#define JS_DECLARE_COMMON_BINARY_OP(OpTitleCase, op_snake_case)   \
+    class OpTitleCase final : public Instruction {                \
+    public:                                                       \
+        explicit OpTitleCase(Register lhs_reg)                    \
+            : Instruction(Type::OpTitleCase)                      \
+            , m_lhs_reg(lhs_reg)                                  \
+        {                                                         \
+        }                                                         \
+                                                                  \
+        void execute_impl(Bytecode::Interpreter&) const;          \
+        String to_string_impl(Bytecode::Executable const&) const; \
+                                                                  \
+    private:                                                      \
+        Register m_lhs_reg;                                       \
     };
     };
 
 
 JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
 JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
@@ -114,16 +114,16 @@ JS_ENUMERATE_COMMON_BINARY_OPS(JS_DECLARE_COMMON_BINARY_OP)
     O(UnaryMinus, unary_minus)           \
     O(UnaryMinus, unary_minus)           \
     O(Typeof, typeof_)
     O(Typeof, typeof_)
 
 
-#define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case) \
-    class OpTitleCase final : public Instruction {             \
-    public:                                                    \
-        OpTitleCase()                                          \
-            : Instruction(Type::OpTitleCase)                   \
-        {                                                      \
-        }                                                      \
-                                                               \
-        void execute(Bytecode::Interpreter&) const;            \
-        String to_string(Bytecode::Executable const&) const;   \
+#define JS_DECLARE_COMMON_UNARY_OP(OpTitleCase, op_snake_case)    \
+    class OpTitleCase final : public Instruction {                \
+    public:                                                       \
+        OpTitleCase()                                             \
+            : Instruction(Type::OpTitleCase)                      \
+        {                                                         \
+        }                                                         \
+                                                                  \
+        void execute_impl(Bytecode::Interpreter&) const;          \
+        String to_string_impl(Bytecode::Executable const&) const; \
     };
     };
 
 
 JS_ENUMERATE_COMMON_UNARY_OPS(JS_DECLARE_COMMON_UNARY_OP)
 JS_ENUMERATE_COMMON_UNARY_OPS(JS_DECLARE_COMMON_UNARY_OP)
@@ -137,8 +137,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     StringTableIndex m_string;
     StringTableIndex m_string;
@@ -151,8 +151,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 };
 };
 
 
 class NewBigInt final : public Instruction {
 class NewBigInt final : public Instruction {
@@ -163,8 +163,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     Crypto::SignedBigInteger m_bigint;
     Crypto::SignedBigInteger m_bigint;
@@ -181,10 +181,10 @@ public:
             m_elements[i] = elements[i];
             m_elements[i] = elements[i];
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
-    size_t length() const { return sizeof(*this) + sizeof(Register) * m_element_count; }
+    size_t length_impl() const { return sizeof(*this) + sizeof(Register) * m_element_count; }
 
 
 private:
 private:
     size_t m_element_count { 0 };
     size_t m_element_count { 0 };
@@ -199,8 +199,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     Register m_lhs;
     Register m_lhs;
@@ -214,8 +214,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     StringTableIndex m_identifier;
     StringTableIndex m_identifier;
@@ -229,8 +229,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     StringTableIndex m_identifier;
     StringTableIndex m_identifier;
@@ -244,8 +244,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     StringTableIndex m_property;
     StringTableIndex m_property;
@@ -260,8 +260,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     Register m_base;
     Register m_base;
@@ -276,8 +276,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     Register m_base;
     Register m_base;
@@ -292,8 +292,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     Register m_base;
     Register m_base;
@@ -324,8 +324,8 @@ public:
         m_false_target = move(false_target);
         m_false_target = move(false_target);
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 protected:
 protected:
     Optional<Label> m_true_target;
     Optional<Label> m_true_target;
@@ -339,8 +339,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 };
 };
 
 
 class JumpNullish final : public Jump {
 class JumpNullish final : public Jump {
@@ -350,8 +350,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 };
 };
 
 
 // NOTE: This instruction is variable-width depending on the number of arguments!
 // NOTE: This instruction is variable-width depending on the number of arguments!
@@ -373,10 +373,10 @@ public:
             m_arguments[i] = arguments[i];
             m_arguments[i] = arguments[i];
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
-    size_t length() const { return sizeof(*this) + sizeof(Register) * m_argument_count; }
+    size_t length_impl() const { return sizeof(*this) + sizeof(Register) * m_argument_count; }
 
 
 private:
 private:
     Register m_callee;
     Register m_callee;
@@ -394,8 +394,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     FunctionNode const& m_function_node;
     FunctionNode const& m_function_node;
@@ -410,8 +410,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 };
 };
 
 
 class Increment final : public Instruction {
 class Increment final : public Instruction {
@@ -421,8 +421,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 };
 };
 
 
 class Decrement final : public Instruction {
 class Decrement final : public Instruction {
@@ -432,8 +432,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 };
 };
 
 
 class Throw final : public Instruction {
 class Throw final : public Instruction {
@@ -445,8 +445,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 };
 };
 
 
 class EnterUnwindContext final : public Instruction {
 class EnterUnwindContext final : public Instruction {
@@ -461,8 +461,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     Label m_entry_point;
     Label m_entry_point;
@@ -477,8 +477,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 };
 };
 
 
 class ContinuePendingUnwind final : public Instruction {
 class ContinuePendingUnwind final : public Instruction {
@@ -491,8 +491,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     Label m_resume_target;
     Label m_resume_target;
@@ -513,8 +513,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     Optional<Label> m_continuation_label;
     Optional<Label> m_continuation_label;
@@ -527,8 +527,8 @@ public:
         , m_variables(move(variables))
         , m_variables(move(variables))
     {
     {
     }
     }
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     HashMap<u32, Variable> m_variables;
     HashMap<u32, Variable> m_variables;
@@ -542,8 +542,8 @@ public:
     {
     {
     }
     }
 
 
-    void execute(Bytecode::Interpreter&) const;
-    String to_string(Bytecode::Executable const&) const;
+    void execute_impl(Bytecode::Interpreter&) const;
+    String to_string_impl(Bytecode::Executable const&) const;
 
 
 private:
 private:
     size_t m_index { 0 };
     size_t m_index { 0 };
@@ -557,7 +557,7 @@ ALWAYS_INLINE void Instruction::execute(Bytecode::Interpreter& interpreter) cons
 {
 {
 #define __BYTECODE_OP(op)       \
 #define __BYTECODE_OP(op)       \
     case Instruction::Type::op: \
     case Instruction::Type::op: \
-        return static_cast<Bytecode::Op::op const&>(*this).execute(interpreter);
+        return static_cast<Bytecode::Op::op const&>(*this).execute_impl(interpreter);
 
 
     switch (type()) {
     switch (type()) {
         ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
         ENUMERATE_BYTECODE_OPS(__BYTECODE_OP)
@@ -571,9 +571,9 @@ ALWAYS_INLINE void Instruction::execute(Bytecode::Interpreter& interpreter) cons
 ALWAYS_INLINE size_t Instruction::length() const
 ALWAYS_INLINE size_t Instruction::length() const
 {
 {
     if (type() == Type::Call)
     if (type() == Type::Call)
-        return static_cast<Op::Call const&>(*this).length();
+        return static_cast<Op::Call const&>(*this).length_impl();
     else if (type() == Type::NewArray)
     else if (type() == Type::NewArray)
-        return static_cast<Op::NewArray const&>(*this).length();
+        return static_cast<Op::NewArray const&>(*this).length_impl();
 
 
 #define __BYTECODE_OP(op) \
 #define __BYTECODE_OP(op) \
     case Type::op:        \
     case Type::op:        \