Commit 3a7759d3 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by Commit Bot

[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: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65458}
parent 7118c421
...@@ -25,6 +25,7 @@ WasmCode*& WasmImportWrapperCache::operator[]( ...@@ -25,6 +25,7 @@ WasmCode*& WasmImportWrapperCache::operator[](
WasmCode* WasmImportWrapperCache::Get(compiler::WasmImportCallKind kind, WasmCode* WasmImportWrapperCache::Get(compiler::WasmImportCallKind kind,
FunctionSig* sig) const { FunctionSig* sig) const {
base::MutexGuard lock(&mutex_);
auto it = entry_map_.find({kind, sig}); auto it = entry_map_.find({kind, sig});
DCHECK(it != entry_map_.end()); DCHECK(it != entry_map_.end());
return it->second; return it->second;
......
...@@ -49,14 +49,14 @@ class WasmImportWrapperCache { ...@@ -49,14 +49,14 @@ class WasmImportWrapperCache {
// cache. // cache.
V8_EXPORT_PRIVATE WasmCode*& operator[](const CacheKey& key); 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, V8_EXPORT_PRIVATE WasmCode* Get(compiler::WasmImportCallKind kind,
FunctionSig* sig) const; FunctionSig* sig) const;
~WasmImportWrapperCache(); ~WasmImportWrapperCache();
private: private:
base::Mutex mutex_; mutable base::Mutex mutex_;
std::unordered_map<CacheKey, WasmCode*, CacheKeyHash> entry_map_; std::unordered_map<CacheKey, WasmCode*, CacheKeyHash> entry_map_;
}; };
......
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