mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-30 05:09:01 +00:00
LibJS/Bytecode: Turn JumpIf true/false
into unconditional Jump
This commit is contained in:
parent
7654da3851
commit
ca8dc8f61f
Notes:
sideshowbarker
2024-07-17 08:35:21 +09:00
Author: https://github.com/awesomekling
Commit: ca8dc8f61f
Pull-request: https://github.com/SerenityOS/serenity/pull/24276
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/shannonbooth
1 changed files with 12 additions and 0 deletions
|
@ -856,6 +856,18 @@ bool Generator::fuse_compare_and_jump(ScopedOperand const& condition, Label true
|
|||
|
||||
void Generator::emit_jump_if(ScopedOperand const& condition, Label true_target, Label false_target)
|
||||
{
|
||||
if (condition.operand().is_constant()) {
|
||||
auto value = m_constants[condition.operand().index()];
|
||||
if (value.is_boolean()) {
|
||||
if (value.as_bool()) {
|
||||
emit<Op::Jump>(true_target);
|
||||
} else {
|
||||
emit<Op::Jump>(false_target);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: It's only safe to fuse compare-and-jump if the condition is a temporary with no other dependents.
|
||||
if (condition.operand().is_register()
|
||||
&& condition.ref_count() == 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue