Use bytecode pinning with ScriptPreloader
Categories
(Core :: JavaScript Engine, task, P1)
Tracking
()
Tracking | Status | |
---|---|---|
firefox95 | --- | fixed |
People
(Reporter: tcampbell, Assigned: arai)
References
(Blocks 1 open bug)
Details
Attachments
(4 files)
Try to use the CompileOptions::usePinnedBytecode
option for ScriptPreloader since that mmap file is alive for as long as the runtime. This should reduce Base Content JS overhead.
Reporter | ||
Updated•3 years ago
|
Assignee | ||
Comment 1•3 years ago
|
||
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/a75f9be5cd6e Use bytecode pinning with ScriptPreloader. r=tcampbell
Comment 3•3 years ago
|
||
bugherder |
Comment 4•3 years ago
|
||
Backed out for causing talos crashes @ js::InternalCallOrConstruct
Assignee | ||
Comment 5•3 years ago
|
||
This accidentally enabled bytecode pinning also for StartupCache, because the same option is used for both StartupCache and ScriptPreloader when reading.
StartupCache has cache invalidation, and we cannot use bytecode pinning.
we should enable bytecode pinning only on ScriptPreloader cache.
Assignee | ||
Comment 6•3 years ago
|
||
also there's lifetime issue around shutdown, that ccov hit
we need to make sure the buffer is freed only after the JS is fully shutdown
Assignee | ||
Comment 8•3 years ago
|
||
ScriptPreloader singleton is freed on ShutdownPhase::XPCOMShutdownFinal phase,
and the mmap-ed file is munmap-ed there.
ScriptPreloader& ScriptPreloader::GetSingleton() {
static RefPtr<ScriptPreloader> singleton;
if (!singleton) {
if (XRE_IsParentProcess()) {
singleton = new ScriptPreloader();
singleton->mChildCache = &GetChildSingleton();
Unused << singleton->InitCache();
} else {
singleton = &GetChildSingleton();
}
ClearOnShutdown(&singleton);
}
return *singleton;
}
ScriptPreloader& ScriptPreloader::GetChildSingleton() {
static RefPtr<ScriptPreloader> singleton;
if (!singleton) {
singleton = new ScriptPreloader();
if (XRE_IsParentProcess()) {
Unused << singleton->InitCache(u"scriptCache-child"_ns);
}
ClearOnShutdown(&singleton);
}
return *singleton;
}
template <class SmartPtr>
inline void ClearOnShutdown(
SmartPtr* aPtr, ShutdownPhase aPhase = ShutdownPhase::XPCOMShutdownFinal) {
using namespace ClearOnShutdown_Internal;
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aPhase != ShutdownPhase::ShutdownPhase_Length);
InsertIntoShutdownList(new PointerClearer<SmartPtr>(aPtr), aPhase);
}
that happens before JS_ShutDown.
nsresult ShutdownXPCOM(nsIServiceManager* aServMgr) {
...
// Notify observers of xpcom shutting down
{
...
mozilla::KillClearOnShutdown(ShutdownPhase::XPCOMShutdownFinal);
...
}
...
nsCycleCollector_shutdown(shutdownCollect);
...
if (sInitializedJS) {
// Shut down the JS engine.
JS_ShutDown();
sInitializedJS = false;
}
ccov's failure happens in GC in nsCycleCollector_shutdown
.
ScriptPreloader
must be live longer than JS_ShutDown
, that means we need to have ShutdownPhase
after that.
Assignee | ||
Comment 9•3 years ago
|
||
Just moving the ScriptPreloader
shutdown after JS_ShutDown
causes another crash around SharedImmutableStringsCache
https://treeherder.mozilla.org/jobs?repo=try&group_state=expanded&revision=78d72c7a97bc8ceb661b7c65e1cc403de6847958&selectedTaskRun=DIiwUXxpReG5GkprStm8lg.0
there seems to be another dependency
Assignee | ||
Comment 10•3 years ago
|
||
Assignee | ||
Comment 12•3 years ago
|
||
mmap-ed file needs to be live longer than JS runtime, and it's different than
ScriptPreloader's lifetime.
Depends on D126633
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Comment 13•3 years ago
|
||
Pushed by arai_a@mac.com: https://hg.mozilla.org/integration/autoland/rev/12ed363393af Part 1: Remove unused ShutdownPhase::Last variant. r=kmag https://hg.mozilla.org/integration/autoland/rev/1fcebc384393 Part 2: Add ShutdownPhase after JS_ShutDown. r=kmag https://hg.mozilla.org/integration/autoland/rev/8b2fb3f5ed01 Part 3: Move AutoMemMap out of ScriptPreloader. r=kmag https://hg.mozilla.org/integration/autoland/rev/8bbe0638c3b7 Part 4: Use bytecode pinning with ScriptPreloader. r=tcampbell
Comment 14•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/12ed363393af
https://hg.mozilla.org/mozilla-central/rev/1fcebc384393
https://hg.mozilla.org/mozilla-central/rev/8b2fb3f5ed01
https://hg.mozilla.org/mozilla-central/rev/8bbe0638c3b7
Description
•