Bug 1449189 - Baldr: remove ExclusiveData indirection (r=bbouvier)
authorLuke Wagner <luke@mozilla.com>
Fri, 30 Mar 2018 11:16:52 -0500
changeset 464339 fbcb35097910b0520521316da5f1219faf8aced7
parent 464338 9b7418660fe23ccf235231f210608c3669b85ed3
child 464340 698a2f48d8b68cde5e9685417cad06a4f119c7ca
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbouvier
bugs1449189
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1449189 - Baldr: remove ExclusiveData indirection (r=bbouvier)
js/src/vm/Initialization.cpp
js/src/wasm/WasmInstance.cpp
js/src/wasm/WasmInstance.h
js/src/wasm/WasmProcess.cpp
js/src/wasm/WasmProcess.h
--- a/js/src/vm/Initialization.cpp
+++ b/js/src/vm/Initialization.cpp
@@ -100,18 +100,16 @@ JS::detail::InitWithFailureDiagnostic(bo
 #if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
     RETURN_IF_FAIL(js::oom::InitThreadType());
 #endif
 
     js::InitMallocAllocator();
 
     RETURN_IF_FAIL(js::Mutex::Init());
 
-    RETURN_IF_FAIL(js::wasm::Init());
-
     js::gc::InitMemorySubsystem(); // Ensure gc::SystemPageSize() works.
 
     RETURN_IF_FAIL(js::jit::InitProcessExecutableMemory());
 
     RETURN_IF_FAIL(js::MemoryProtectionExceptionHandler::install());
 
     RETURN_IF_FAIL(js::jit::InitializeIon());
 
--- a/js/src/wasm/WasmInstance.cpp
+++ b/js/src/wasm/WasmInstance.cpp
@@ -79,33 +79,17 @@ class SigIdSet
         p->value()--;
         if (!p->value()) {
             js_delete(p->key());
             map_.remove(p);
         }
     }
 };
 
-ExclusiveData<SigIdSet>* sigIdSet = nullptr;
-
-bool
-js::wasm::InitSignatureSet()
-{
-    MOZ_ASSERT(!sigIdSet);
-    sigIdSet = js_new<ExclusiveData<SigIdSet>>(mutexid::WasmSigIdSet);
-    return sigIdSet != nullptr;
-}
-
-void
-js::wasm::ReleaseSignatureSet()
-{
-    MOZ_ASSERT(sigIdSet);
-    js_delete(sigIdSet);
-    sigIdSet = nullptr;
-}
+ExclusiveData<SigIdSet> sigIdSet(mutexid::WasmSigIdSet);
 
 const void**
 Instance::addressOfSigId(const SigIdDesc& sigId) const
 {
     return (const void**)(globalData() + sigId.globalDataOffset());
 }
 
 FuncImportTls&
@@ -505,17 +489,17 @@ Instance::init(JSContext* cx)
         return false;
 
     for (const SharedTable& table : tables_) {
         if (table->movingGrowable() && !table->addMovingGrowObserver(cx, object_))
             return false;
     }
 
     if (!metadata().sigIds.empty()) {
-        ExclusiveData<SigIdSet>::Guard lockedSigIdSet = sigIdSet->lock();
+        ExclusiveData<SigIdSet>::Guard lockedSigIdSet = sigIdSet.lock();
 
         if (!lockedSigIdSet->ensureInitialized(cx))
             return false;
 
         for (const SigWithId& sig : metadata().sigIds) {
             const void* sigId;
             if (!lockedSigIdSet->allocateSigId(cx, sig, &sigId))
                 return false;
@@ -540,17 +524,17 @@ Instance::~Instance()
 
     for (unsigned i = 0; i < funcImports.length(); i++) {
         FuncImportTls& import = funcImportTls(funcImports[i]);
         if (import.baselineScript)
             import.baselineScript->removeDependentWasmImport(*this, i);
     }
 
     if (!metadata().sigIds.empty()) {
-        ExclusiveData<SigIdSet>::Guard lockedSigIdSet = sigIdSet->lock();
+        ExclusiveData<SigIdSet>::Guard lockedSigIdSet = sigIdSet.lock();
 
         for (const SigWithId& sig : metadata().sigIds) {
             if (const void* sigId = *addressOfSigId(sig.id))
                 lockedSigIdSet->deallocateSigId(sig, sigId);
         }
     }
 }
 
--- a/js/src/wasm/WasmInstance.h
+++ b/js/src/wasm/WasmInstance.h
@@ -168,15 +168,12 @@ class Instance
     static uint32_t currentMemory_i32(Instance* instance);
     static int32_t wait_i32(Instance* instance, uint32_t byteOffset, int32_t value, int64_t timeout);
     static int32_t wait_i64(Instance* instance, uint32_t byteOffset, int64_t value, int64_t timeout);
     static int32_t wake(Instance* instance, uint32_t byteOffset, int32_t count);
 };
 
 typedef UniquePtr<Instance> UniqueInstance;
 
-bool InitSignatureSet();
-void ReleaseSignatureSet();
-
 } // namespace wasm
 } // namespace js
 
 #endif // wasm_instance_h
--- a/js/src/wasm/WasmProcess.cpp
+++ b/js/src/wasm/WasmProcess.cpp
@@ -242,27 +242,20 @@ wasm::LookupCodeSegment(const void* pc, 
 
 const Code*
 wasm::LookupCode(const void* pc, const CodeRange** cr /* = nullptr */)
 {
     const CodeSegment* found = LookupCodeSegment(pc, cr);
     return found ? &found->code() : nullptr;
 }
 
-bool
-wasm::Init()
-{
-    return InitSignatureSet();
-}
-
 void
 wasm::ShutDown()
 {
     // If there are live runtimes then we are already pretty much leaking the
     // world, so to avoid spurious assertions (which are valid and valuable when
     // there are not live JSRuntimes), don't bother releasing anything here.
     if (JSRuntime::hasLiveRuntimes())
         return;
 
-    ReleaseSignatureSet();
     ReleaseBuiltinThunks();
     processCodeSegmentMap.freeAll();
 }
--- a/js/src/wasm/WasmProcess.h
+++ b/js/src/wasm/WasmProcess.h
@@ -50,18 +50,15 @@ bool
 RegisterCodeSegment(const CodeSegment* cs);
 
 void
 UnregisterCodeSegment(const CodeSegment* cs);
 
 // Called once before/after the last VM execution which could execute or compile
 // wasm.
 
-bool
-Init();
-
 void
 ShutDown();
 
 } // namespace wasm
 } // namespace js
 
 #endif // wasm_process_h