Commit 1976cbfb authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[compiler] Predictable compilation dependency installation

--predictable requires deterministic heap allocation sequences.
Guarantee these for compilation dependency installation by sorting the
dependency list if --predictable is enabled.

Bug: v8:12397
Change-Id: Ia4660f2249a1c3390a932ae057a5b4d4537497ab
Fixed: v8:12447
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3306488
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78158}
parent f4e02f26
...@@ -119,6 +119,11 @@ class PendingDependencies final { ...@@ -119,6 +119,11 @@ class PendingDependencies final {
} }
void InstallAll(Isolate* isolate, Handle<Code> code) { void InstallAll(Isolate* isolate, Handle<Code> code) {
if (V8_UNLIKELY(FLAG_predictable)) {
InstallAllPredictable(isolate, code);
return;
}
// With deduplication done we no longer rely on the object address for // With deduplication done we no longer rely on the object address for
// hashing. // hashing.
AllowGarbageCollection yes_gc; AllowGarbageCollection yes_gc;
...@@ -128,6 +133,27 @@ class PendingDependencies final { ...@@ -128,6 +133,27 @@ class PendingDependencies final {
} }
} }
void InstallAllPredictable(Isolate* isolate, Handle<Code> code) {
CHECK(FLAG_predictable);
// First, guarantee predictable iteration order.
using HandleAndGroup =
std::pair<Handle<HeapObject>, DependentCode::DependencyGroups>;
std::vector<HandleAndGroup> entries(deps_.begin(), deps_.end());
std::sort(entries.begin(), entries.end(),
[](const HandleAndGroup& lhs, const HandleAndGroup& rhs) {
return lhs.first->ptr() < rhs.first->ptr();
});
// With deduplication done we no longer rely on the object address for
// hashing.
AllowGarbageCollection yes_gc;
for (const auto& o_and_g : entries) {
DependentCode::InstallDependency(isolate, code, o_and_g.first,
o_and_g.second);
}
}
private: private:
struct HandleHash { struct HandleHash {
size_t operator()(const Handle<HeapObject>& x) const { size_t operator()(const Handle<HeapObject>& x) const {
......
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