icecat: add release icecat-140.7.0-1gnu1 for aramo

This commit is contained in:
Ark74 2026-01-18 00:16:18 -06:00
parent 17ba0259bf
commit 86c0c0ca33
156 changed files with 9131 additions and 4525 deletions

View file

@ -673,6 +673,36 @@ void ScriptPreloader::PrepareCacheWrite() {
PrepareCacheWriteInternal();
}
// A struct to hold reference to a CachedStencil and the snapshot of the
// CachedStencil::mLoadTime field.
// CachedStencil::mLoadTime field can be modified concurrently, and we need
// to create a snapshot, in order to sort scripts.
struct CachedStencilRefAndTime {
using CachedStencil = ScriptPreloader::CachedStencil;
CachedStencil* mStencil;
TimeStamp mLoadTime;
explicit CachedStencilRefAndTime(CachedStencil* aStencil)
: mStencil(aStencil), mLoadTime(aStencil->mLoadTime) {}
// For use with nsTArray::Sort.
//
// Orders scripts by script load time, so that scripts which are needed
// earlier are stored earlier, and scripts needed at approximately the
// same time are stored approximately contiguously.
struct Comparator {
bool Equals(const CachedStencilRefAndTime& a,
const CachedStencilRefAndTime& b) const {
return a.mLoadTime == b.mLoadTime;
}
bool LessThan(const CachedStencilRefAndTime& a,
const CachedStencilRefAndTime& b) const {
return a.mLoadTime < b.mLoadTime;
}
};
} JS_HAZ_NON_GC_POINTER;
// Writes out a script cache file for the scripts accessed during early
// startup in this session. The cache file is a little-endian binary file with
// the following format:
@ -726,19 +756,20 @@ Result<Ok, nsresult> ScriptPreloader::WriteCache() {
mMonitor.AssertNotCurrentThreadOwns();
MonitorAutoLock mal(mMonitor);
nsTArray<CachedStencil*> scripts;
nsTArray<CachedStencilRefAndTime> scriptRefs;
for (auto& script : IterHash(mScripts, Match<ScriptStatus::Saved>())) {
scripts.AppendElement(script);
scriptRefs.AppendElement(CachedStencilRefAndTime(script));
}
// Sort scripts by load time, with async loaded scripts before sync scripts.
// Since async scripts are always loaded immediately at startup, it helps to
// have them stored contiguously.
scripts.Sort(CachedStencil::Comparator());
scriptRefs.Sort(CachedStencilRefAndTime::Comparator());
OutputBuffer buf;
size_t offset = 0;
for (auto script : scripts) {
for (auto& scriptRef : scriptRefs) {
auto* script = scriptRef.mStencil;
script->mOffset = offset;
MOZ_DIAGNOSTIC_ASSERT(
JS::IsTranscodingBytecodeOffsetAligned(script->mOffset));
@ -768,7 +799,8 @@ Result<Ok, nsresult> ScriptPreloader::WriteCache() {
written += padding;
}
for (auto script : scripts) {
for (auto& scriptRef : scriptRefs) {
auto* script = scriptRef.mStencil;
MOZ_DIAGNOSTIC_ASSERT(JS::IsTranscodingBytecodeOffsetAligned(written));
MOZ_TRY(Write(fd, script->Range().begin().get(), script->mSize));