[wasm] Missing lock in import wrapper cache
Add a lock to prevent races between {WasmImportWrapperCache::Get} and the cache modification scope. R=clemensb@chromium.org Change-Id: Ife281c127c765d3ca57f58c975e15a76833983ca Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1965588 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#65458}
This commit is contained in:
parent
7118c421f5
commit
3a7759d320
@ -25,6 +25,7 @@ WasmCode*& WasmImportWrapperCache::operator[](
|
||||
|
||||
WasmCode* WasmImportWrapperCache::Get(compiler::WasmImportCallKind kind,
|
||||
FunctionSig* sig) const {
|
||||
base::MutexGuard lock(&mutex_);
|
||||
auto it = entry_map_.find({kind, sig});
|
||||
DCHECK(it != entry_map_.end());
|
||||
return it->second;
|
||||
|
@ -49,14 +49,14 @@ class WasmImportWrapperCache {
|
||||
// cache.
|
||||
V8_EXPORT_PRIVATE WasmCode*& operator[](const CacheKey& key);
|
||||
|
||||
// Assumes the key exists in the map.
|
||||
// Thread-safe. Assumes the key exists in the map.
|
||||
V8_EXPORT_PRIVATE WasmCode* Get(compiler::WasmImportCallKind kind,
|
||||
FunctionSig* sig) const;
|
||||
|
||||
~WasmImportWrapperCache();
|
||||
|
||||
private:
|
||||
base::Mutex mutex_;
|
||||
mutable base::Mutex mutex_;
|
||||
std::unordered_map<CacheKey, WasmCode*, CacheKeyHash> entry_map_;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user