Skip to content

Commit

Permalink
Revert "LibJS/Bytecode: Fuse [Not, JumpIf] instructions into JumpIfNot"
Browse files Browse the repository at this point in the history
This reverts commit 795149e.
  • Loading branch information
awesomekling committed Mar 6, 2024
1 parent ea0b719 commit c4a0afb
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 53 deletions.
1 change: 0 additions & 1 deletion Userland/Libraries/LibJS/Bytecode/Instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
O(IteratorToArray) \
O(Jump) \
O(JumpIf) \
O(JumpIfNot) \
O(JumpGreaterThan) \
O(JumpGreaterThanEquals) \
O(JumpLessThan) \
Expand Down
20 changes: 0 additions & 20 deletions Userland/Libraries/LibJS/Bytecode/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,6 @@ void Interpreter::run_bytecode()
else
m_current_block = &static_cast<Op::JumpIf const&>(instruction).false_target()->block();
goto start;
case Instruction::Type::JumpIfNot:
if (!get(static_cast<Op::JumpIfNot const&>(instruction).condition()).to_boolean())
m_current_block = &static_cast<Op::JumpIfNot const&>(instruction).true_target()->block();
else
m_current_block = &static_cast<Op::JumpIfNot const&>(instruction).false_target()->block();
goto start;

#define JS_HANDLE_FUSABLE_BINARY_JUMP(PreOp, int32_operator, slow_case) \
case Instruction::Type::Jump##PreOp: { \
Expand Down Expand Up @@ -1288,12 +1282,6 @@ ThrowCompletionOr<void> JumpIf::execute_impl(Bytecode::Interpreter&) const
__builtin_unreachable();
}

ThrowCompletionOr<void> JumpIfNot::execute_impl(Bytecode::Interpreter&) const
{
// Handled in the interpreter loop.
__builtin_unreachable();
}

#define JS_DEFINE_FUSABLE_BINARY_OP(PreOp, ...) \
ThrowCompletionOr<void> Jump##PreOp::execute_impl(Bytecode::Interpreter&) const { __builtin_unreachable(); } \
\
Expand Down Expand Up @@ -1974,14 +1962,6 @@ ByteString JumpIf::to_byte_string_impl(Bytecode::Executable const& executable) c
true_string, false_string);
}

ByteString JumpIfNot::to_byte_string_impl(Bytecode::Executable const& executable) const
{
return ByteString::formatted("JumpIfNot {}, \033[32mtrue\033[0m:{} \033[32mfalse\033[0m:{}",
format_operand("condition"sv, m_condition, executable),
*m_true_target,
*m_false_target);
}

ByteString JumpNullish::to_byte_string_impl(Bytecode::Executable const& executable) const
{
auto true_string = m_true_target.has_value() ? ByteString::formatted("{}", *m_true_target) : "<empty>";
Expand Down
17 changes: 0 additions & 17 deletions Userland/Libraries/LibJS/Bytecode/Op.h
Original file line number Diff line number Diff line change
Expand Up @@ -1123,23 +1123,6 @@ class JumpIf final : public Jump {
Operand m_condition;
};

class JumpIfNot final : public Jump {
public:
explicit JumpIfNot(Operand condition, Label true_target, Label false_target)
: Jump(Type::JumpIfNot, move(true_target), move(false_target), sizeof(*this))
, m_condition(condition)
{
}

ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
ByteString to_byte_string_impl(Bytecode::Executable const&) const;

Operand condition() const { return m_condition; }

private:
Operand m_condition;
};

// NOTE: The raw operator is used for comparing two Int32 values.
#define JS_ENUMERATE_FUSABLE_BINARY_OPS(X) \
X(GreaterThan, >, greater_than) \
Expand Down
1 change: 0 additions & 1 deletion Userland/Libraries/LibJS/Bytecode/Pass/GenerateCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ static void generate_cfg_for_block(BasicBlock const& current_block, PassPipeline
#undef JS_ENUMERATE_FUSABLE_BINARY_OP

case JumpIf:
case JumpIfNot:
case JumpNullish:
case JumpUndefined: {
// FIXME: It would be nice if we could avoid this copy, if we know that the unwind context stays the same in both paths
Expand Down
14 changes: 0 additions & 14 deletions Userland/Libraries/LibJS/Bytecode/Pass/Peephole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,6 @@ void Peephole::perform(PassPipelineExecutable& executable)
if (next_instruction.type() == Instruction::Type::JumpIf) {
auto const& jump = static_cast<Op::JumpIf const&>(next_instruction);

if (instruction.type() == Instruction::Type::Not) {
auto const& not_ = static_cast<Op::Not const&>(instruction);
VERIFY(jump.condition() == not_.dst());
new_block->append<Op::JumpIfNot>(
not_.source_record().source_start_offset,
not_.source_record().source_end_offset,
not_.src(),
*jump.true_target(),
*jump.false_target());
++it;
VERIFY(it.at_end());
continue;
}

#define DO_FUSE_JUMP(PreOp, ...) \
if (instruction.type() == Instruction::Type::PreOp) { \
auto const& compare = static_cast<Op::PreOp const&>(instruction); \
Expand Down

0 comments on commit c4a0afb

Please sign in to comment.