|
13 | 13 | #include "src/objects/heap-number.h" |
14 | 14 | #include "src/objects/js-promise.h" |
15 | 15 | #include "src/objects/objects-inl.h" |
16 | | -#include "src/strings/string-hasher-inl.h" |
17 | 16 | #include "src/utils/ostreams.h" |
18 | 17 | #include "src/wasm/function-compiler.h" |
19 | 18 | #include "src/wasm/module-compiler.h" |
@@ -307,6 +306,11 @@ MaybeHandle<WasmModuleObject> WasmEngine::SyncCompile( |
307 | 306 | CreateWasmScript(isolate, bytes, native_module->module()->source_map_url, |
308 | 307 | native_module->module()->name); |
309 | 308 |
|
| 309 | + // Create the module object. |
| 310 | + // TODO(clemensb): For the same module (same bytes / same hash), we should |
| 311 | + // only have one WasmModuleObject. Otherwise, we might only set |
| 312 | + // breakpoints on a (potentially empty) subset of the instances. |
| 313 | + |
310 | 314 | // Create the compiled module object and populate with compiled functions |
311 | 315 | // and information needed at instantiation time. This object needs to be |
312 | 316 | // serializable. Instantiation may occur off a deserialized version of this |
@@ -691,42 +695,6 @@ std::shared_ptr<NativeModule> WasmEngine::NewNativeModule( |
691 | 695 | return native_module; |
692 | 696 | } |
693 | 697 |
|
694 | | -std::shared_ptr<NativeModule> WasmEngine::MaybeGetNativeModule( |
695 | | - ModuleOrigin origin, Vector<const uint8_t> wire_bytes) { |
696 | | - if (origin != kWasmOrigin) return nullptr; |
697 | | - base::MutexGuard lock(&mutex_); |
698 | | - while (true) { |
699 | | - auto it = native_module_cache_.find(wire_bytes); |
700 | | - if (it == native_module_cache_.end()) { |
701 | | - // Insert an empty entry to let other threads know that this |
702 | | - // {NativeModule} is already being created on another thread. |
703 | | - native_module_cache_.emplace(wire_bytes, std::weak_ptr<NativeModule>()); |
704 | | - return nullptr; |
705 | | - } |
706 | | - if (auto shared_native_module = it->second.lock()) { |
707 | | - return shared_native_module; |
708 | | - } |
709 | | - cache_cv_.Wait(&mutex_); |
710 | | - } |
711 | | -} |
712 | | - |
713 | | -void WasmEngine::UpdateNativeModuleCache( |
714 | | - std::shared_ptr<NativeModule> native_module, bool error) { |
715 | | - DCHECK_NOT_NULL(native_module); |
716 | | - if (native_module->module()->origin != kWasmOrigin) return; |
717 | | - Vector<const uint8_t> wire_bytes = native_module->wire_bytes(); |
718 | | - base::MutexGuard lock(&mutex_); |
719 | | - auto it = native_module_cache_.find(wire_bytes); |
720 | | - DCHECK_NE(it, native_module_cache_.end()); |
721 | | - DCHECK_NULL(it->second.lock()); |
722 | | - // The lifetime of the temporary entry's bytes is unknown. Use the new native |
723 | | - // module's owned copy of the bytes for the key instead. |
724 | | - native_module_cache_.erase(it); |
725 | | - native_module_cache_.emplace(wire_bytes, |
726 | | - error ? nullptr : std::move(native_module)); |
727 | | - cache_cv_.NotifyAll(); |
728 | | -} |
729 | | - |
730 | 698 | void WasmEngine::FreeNativeModule(NativeModule* native_module) { |
731 | 699 | base::MutexGuard guard(&mutex_); |
732 | 700 | auto it = native_modules_.find(native_module); |
@@ -767,14 +735,6 @@ void WasmEngine::FreeNativeModule(NativeModule* native_module) { |
767 | 735 | TRACE_CODE_GC("Native module %p died, reducing dead code objects to %zu.\n", |
768 | 736 | native_module, current_gc_info_->dead_code.size()); |
769 | 737 | } |
770 | | - auto cache_it = native_module_cache_.find(native_module->wire_bytes()); |
771 | | - // Not all native modules are stored in the cache currently. In particular |
772 | | - // asynchronous compilation and asmjs compilation results are not. So make |
773 | | - // sure that we only delete existing and expired entries. |
774 | | - if (cache_it != native_module_cache_.end() && cache_it->second.expired()) { |
775 | | - native_module_cache_.erase(cache_it); |
776 | | - cache_cv_.NotifyAll(); |
777 | | - } |
778 | 738 | native_modules_.erase(it); |
779 | 739 | } |
780 | 740 |
|
@@ -1012,13 +972,6 @@ std::shared_ptr<WasmEngine> WasmEngine::GetWasmEngine() { |
1012 | 972 | return *GetSharedWasmEngine(); |
1013 | 973 | } |
1014 | 974 |
|
1015 | | -size_t WasmEngine::WireBytesHasher::operator()( |
1016 | | - const Vector<const uint8_t>& bytes) const { |
1017 | | - return StringHasher::HashSequentialString( |
1018 | | - reinterpret_cast<const char*>(bytes.begin()), bytes.length(), |
1019 | | - kZeroHashSeed); |
1020 | | -} |
1021 | | - |
1022 | 975 | // {max_mem_pages} is declared in wasm-limits.h. |
1023 | 976 | uint32_t max_mem_pages() { |
1024 | 977 | STATIC_ASSERT(kV8MaxWasmMemoryPages <= kMaxUInt32); |
|
0 commit comments