mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibRegex: Correct jump offset to the start of the loop block
Previously we were jumping to the new end of the previous block (created by the newly inserted ForkStay), correct the offset to jump to the correct block as shown in the comments. Fixes #12033.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
3de51a4b99
commit
bfe8f312f3
Notes:
sideshowbarker
2024-07-17 20:32:15 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/bfe8f312f36 Pull-request: https://github.com/SerenityOS/serenity/pull/12038 Issue: https://github.com/SerenityOS/serenity/issues/11940 Issue: https://github.com/SerenityOS/serenity/issues/12033
@@ -376,7 +376,7 @@ void Regex<Parser>::attempt_rewrite_loops_as_atomic_groups(BasicBlockList const&
|
||||
if (candidate.new_target_block.has_value()) {
|
||||
// Insert a fork-stay targeted at the second block.
|
||||
bytecode.insert(candidate.forking_block.start, (ByteCodeValueType)OpCodeId::ForkStay);
|
||||
bytecode.insert(candidate.forking_block.start + 1, candidate.new_target_block->start - candidate.forking_block.start);
|
||||
bytecode.insert(candidate.forking_block.start + 1, candidate.new_target_block->start - candidate.forking_block.start + 2);
|
||||
needed_patches.insert(candidate.forking_block.start, 2u);
|
||||
}
|
||||
}
|
||||
@@ -427,9 +427,9 @@ void Regex<Parser>::attempt_rewrite_loops_as_atomic_groups(BasicBlockList const&
|
||||
if (patch_it.key() == ip)
|
||||
return;
|
||||
|
||||
if (patch_point.value < 0 && target_offset < patch_it.key() && ip > patch_it.key())
|
||||
if (patch_point.value < 0 && target_offset <= patch_it.key() && ip > patch_it.key())
|
||||
bytecode[patch_point.offset] += (patch_point.should_negate ? 1 : -1) * (*patch_it);
|
||||
else if (patch_point.value > 0 && target_offset > patch_it.key() && ip < patch_it.key())
|
||||
else if (patch_point.value > 0 && target_offset >= patch_it.key() && ip < patch_it.key())
|
||||
bytecode[patch_point.offset] += (patch_point.should_negate ? -1 : 1) * (*patch_it);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user