LibRegex: Use ReadonlySpan to peek into OpCode_Compare LUTs
Some checks are pending
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

By the time we're executing bytecode, we know the the bytecode will be
flattened. This means we can use ReadonlySpan to look into it instead of
DisjointChunks::spans(), which allocates.
This commit is contained in:
Andreas Kling 2025-04-13 18:26:57 +02:00 committed by Andreas Kling
parent c1c3b01a6c
commit 87ec5b32b0
Notes: github-actions[bot] 2025-04-14 15:41:09 +00:00
2 changed files with 7 additions and 1 deletions

View file

@ -357,6 +357,12 @@ public:
return true;
}
[[nodiscard]] ReadonlySpan<T> flat_data() const
{
VERIFY(m_chunks.size() <= 1);
return m_chunks.is_empty() ? ReadonlySpan<T> {} : m_chunks.first().span();
}
DisjointChunks release_slice(size_t start, size_t length) & { return move(*this).slice(start, length); }
DisjointChunks release_slice(size_t start) & { return move(*this).slice(start); }

View file

@ -540,7 +540,7 @@ ALWAYS_INLINE ExecutionResult OpCode_Compare::execute(MatchInput const& input, M
return ExecutionResult::Failed_ExecuteLowPrioForks;
auto count = m_bytecode->at(offset++);
auto range_data = m_bytecode->template spans<4>().slice(offset, count);
auto range_data = m_bytecode->flat_data().slice(offset, count);
offset += count;
auto ch = input.view[state.string_position_in_code_units];