mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:37:37 +00:00
Revert "LibJS/Bytecode: Don't fuse unrelated compare and jump in peephole pass"
This reverts commit c1dbde72e9
.
This commit is contained in:
parent
baf359354b
commit
ea0b7192fa
2 changed files with 21 additions and 28 deletions
|
@ -40,29 +40,32 @@ void Peephole::perform(PassPipelineExecutable& executable)
|
||||||
|
|
||||||
if (instruction.type() == Instruction::Type::Not) {
|
if (instruction.type() == Instruction::Type::Not) {
|
||||||
auto const& not_ = static_cast<Op::Not const&>(instruction);
|
auto const& not_ = static_cast<Op::Not const&>(instruction);
|
||||||
if (jump.condition() != not_.dst()) {
|
VERIFY(jump.condition() == not_.dst());
|
||||||
auto slot_offset = new_block->size();
|
new_block->append<Op::JumpIfNot>(
|
||||||
new_block->grow(not_.length());
|
not_.source_record().source_start_offset,
|
||||||
memcpy(new_block->data() + slot_offset, ¬_, not_.length());
|
not_.source_record().source_end_offset,
|
||||||
continue;
|
not_.src(),
|
||||||
}
|
*jump.true_target(),
|
||||||
|
*jump.false_target());
|
||||||
|
++it;
|
||||||
|
VERIFY(it.at_end());
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DO_FUSE_JUMP(PreOp, ...) \
|
#define DO_FUSE_JUMP(PreOp, ...) \
|
||||||
if (instruction.type() == Instruction::Type::PreOp) { \
|
if (instruction.type() == Instruction::Type::PreOp) { \
|
||||||
auto const& compare = static_cast<Op::PreOp const&>(instruction); \
|
auto const& compare = static_cast<Op::PreOp const&>(instruction); \
|
||||||
if (jump.condition() == compare.dst()) { \
|
VERIFY(jump.condition() == compare.dst()); \
|
||||||
new_block->append<Op::Jump##PreOp>( \
|
new_block->append<Op::Jump##PreOp>( \
|
||||||
compare.source_record().source_start_offset, \
|
compare.source_record().source_start_offset, \
|
||||||
compare.source_record().source_end_offset, \
|
compare.source_record().source_end_offset, \
|
||||||
compare.lhs(), \
|
compare.lhs(), \
|
||||||
compare.rhs(), \
|
compare.rhs(), \
|
||||||
*jump.true_target(), \
|
*jump.true_target(), \
|
||||||
*jump.false_target()); \
|
*jump.false_target()); \
|
||||||
++it; \
|
++it; \
|
||||||
VERIFY(it.at_end()); \
|
VERIFY(it.at_end()); \
|
||||||
continue; \
|
continue; \
|
||||||
} \
|
|
||||||
}
|
}
|
||||||
JS_ENUMERATE_FUSABLE_BINARY_OPS(DO_FUSE_JUMP)
|
JS_ENUMERATE_FUSABLE_BINARY_OPS(DO_FUSE_JUMP)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
test("Don't fuse unrelated jump and compare", () => {
|
|
||||||
function go(a) {
|
|
||||||
a < 3;
|
|
||||||
a &&= 1;
|
|
||||||
|
|
||||||
a < 3;
|
|
||||||
a ||= 1;
|
|
||||||
}
|
|
||||||
go();
|
|
||||||
});
|
|
Loading…
Add table
Add a link
Reference in a new issue