diff --git a/js/src/vm/JSContext.h b/js/src/vm/JSContext.h index af0b22530dd5..3d6b3199dd9c 100644 --- a/js/src/vm/JSContext.h +++ b/js/src/vm/JSContext.h @@ -368,7 +368,7 @@ struct JSContext : public JS::RootingContext, js::SymbolRegistry& symbolRegistry() { return runtime_->symbolRegistry(); } // Methods to access runtime data that must be protected by locks. - js::ScriptDataTable& scriptDataTable(js::AutoLockScriptData& lock) { + js::RuntimeScriptDataTable& scriptDataTable(js::AutoLockScriptData& lock) { return runtime_->scriptDataTable(lock); } diff --git a/js/src/vm/JSScript.cpp b/js/src/vm/JSScript.cpp index 9a82a5fabd97..ec6819c00d10 100644 --- a/js/src/vm/JSScript.cpp +++ b/js/src/vm/JSScript.cpp @@ -3615,7 +3615,8 @@ bool JSScript::createSharedScriptData(JSContext* cx, uint32_t codeLength, void JSScript::freeScriptData() { scriptData_ = nullptr; } // Takes owndership of the script's scriptData_ and either adds it into the -// runtime's ScriptDataTable or frees it if a matching entry already exists. +// runtime's RuntimeScriptDataTable or frees it if a matching entry already +// exists. bool JSScript::shareScriptData(JSContext* cx) { RuntimeScriptData* rsd = scriptData(); MOZ_ASSERT(rsd); @@ -3623,11 +3624,12 @@ bool JSScript::shareScriptData(JSContext* cx) { // Calculate the hash before taking the lock. Because the data is reference // counted, it also will be freed after releasing the lock if necessary. - SharedScriptDataHasher::Lookup lookup(rsd); + RuntimeScriptDataHasher::Lookup lookup(rsd); AutoLockScriptData lock(cx->runtime()); - ScriptDataTable::AddPtr p = cx->scriptDataTable(lock).lookupForAdd(lookup); + RuntimeScriptDataTable::AddPtr p = + cx->scriptDataTable(lock).lookupForAdd(lookup); if (p) { MOZ_ASSERT(rsd != *p); scriptData_ = *p; @@ -3641,7 +3643,7 @@ bool JSScript::shareScriptData(JSContext* cx) { rsd->AddRef(); } - // Refs: JSScript, ScriptDataTable + // Refs: JSScript, RuntimeScriptDataTable MOZ_ASSERT(scriptData()->refCount() >= 2); return true; @@ -3652,9 +3654,9 @@ void js::SweepScriptData(JSRuntime* rt) { // i.e. when the only reference to them is from the table entry. AutoLockScriptData lock(rt); - ScriptDataTable& table = rt->scriptDataTable(lock); + RuntimeScriptDataTable& table = rt->scriptDataTable(lock); - for (ScriptDataTable::Enum e(table); !e.empty(); e.popFront()) { + for (RuntimeScriptDataTable::Enum e(table); !e.empty(); e.popFront()) { RuntimeScriptData* scriptData = e.front(); if (scriptData->refCount() == 1) { scriptData->Release(); @@ -3666,7 +3668,7 @@ void js::SweepScriptData(JSRuntime* rt) { void js::FreeScriptData(JSRuntime* rt) { AutoLockScriptData lock(rt); - ScriptDataTable& table = rt->scriptDataTable(lock); + RuntimeScriptDataTable& table = rt->scriptDataTable(lock); // The table should be empty unless the embedding leaked GC things. MOZ_ASSERT_IF(rt->gc.shutdownCollectedEverything(), table.empty()); @@ -3680,7 +3682,7 @@ void js::FreeScriptData(JSRuntime* rt) { } #endif - for (ScriptDataTable::Enum e(table); !e.empty(); e.popFront()) { + for (RuntimeScriptDataTable::Enum e(table); !e.empty(); e.popFront()) { #ifdef DEBUG if (++numLive <= maxCells) { RuntimeScriptData* scriptData = e.front(); diff --git a/js/src/vm/JSScript.h b/js/src/vm/JSScript.h index e65cd0cc15a0..70dc5de68d66 100644 --- a/js/src/vm/JSScript.h +++ b/js/src/vm/JSScript.h @@ -1766,7 +1766,7 @@ class alignas(uint32_t) SharedScriptData final { SharedScriptData& operator=(const SharedScriptData&) = delete; }; -struct SharedScriptDataHasher; +struct RuntimeScriptDataHasher; // Script data that is shareable across a JSRuntime. class RuntimeScriptData final { @@ -1786,7 +1786,7 @@ class RuntimeScriptData final { friend class ::JSScript; friend class js::SharedScriptData; - friend struct js::SharedScriptDataHasher; + friend struct js::RuntimeScriptDataHasher; private: // Layout of trailing arrays. @@ -1858,7 +1858,7 @@ class RuntimeScriptData final { // Two SharedScriptData instances may be de-duplicated if they have the same // data in their immutableData() span. This Hasher enables that comparison. -struct SharedScriptDataHasher { +struct RuntimeScriptDataHasher { using Lookup = RefPtr; static HashNumber hash(const Lookup& l) { @@ -1878,8 +1878,8 @@ struct SharedScriptDataHasher { class AutoLockScriptData; -using ScriptDataTable = - HashSet; +using RuntimeScriptDataTable = + HashSet; extern void SweepScriptData(JSRuntime* rt); diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index ac2755f3fb7f..395151644c8c 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -373,8 +373,8 @@ void JSRuntime::addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, AutoLockScriptData lock(this); rtSizes->scriptData += scriptDataTable(lock).shallowSizeOfExcludingThis(mallocSizeOf); - for (ScriptDataTable::Range r = scriptDataTable(lock).all(); !r.empty(); - r.popFront()) { + for (RuntimeScriptDataTable::Range r = scriptDataTable(lock).all(); + !r.empty(); r.popFront()) { rtSizes->scriptData += r.front()->sizeOfIncludingThis(mallocSizeOf); } } diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index 9e41f3d2b1ee..cbf888983b45 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -805,10 +805,11 @@ struct JSRuntime : public js::MallocProvider { // within the runtime. This may be modified by threads using // AutoLockScriptData. private: - js::ScriptDataLockData scriptDataTable_; + js::ScriptDataLockData scriptDataTable_; public: - js::ScriptDataTable& scriptDataTable(const js::AutoLockScriptData& lock) { + js::RuntimeScriptDataTable& scriptDataTable( + const js::AutoLockScriptData& lock) { return scriptDataTable_.ref(); }