Commit 4e046cea authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[osr] Two fixes in the OSR code cache

1: Clear cache entry 0 before overwriting it to maintain bookkeeping of
the SharedFunctionInfo's OSR code cache state, which tracks how many
cache entries there are for this particular SFI.

2: When inserting into the code cache, we don't know in advance whether
the entry is already present or not (this could happen with multiple
simultaneous compile jobs from different closures of the same SFI).

Fixed: chromium:1314644
Bug: v8:12161
Change-Id: I0085a3a6e0c1879c3d483853220e654aa03660ac
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3578643Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Jakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79912}
parent b8473c52
......@@ -31,7 +31,11 @@ void OSROptimizedCodeCache::Insert(Isolate* isolate,
Handle<OSROptimizedCodeCache> osr_cache(native_context->osr_code_cache(),
isolate);
DCHECK_EQ(osr_cache->FindEntry(*shared, osr_offset), -1);
if (shared->osr_code_cache_state() == kNotCached) {
DCHECK_EQ(osr_cache->FindEntry(*shared, osr_offset), -1);
} else if (osr_cache->FindEntry(*shared, osr_offset) != -1) {
return; // Already cached for a different JSFunction.
}
STATIC_ASSERT(kEntryLength == 3);
int entry = -1;
......@@ -52,6 +56,7 @@ void OSROptimizedCodeCache::Insert(Isolate* isolate,
// TODO(mythria): We could use better mechanisms (like lru) to replace
// existing entries. Though we don't expect this to be a common case, so
// for now choosing to replace the first entry.
osr_cache->ClearEntry(0, isolate);
entry = 0;
}
}
......
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