Revert "LibRegex: Remove orphaned save points in nested LookAhead"

This reverts commit f2678bfcb8.
This commit is contained in:
Tim Ledbetter 2025-03-14 17:14:41 +00:00 committed by Tim Ledbetter
parent 0a5f68eba6
commit b9ac99d2eb
Notes: github-actions[bot] 2025-03-14 19:58:28 +00:00
3 changed files with 0 additions and 23 deletions

View file

@ -217,12 +217,6 @@ ALWAYS_INLINE ExecutionResult OpCode_FailForks::execute(MatchInput const& input,
input.fail_counter += state.forks_since_last_save;
return ExecutionResult::Failed_ExecuteLowPrioForks;
}
ALWAYS_INLINE ExecutionResult OpCode_PopSaved::execute(MatchInput const& input, MatchState&) const
{
input.saved_positions.take_last();
input.saved_code_unit_positions.take_last();
return ExecutionResult::Failed_ExecuteLowPrioForks;
}
ALWAYS_INLINE ExecutionResult OpCode_Jump::execute(MatchInput const&, MatchState& state) const
{

View file

@ -31,7 +31,6 @@ using ByteCodeValueType = u64;
__ENUMERATE_OPCODE(ForkReplaceJump) \
__ENUMERATE_OPCODE(ForkReplaceStay) \
__ENUMERATE_OPCODE(FailForks) \
__ENUMERATE_OPCODE(PopSaved) \
__ENUMERATE_OPCODE(SaveLeftCaptureGroup) \
__ENUMERATE_OPCODE(SaveRightCaptureGroup) \
__ENUMERATE_OPCODE(SaveRightNamedCaptureGroup) \
@ -267,15 +266,9 @@ public:
switch (type) {
case LookAroundType::LookAhead: {
// SAVE
// FORKJUMP _BODY
// POPSAVED
// LABEL _BODY
// REGEXP BODY
// RESTORE
empend((ByteCodeValueType)OpCodeId::Save);
empend((ByteCodeValueType)OpCodeId::ForkJump);
empend((ByteCodeValueType)1);
empend((ByteCodeValueType)OpCodeId::PopSaved);
extend(move(lookaround_body));
empend((ByteCodeValueType)OpCodeId::Restore);
return;
@ -620,14 +613,6 @@ public:
ByteString arguments_string() const override { return ByteString::empty(); }
};
class OpCode_PopSaved final : public OpCode {
public:
ExecutionResult execute(MatchInput const& input, MatchState& state) const override;
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::PopSaved; }
ALWAYS_INLINE size_t size() const override { return 1; }
ByteString arguments_string() const override { return ByteString::empty(); }
};
class OpCode_Save final : public OpCode {
public:
ExecutionResult execute(MatchInput const& input, MatchState& state) const override;

View file

@ -738,8 +738,6 @@ TEST_CASE(ECMA262_match)
// Optimizer bug, ignoring an enabled trailing 'invert' when comparing blocks, ladybird#3421.
{ "[^]*[^]"sv, "i"sv, true },
{ "xx|...|...."sv, "cd"sv, false },
// Tests nested lookahead with alternation - verifies proper save/restore stack cleanup
{ "a(?=.(?=c)|b)b"sv, "ab"sv, true },
};
for (auto& test : tests) {