Commit 35fd638c authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[liftoff] Speed up slot interference check

This check leads to quadratic runtime, which is problematic on huge
stacks (>10000 entries in the reproducer).
Typically stacks are small, so we check the first 16 entries one by one,
and then increase the step size. This still gives fuzzers and other
tests a good chance to find bugs, but avoids quadratic runtime.

R=thibaudm@chromium.org

Bug: chromium:1344481
Change-Id: Iaa3684410939d4c56177eed62787b29e409c3136
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3842154Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82621}
parent d121e8ee
......@@ -769,9 +769,13 @@ bool SlotInterference(const VarState& a, const VarState& b) {
}
bool SlotInterference(const VarState& a, base::Vector<const VarState> v) {
return std::any_of(v.begin(), v.end(), [&a](const VarState& b) {
return SlotInterference(a, b);
});
// Check the first 16 entries in {v}, then increase the step size to avoid
// quadratic runtime on huge stacks. This logic checks 41 of the first 100
// slots, 77 of the first 1000 and 115 of the first 10000.
for (size_t idx = 0, end = v.size(); idx < end; idx += 1 + idx / 16) {
if (SlotInterference(a, v[idx])) return true;
}
return false;
}
} // namespace
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment