Bug 1562272 - Rename js::ScriptDataTable to RuntimeScriptDataTable. r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D37564

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ted Campbell 2019-07-10 14:49:19 +00:00
Родитель 95d34cd78d
Коммит 4b6fb00135
5 изменённых файлов: 21 добавлений и 18 удалений

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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();

Просмотреть файл

@ -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<RuntimeScriptData>;
static HashNumber hash(const Lookup& l) {
@ -1878,8 +1878,8 @@ struct SharedScriptDataHasher {
class AutoLockScriptData;
using ScriptDataTable =
HashSet<RuntimeScriptData*, SharedScriptDataHasher, SystemAllocPolicy>;
using RuntimeScriptDataTable =
HashSet<RuntimeScriptData*, RuntimeScriptDataHasher, SystemAllocPolicy>;
extern void SweepScriptData(JSRuntime* rt);

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -805,10 +805,11 @@ struct JSRuntime : public js::MallocProvider<JSRuntime> {
// within the runtime. This may be modified by threads using
// AutoLockScriptData.
private:
js::ScriptDataLockData<js::ScriptDataTable> scriptDataTable_;
js::ScriptDataLockData<js::RuntimeScriptDataTable> scriptDataTable_;
public:
js::ScriptDataTable& scriptDataTable(const js::AutoLockScriptData& lock) {
js::RuntimeScriptDataTable& scriptDataTable(
const js::AutoLockScriptData& lock) {
return scriptDataTable_.ref();
}