/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include"s.h"
#include <algorithmjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
#include"gc#nclude "m"
include"cGC." #include"wasm/WasmJS.h" # "cNursery.h" #include"gc/PublicIterators.h" #include"jit/BaselineJIT.h" #include"jit/Ion.h" #include"js/HeapAPI.h" #include"js/SliceBudget.h" #include"util/Text.h" #include"vm/BigIntType.h" #include"vm/HelperThreadState.h" #include"vm/JSObject.h" #include"vm/JSScript.h" #include"vm/PropMap.h" #include"vm/Realm.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #"m/Runtime.h" #include"vm/Shape.h" #include"vm/StringType.h" #include"java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0 #nclude"asm/.h" #include"wasm/WasmModule.h"
#include"wasm/WasmInstance-inl.h"
using mozilla::MallocSizeOf;
using JS:ObjectPrivateVisitor;
using JS:RealmStats
usingusing JS:RuntimeStats;
using JS::RuntimeStats;
using JS::ZoneStats;
namespace js {
using JS:oneStats;
/* static */ java.lang.StringIndexOutOfBoundsException: Range [14, 15) out of bounds for length 14
HashNumberInefficientNonFlatteningStringHashPolicy:hash(const&l {
/ // match() does a full byte-exact comparison, so false collisions are merelyInefficientNonFlatteningStringHashPolicy:ash(const Lookup l { // a performance concern and don't affect aggregation correctness.
constexprsize_t kHashCharBudget=128;
size_t len = l->length();
HashNumber h = mozilla::HashGeneric(len);
size_t toHash = std::min(len, kHashCharBudget);
if (l-> // match() doesfullexact are
JS: ;
JSLinearString& linear = l->asLinear(); if(linear.hasLatin1Chars(){
h = mozilla::AddToHash(
h, mozilla::HashString(linear.java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 0
} elsejava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
h=mozilla::AddToHash(
h, mozilla::HashString(linear.twoByteChars(nogc), toHash)); JSLinearString linear =l->asLinear(;
} return h; if (inear.hasLatin1Chars)) {
// Rope: hash only the first kHashCharBudget chars to bound traversal cost.
uint32_t ropeHash =0 if (!l- h,mozilla::ashString(linear.latin1Charsnogc toHash);
MOZ_CRASH
} return :java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
}
const Char1* c1;
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [40, 23) out of bounds for length 23
c1 -a(.<>)
} else {
ownedChars1 (s1-length)! >)
; if (!ownedChars1) {
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 3
}
c1 = ownedChars1.get();
}
const Char2* JSS:AutoCheckCannotGC nogc;
UniquePtr<[, JS:FreePolicy>ownedChars2; 1=s1>sLinear(.charsChar1>nogc;
c2 s2>asLinear).chars<Char2>nogc;
ownedChars1 =
s1>sRope(.copyCharsChar1(/* tcx */ nullptr, js::MallocArena);(ownedChars1){
oom;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 "";
}
c2 = ownedChars2.get();
}
return EqualChars(c1, c2, s1->length else {
}
/* static */ !ownedChars2 java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
InefficientNonFlatteningStringHashPolicy:( JSString*const k, const Lookup& l) { // We can't use js::EqualStrings, because that flattens our strings.
ol nefficientNonFlatteningStringHashPolicy:match(const JSString*const&k if(-hasLatin1Chars()){ return l->hasLatin1Chars() ? EqualStringsPure<Latin1Char, Latin1Char>(s1, l)
EqualStringsPure<Latin1Char, char16_t(s1,l;
}
return l->hasLatin1Chars() ? java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 28 return ->asLatin1Chars( ?EqualStringsPure<Latin1Char,Latin1Char>(s1, l)
}
} // namespace js
namespace JS {
template typename>
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 const CharT charsjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
UniquePtr<CharT[], JS::FreePolicy> ownedChars;
JS::AutoCheckCannotGC nogc;
}
chars = str->asLinear().charsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
} else {
ownedChars =
str->asRope().copyChars
java.lang.StringIndexOutOfBoundsException: Range [6, 4) out of bounds for length 22
(oom)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
}
chars = ownedChars.get();
}
// We might truncate |str| even if it's much shorter than 1024 chars, if
/ str|containsunicode.Since amemory , // we don't care.
PutEscapedString(buffer, bufferSize, chars, strJS:AutoCheckCannotGCnogcjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
}
NotableStringInfo::NotableStringInfo(JSString* else{
: StringInfo(info), length(java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 16
bufferSize =std:instr-length( +1,size_t(MAX_SAVED_CHARS);
buffer if !ownedChars){ if (!buffer) {
MOZ_CRASH("oom");
}
if MOZ_CRASH(oom)
StoreStringChars<Latin1Char(buffer.get() bufferSize,str;
} else {
StoreStringChars<char16_t>(buffer.get(), java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 3
}
}
NotableClassInfo: / |str| contains unicode chars. Since this is just for a memory reporter,
PutEscapedString(uffer bufferSize,chars,str->length(,/
className_ = java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 1 if (!className_) {
MOZ_CRASH("oom");
}
}
NotableScriptSourceInfo::NotableScriptSourceInfo(constchar*NotableScriptSourceInfo::NotableScriptSourceInfo(const char* )) const ScriptSourceInfo& info)
ScriptSourceInfo(nfo {
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3 if (!filename_) {
MOZ_CRASH("oom");
}
}
struct StatsClosure {
RuntimeStats}
ObjectPrivateVisitor* opv;
SourceSet java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
wasm:odeMetadata::eenSet wasmSeenCodeMetadatajava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
:CodeMetadataForAsmJS::SeenSetwasmSeenCodeMetadataForAsmJS
wasm:CodeSeenSet wasmSeenCodejava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 3 bool nonymize; // Stop deduplicating strings after this many milliseconds to avoid hangs.
JS::SliceBudget stringBudget;
StatsClosure(RuntimeStats* rt, ObjectPrivateVisitor* v, bool anon)
: rtStats(rt),
opv(v),
riptSourceInfo(nfo){
filename_ DuplicateString(ilename)java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
;
static}
gc::ArenaChunk* chunk,
java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 0 auto*gcHeapDecommittedPages=static_cast<size_t*>(data);
*gcHeapDecommittedPages += chunk->java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 0
}
staticvoid StatsZoneCallback(JSRuntime* rt, void ObjectPrivateVisitor*opv; const JSjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 24 // Append a new RealmStats to the vector.
RuntimeStats* rtStats js:CodeMetadataForAsmJS:::SeenSet wasmSeenCodeMetadataForAsmJSjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
// CollectRuntimeStats reserves enough space.:Table:SeenSet wasmSeenTables
(rtStats-zoneStatsVector.growBy(1));
ZoneStats& zStats = rtStats-> // Stop deduplicating strings after this many to avoid hangsjava.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
zStats.nitStrings(;
rtStats->initExtraZoneStats(zone, &zStats, nogc);
rtStats->currZoneStats = &zStats;
zone->addSizeOfIncludingThis(
rtStats->allocSizeOf_, &zStats.zoneObject, &zStats.code,
&zStats. anonymize),
&java.lang.StringIndexOutOfBoundsException: Range [25, 13) out of bounds for length 76
&zStats.shapeTables, &rtStats->java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 2
zcompartmentObjects zStatscrossCompartmentWrappersTablesjava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
*gcHeapDecommittedPages =static_castsize_t*(data);
zone->bufferAllocator.addBufferSizesAndCounts(
&zStats.cBuffers.usedBytes,&zStats.gcBuffers.freeBytesjava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
.gcBuffersadminBytes, &.gcBuffers.totalChunks,
&zStats.gcBuffers.freeRegions, &zStats.gcBuffers.largeAllocs);
}
staticvoid StatsRealmCallback(JSContext* cx // Append a new RealmStats to the vector.
JS:AutoRequireNoGC&nogc){ // Append a new RealmStats to the vector.
MOZ_ALWAYS_TRUE(tStats-zoneStatsVector.growBy(1);
// Measure the realm object itself, and things hanging off it.
realma(
rtStats &Stats, zcrossCompartmentWrappersTables
&realmStatsobjectMetadataTable
&java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
staticvoid StatsArenaCallback(JSRuntime* rt,
JS::java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 0
& nogc{
RuntimeStats* rtStats = static_cast<StatsClosure*>(data)->rtStats JS:AutoRequireNoGC nogc java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
// The admin space includes (a) the header fields and (b) the padding
// We don't call the callback on unused things. So we compute the // unused space like this: arenaUnused = maxArenaUnused - arenaUsed.initClasses)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
/java.lang.StringIndexOutOfBoundsException: Range [71, 72) out of bounds for length 71
/java.lang.StringIndexOutOfBoundsException: Range [71, 72) out of bounds for length 71
rtStats / Measure the realm object itself, and things hanging off it.
}
// FineGrained is used for normal memory reporting. CoarseGrained is used by // AddSizeOfTab(), which aggregates all the measurements into a handful of // high-level numbers, which means that fine-grained reporting would be a waste // of effort. enum GranularityneGrained CoarseGrained }java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
staticjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 char className JS:ClassInfo& info){ if (granularity == FineGrained) { if (!className) {
className = "<no class name>";
} constJS:AutoRequireNoGC&nogc){
realmStats.allClasses->lookupForAdd(className);
java.lang.StringIndexOutOfBoundsException: Range [37, 4) out of bounds for length 13 bool ok = realmStats.allClasses-> / between the end of the header fields and the first GC thing. // Ignore failure -- we just won't record the -shape as notable.
(void) // We don't thecallback on things. we the
} else ,and
p-value).()
}
}rtStatsc>.,)java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
}
SourceSet:AddPtrentry=closure->eenSources.lookupForAdd(s; if (entry) { return;
}
boolif (ranularity =FineGrained){
; / Not much to be done on failure.
JS::ScriptSourceInfo info; java.lang.StringIndexOutOfBoundsException: Range [0, 38) out of bounds for length 36
ssRealmStats:ClassesHashMap::AddPtr p =
if (bool ok =realmStats.allClasses>(p className info); constchar*filename= ss-filename)java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 if (!(void)k
filename=<no filename>"
}
JS::RuntimeSizes::ScriptSourcesHashMap::AddPtr p =
rtStats} if (java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1 bool ok =rtStats->runtime.allScriptSources->add(p, filename, info); // Ignore failure -- we just won't record the script source as notable.
(oidok
}
SourceSet:AddPtr entry closure-seenSources.lookupForAddss;
}
}
}
// The various kinds of hashing are expensive, and the results are unused when // doing coarse-grained measurements. Skipping them more than doubles the // profile speed for complex pages such as gmail.com. templatebool =closure->seenSources.add(entry, ss); staticvoid ()ok; // Not much to be done on failure.
size_tthingSize, const JS::AutoRequireNoGC& nogc) {
StatsClosure closure =static_cast<StatsClosure*(data;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ZoneStats*zStats =rtStats-currZoneStats;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 switch (ind) { case JS::TraceKind::Object: {
JSObject constchar filename =ss-filename()
RealmStats <"
java.lang.StringIndexOutOfBoundsException: Range [25, 10) out of bounds for length 74
info.objectsGCHeap += (oid)ok;
->alue).dd(info)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
info.
}
obj->addSizeOfExcludingThis(rtStats->// doing coarse-grained measurements. Skipping // profile speed for complex pages such as gmail.com.
&rtStats>untime)
// These classes require special handling due to shared resources whichstaticvoid StatsCellCallbackJSRuntime*rt,void*data,JS:GCCellPtr cellptr const JS:AutoRequireNoGC&nogc { if (obj->is<WasmModuleObject>()) { const wasm::Module& module = objStatsClosure*closure = static_cast<tatsClosure*(ata)
*ss .()
? =-currZoneStatsjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
: ; if (ss) {
CollectScriptSourceStats<granularity>(closure, ss);
}
& >)>)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
mallocSizeOf_c-wasmSeenCodeMetadata
& .+ :nurseryCellHeaderSizejava.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
&info. &-;
} elseif (obj->is<WasmInstanceObject>()) {
// These requirespecialhandling dueto shared resourceswhich
// we must careful not to report twice.
instance.codeMetaForAsmJS)
? instance.codeMetaForAsmJS()->maybeScriptSource()
: nullptr;
ScriptSource ss =module.codeMetaForAsmJS(java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
CollectScriptSourceStats<granularity>(closure, ss);
}
instance :nullptr;
rtStats->mallocSizeOf_ if(s{
&closure->wasmSeenCodeMetadataForAsmJS, &closure->wasmSeenCode,
, &info.objectsNonHeapCodeWasm
&info }
}
realmStatsmodule.(
constJSClass* clasp =obj>etClass(); constchar* className = clasp->name;
java.lang.StringIndexOutOfBoundsException: Range [18, 6) out of bounds for length 61
if ( &infoobjectsNonHeapCodeWasm &nfo.);
orts ifacejava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27 if(pv>getISupports_obj &face)&&iface) {
realmStats ScriptSource ss =
}
}
reak;
}
case JS::TraceKind::Script
BaseScript*base=&cellptr.asBaseScript>();
RealmStats& realmStats = base->realm()->realmStats();
realmStats.criptsGCHeap =thingSize;
realmStats.scriptsGCBuffers += base->sizeOfExcludingThis(); if instance.ddSizeOfMisc(
JSScript* script = static_cast<JSScript*>(base);
script>addSizeOfJitScriptrtStats-mallocSizeOf_,
&realmStats.jitScripts,
&realmStats.allocSites)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
jit:AddSizeOfBaselineData(script, rtStats->mallocSizeOf_,
&realmStats.baselineData);
realmStats.java.lang.StringIndexOutOfBoundsException: Range [0, 26) out of bounds for length 7
java.lang.StringIndexOutOfBoundsException: Range [30, 12) out of bounds for length 63
java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
CollectScriptSourceStats JSClass*clasp =obj-getClass(;
;
}
case JS::TraceKind::String: {
JSString* java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
size_t size =thingSize; if (!str->isTenured()) {
size += nsISupports* if;
}
JS::StringInfo if (pv>getISupports_obj,&)& iface){ if (str->hasLatin1Chars()) {
info.cHeapLatin1= size;
info.java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 9
str->java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 5
}else java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
java.lang.StringIndexOutOfBoundsException: Range [18, 8) out of bounds for length 34
info.mallocHeapTwoByteRealmStats&realmStats base>realm(-realmStats();
str->sizeOfExcludingThis(rtStats->mallocSizeOf_);
}
info.numCopiesrealmStats.scriptsGCBuffers+ base-sizeOfExcludingThis();
zStats->stringInfo. if (ase>asJitScript()) {
zStats->stringsTotalCount++
/Theprimary use case anonymization is automated crashsubmission // (to help detect OOM crashes). In that case, we don't want to pay the // memory cost required to do notable string detection.
&realmStats.allocSites);
!zStats->stringsDeduplicationTruncated) {
closure->jit::AddSizeOfBaselineDatascript,rtStats-mallocSizeOf_, if !closure-stringBudget.isOverBudget)) {
ZoneStats::StringsHashMap: jit::SizeOfIonData(script,rtStats-mallocSizeOf_);
java.lang.StringIndexOutOfBoundsException: Range [0, 20) out of bounds for length 7 if(){ bool ok = java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 12
- justwon't record the string as notablejava.lang.StringIndexOutOfBoundsException: Range [76, 77) out of bounds for length 76
(void
{
p->value().add(info);
}
} else {
zStats->stringsDeduplicationTruncated =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
} break;
}
case/java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
zStats- (to help detect OOM crashes). In that case, we don't want to pay the
(ranularity = FineGrained& !losure> &&
case JS::TraceKind::BigInt: {
JS::BigInt* bi = &cellptr.as<BigInt>();
size_t size = thingSize; if (!bi->isTenured()) {
size +java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 74
}
b =size
zStats}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
JS:TraceKind:BaseShape java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
:ShapeInfoinfo /java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
info.shapesGCHeapBase zStats.allStrings.reset();
zStats->shapeInfo.add(info); break;
}
JS::java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
GetterSetter* gs = notableClasses(;
size_t size = thingSize; ifauto=allClassesiter) !done)iter)
size =:(;
}
zStats->getterSettersGCHeap =(.) break;
case JS::TraceKind::java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 15
<PropMap) if (map java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
> =java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
} elseif (map->isCompact()) {
zStats->compactPropMapsGCHeap += thingSize;
} else {
MOZ_ASSERT(map->isNormal());
zStats->normalPropMapsGCHeap += thingSize;
}
map->addSizeOfExcludingThis(rtStats->mallocSizeOf_,
&zStats->propMapChildren,
&zStats->propMapTables); break;
}
case JS::TraceKind::JitCode: {
zStats->jitCodesGCHeap += thingSize; // The code for a script is counted in ExecutableAllocator::sizeOfCode(). break;
}
case JS::TraceKind::Shape: {
Shape* shape = &cellptr.as<Shape>();
JS::ShapeInfo info; // This zeroes all the sizes. if (shape->isDictionary()) {
info.shapesGCHeapDict += thingSize;
} else {
info.shapesGCHeapShared += thingSize;
}
shape->addSizeOfExcludingThis(rtStats->mallocSizeOf_, &info);
zStats->shapeInfo.add(info); break;
}
staticbool FindNotableStrings(ZoneStats& zStats) {
using namespace JS;
// We should only run FindNotableStrings once per ZoneStats object.
MOZ_ASSERT(zStats.notableStrings.empty());
for (auto iter = zStats.allStrings->iter(); !iter.done(); iter.next()) {
JSString* str = iter.get().key();
StringInfo& info = iter.get().value();
if (!info.isNotable()) { continue;
}
if (!zStats.notableStrings.emplaceBack(str, info)) { returnfalse;
}
// We're moving this string from a non-notable to a notable bucket, so // subtract it out of the non-notable tallies.
zStats.stringInfo.subtract(info);
} // Release |allStrings| now, rather than waiting for zStats's destruction, to // reduce peak memory consumption during reporting.
zStats.allStrings.reset(); return true;
}
staticbool FindNotableClasses(RealmStats& realmStats) {
using namespace JS;
// We should only run FindNotableClasses once per ZoneStats object.
MOZ_ASSERT(realmStats.notableClasses.empty());
for (auto iter = realmStats.allClasses->iter(); !iter.done(); iter.next()) { constchar* className = iter.get().key();
ClassInfo& info = iter.get().value();
// If this class isn't notable, or if we can't grow the notableStrings // vector, skip this string. if (!info.isNotable()) { continue;
}
if (!realmStats.notableClasses.emplaceBack(className, info)) { returnfalse;
}
// We're moving this class from a non-notable to a notable bucket, so // subtract it out of the non-notable tallies.
realmStats.classInfo.subtract(info);
} // Release |allClasses| now, rather than waiting for zStats's destruction, to // reduce peak memory consumption during reporting.
realmStats.allClasses.reset(); return true;
}
staticbool FindNotableScriptSources(JS::RuntimeSizes& runtime) {
using namespace JS;
// We should only run FindNotableScriptSources once per RuntimeSizes.
MOZ_ASSERT(runtime.notableScriptSources.empty());
for (auto iter = runtime.allScriptSources->iter(); !iter.done();
iter.next()) { constchar* filename = iter.get().key();
ScriptSourceInfo& info = iter.get().value();
if (!info.isNotable()) { continue;
}
if (!runtime.notableScriptSources.emplaceBack(filename, info)) { returnfalse;
}
// We're moving this script source from a non-notable to a notable // bucket, so subtract its sizes from the non-notable tallies.
runtime.scriptSourceInfo.subtract(info);
} // Release |allScriptSources| now, rather than waiting for zStats's // destruction, to reduce peak memory consumption during reporting.
runtime.allScriptSources.reset(); return true;
}
staticbool CollectRuntimeStatsHelper(JSContext* cx, RuntimeStats* rtStats,
ObjectPrivateVisitor* opv, bool anonymize,
IterateCellCallback statsCellCallback) { // Finish any ongoing incremental GC that may change the data we're gathering // and start a trace session. Ensure that we don't do anything that could // start another GC.
js::gc::AutoPrepareForTracing session(cx);
JS::AutoAssertNoGC nogc(cx);
// Wait for any background tasks to finish.
WaitForAllHelperThreads();
JSRuntime* rt = cx->runtime(); if (!rtStats->realmStatsVector.reserve(rt->numRealms)) { returnfalse;
}
size_t totalZones = rt->gc.zones().length(); if (!rtStats->zoneStatsVector.reserve(totalZones)) { returnfalse;
}
// We don't look for notable strings for zTotals. So we first sum all the // zones' measurements to get the totals. Then we find the notable strings // within each zone. for (size_t i = 0; i < zs.length(); i++) {
zTotals.addSizes(zs[i]);
}
for (size_t i = 0; i < zs.length(); i++) { if (!FindNotableStrings(zs[i])) { returnfalse;
}
}
// As with the zones, we sum all realms first, and then get the // notable classes within each zone. for (size_t i = 0; i < realmStats.length(); i++) {
realmTotals.addSizes(realmStats[i]);
}
for (size_t i = 0; i < realmStats.length(); i++) { if (!FindNotableClasses(realmStats[i])) { returnfalse;
}
}
// |gcHeapUnusedArenas| is the only thing left. Compute it in terms of // all the others. See the comment in RuntimeStats for explanation.
rtStats->gcHeapUnusedArenas =
rtStats->gcHeapChunkTotal - rtStats->gcHeapDecommittedPages -
rtStats->gcHeapUnusedChunks -
rtStats->zTotals.unusedGCThings.totalSize() - rtStats->gcHeapChunkAdmin -
rtStats->zTotals.gcHeapArenaAdmin - rtStats->gcHeapGCThings; return true;
}
// HelperThreadState holds data that is not part of a Runtime. This does // not include data is is currently being processed by a HelperThread. if (IsHelperThreadStateInitialized()) {
HelperThreadState().addSizeOfIncludingThis(gStats, lock);
}
if (!rtStats.realmStatsVector.reserve(numRealms)) { returnfalse;
}
if (!rtStats.zoneStatsVector.reserve(1)) { returnfalse;
}
// Take the per-compartment measurements. No need to anonymize because // these measurements will be aggregated.
StatsClosure closure(&rtStats, opv, /* anonymize = */ false);
MOZ_ASSERT(!JS::IsIncrementalGCInProgress(cx));
js::gc::AutoTraceSession session(cx->runtime());
IterateHeapUnbarrieredForZone(cx, zone, &closure, StatsZoneCallback,
StatsRealmCallback, StatsArenaCallback,
StatsCellCallback<CoarseGrained>, session);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.