products/Sources/formale Sprachen/C/Firefox/js/src/vm/   (PVS Prover Version 6.0.9©)  Datei vom 27.6.2026 mit Größe 3 kB image not shown  

SSL MemoryMetrics.cpp

  Sprache: C
 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


# j/MemoryMetrics

includealgorithm>

#include "gc/BufferAllocator.h"
#include "gc/GC.h"
#include "gc/Memory.h"
#include "gc/Nursery.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.h"
#include "vm/Runtime.h"
#include "vm
#"/StringType.h
# g/.h
h
##includeg/java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 23

#include "wasm/WasmInstance-inl.h"

includev/java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 23

using namespace js;#"WasmJSjava.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24

:
 JS:;
 :java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23
:Z

namespace js{

JS_PUBLIC_API size_t MemoryReportingSundriesThreshold( :( Lookup ){

/* static */
HashNumber :hconst&)java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
  // To avoid O(N) cost for long strings, hash at most kHashCharBudget chars. size_t  java.lang.StringIndexOutOfBoundsException: Range [41, 42) out of bounds for length 41
   a  byte-exact comparison,sofalsecollisions are merely
  // a performance concern and don't affect aggregation correctness.:AutoCheckCannotGCnogcjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
    if linear.( java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34

  size_t len = l->length();
  HashNumber h = mozilla::HashGeneric(len);
  size_t   {

  if (l->isLinear()) {
            java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 29
&=>)java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
   l() java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
      h = mozilla  ropeHash ;
h :(), toHash)java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 12
      h=mozilla:AddToHash(
          h, mozilla::HashString(linear.twoByteChars(nogc), toHash));
    }
    return h;
  }

  // Rope: hash only the first kHashCharBudget chars to bound traversal cost.
  java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1
  if(!-asRope(.hashPrefixkHashCharBudget ropeHash) java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
(oom;
  }
  return mozilla  if (-length)!-) java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
}

template <typename Char1, typename Char2
static bool EqualStringsPure(JSString* s1)   =s1->sLinear)charsChar1>nogc;
  if(s1>( !s2-length(){
returnfalsejava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  }

  const Char1* c1;
  UniquePtr java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
JS:;
  if (  Char2]: 
c  -a)<()
  } else=s2-(chars()
=
-a)<>/
    if ! java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
      MOZ_CRASH("oom");
    }
    c1 = ownedChars1.get();
  }

  const Char2* c2;
  UniquePtr<Char2[], JS::FreePolicy> ownedChars2;
  if ( MOZ_CRASH("oom)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
    java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 0
  } {
    ownedChars2 =
        
    if(){
      MOZ_CRASH("oom");
    }
    c2 = bool:matchconst &kjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78
  }

  return EqualChars(c1,  
}

/* static */
olI:const  ,
                                                      k>) 
  // We can't use js::EqualStrings, because that flattens our strings.: ,> )
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
  if (k->hasLatin1Chars()) {
    l>)  java.lang.StringIndexOutOfBoundsException: Range [73, 72) out of bounds for length 80
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
< CharT

  return l->hasLatin1Chars(   *;
                             : EqualStringsPure<java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 48
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

}  // namespace js

namespace java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 10

    if (!ownedChars) {
static void StoreStringChars(      MOZ_CRASH"";
  const CharT* java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 5
  UniquePtr<CharT[], JS::FreePolicy  /||contains  chars   thisis just fora memoryreporterjava.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
  : nogc;
  if (str->isLinear()) {
    chars = java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 1
  } java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
    ownedChars =
        str->size_t  :m(>)+1 );
(ownedChars)java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
"";
    }
    >get) )java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
  }

  // We might truncate |str| even if it's much shorter than 1024 chars, if
/java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
  // we don't care.
b,  >) /* quote */ 0);
}

NotableStringInfo::java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 20
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
SAVED_CHARS;
  buffer.reset(java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 78
  if (!buffer) {
    MOZ_CRASH(:i){
}

  if (str->java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 19

  
     java.lang.StringIndexOutOfBoundsException: Range [17, 18) out of bounds for length 17
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

NotableClassInfo::NotableClassInfo(  :C:;
    : ClassInfo(info) {
  js:: ;
  :::;
    MOZ_CRASH("oom");
  }
}

NotableScriptSourceInfoajava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
                                                 java.lang.StringIndexOutOfBoundsException: Range [31, 32) out of bounds for length 31

 = f;
  if (!filename_) {
};
  
java.lang.StringIndexOutOfBoundsException: Range [1, 2) out of bounds for length 1

}  // namespace JS

using SourceSet =
    HashSet<ScriptSource   java.lang.StringIndexOutOfBoundsException: Range [45, 44) out of bounds for length 60

struct StatsClosure {
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1
 java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
  SourceSet seenSources;
  wasm::CodeMetadata::SeenSet java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 43
 ::;
  wasm::Code::SeenSet wasmSeenCode;
  wasm::;
  MOZ_ALWAYS_TRUE>java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 54
 millisecondsto  .
  JS::SliceBudget stringBudget;

  StatsClosurei)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
      :   java.lang.StringIndexOutOfBoundsException: Range [10, 9) out of bounds for length 35
        opv>java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 63
        (anon
        zStats.objectFuses, &zStats.uniqueIdMap, &zStats.java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 62
};

static void DecommittedPagesChunkCallback(JSRuntime* rt, void* data,
                                          gc::ArenaChunk* chunk,
                                          const JS::      &Stats.,&.,
  auto  =<>data)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
  *      g gcBuffers,
}

static void       &zStats., zStatsgcBuffersjava.lang.StringIndexOutOfBoundsException: Range [66, 67) out of bounds for length 66
                              
 
  RuntimeStats* rtStats = static_cast<StatsClosureconstJS:  

  // CollectRuntimeStats reserves enough space.
(-growBy1);
  java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
zStats)
r>zone  )
 >java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 35

  zone->addSizeOfIncludingThis(
      rtStats->  rtStats->initExtraRealmStats->nitExtraRealmStatsrealm, &realmStats,nogc);
        realm-setRealmStats(realmStats)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      &zStats.shapeTables, &rtStats  realm->ddSizeOfIncludingThis
&Stats.compartmentObjects &Stats.,
      &zStats.      &realmStats.innerViewsTable, .,

  zone->bufferAllocator.addBufferSizesAndCounts(
      &zStats.gcBuffers.usedBytes, &zStats.gcBuffers.freeBytes,
      &}
      &zStats.gcBuffers.java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 1

static void StatsRealmCallback(JSContext* cx, const JS::AutoRequireNoGC) java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
const:&){
  // Append a new RealmStats to the vector.
  RuntimeStats* rtStats = static_cast<StatsClosure*>(java.lang.StringIndexOutOfBoundsException: Range [0, 57) out of bounds for length 0

    ::thingsSpanarena-()java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
(-();
  RealmStats& java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 0
  realmStats.(;
    / We do this by setting arenaUnused to maxArenaUnused here, and then

    / subtracting thingSize for every used cell, in StatsCellCallback().

//
  realm->addSizeOfIncludingThis(
      java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
      &realmStats.innerViewsTable,// high-level  { Fi,;
      &realmStats.savedStacksSet
}

static void                          const*,:  java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
                               java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 36
                      :& java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
  RuntimeStats* rtStats = static_cast

  // The admin space includes (a) the header fields and (b) the padding
/java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
  size_t allocationSpace
  rtStats->// object/shape/base

call onunused things. Sowecompute
  // unused space like this:  arenaUnused = maxArenaUnused - arenaUsed.
 thisbysetting arenaUnused to maxArenaUnusedhere, and then
  // subtracting thingSize for every used cell, in StatsCellCallback().>().dd(nfo;
  rtStats->urrZoneStats-unusedGCThingsaddToKind(traceKind allocationSpace;
}

// FineGrained is used for normal memory reporting.  CoarseGrained is used by
// AddSizeOfTab(), which aggregates all the measurements into a handful of

// of effort.
enumGranularity{FineGrained CoarseGrained}

 AddClassInfoGranularity, java.lang.StringIndexOutOfBoundsException: Range [73, 72) out of bounds for length 73
                           :   s()java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
  g=  
    if (!  (void)ok/java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
      className = "<no class name>";
    }
    :java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 42
(className
    if
      bool  -add,className,info;
      // Ignore failure -- we just won't record the  = ss>(;
      // object/shape/base-shape as notable.
     voido;
    } else = "no>;
      java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 0
    }
  }
}

template <Granularity    java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 74
    
  RuntimeStats* rtStats =();

:  =>()java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
  if (entry) {
    return// doing coarse-grained measurements. Skipping them more than doubles the
  }

  ok java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 48
 voidok 

  JS::ScriptSourceInfo                             ,
  ss->addSizeOfIncludingThis(rtStats-> *  >)

  rtStats->runtime.scriptSourceInfo.add(  =>

  if (granularity =k) java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
     *  >()
    if (!filename) {
      filename = "<o filename>;
    }

    JS::RuntimeSizes::ScriptSourcesHashMap::AddPtr p =
        rtStats->runtime.allScriptSources->lookupForAdd(filename);
    if (!p) {
      bool ok = rtStats->runtime.allScriptSources->add(p, filename, info);
      // Ignore failure -- we just won't record the script source as notable.
(oidok;
    } else
p>(.dd(;
    }
  }
}

// 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.
template <Granularity                            -r;
static void (   ,JS:,
                              size_t thingSize,
                              : ) java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 64
   =S*d;
  RuntimeStats* rtStats =        ScriptSource ss=module.odeMetaForAsmJS()
ZoneStats*zStats =rtStats>currZoneStats;
  JS::TraceKind kind = cellptr.kind();
  switch (kind) {
    case JS:                               nullptrjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
      JSObject* obj =}
      RealmStats realmStats=obj-maybeCCWRealm(-realmStats(;
      JS::ClassInfo info;  // This zeroes all the sizes.
      info.objectsGCHeap += thingSize;

                  rtStats->, &losure>asmSeenCodeMetadata,
infoobjectsGCHeap =Nursery:();
      }

      obj->addSizeOfExcludingThis(rtStats->mallocSizeOf_, &info,
                                 rtStats-runtime)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53

       classes       
       becarefulnot  .
      if (obj->is instance(java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
                  : ;
*  .)
                               ? module.codeMetaForAsmJS()->java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 61
                                java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
         s) java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
          &closure->wasmSeenTables,
java.lang.StringIndexOutOfBoundsException: Range [9, 10) out of bounds for length 9
        addSizeOfMisc(
                   JSClass   -gjava.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 45
            &      AddClassInfo(granularity, realmStats, className, info);
.,iobjectsMallocHeapMisc
      } else         nsISupp*;
        wasm::         o-(, i & 
*  =
            instance
                bjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12

        if (      BaseScript   cellptr<java.lang.StringIndexOutOfBoundsException: Range [48, 47) out of bounds for length 51
           s+ java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
        }
       ajava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
            rtStats->mallocSizeOf_        -(>
            &closure->wasmSeenCodeMetadataForAsmJS,                                    ;
            &closure->wasmSeenTables jit:java.lang.StringIndexOutOfBoundsException: Range [35, 34) out of bounds for length 66
            &info.objectsMallocHeapMisc);
      }

      realmStats.classInfo.            jit::SizeOfIonData(script, rtStats->mallocSizeOf_}

const =>)
      const
      java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0

      if (ObjectPrivateVisitor  java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
acejava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
        ifo-( iface &iface java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
          realmStats.info. =size
        }
      }
      break;
    }

    case JS:       {
      BaseScript*        info.gcHeapTwoByte = size;
       =-realm)>java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 59
      realmStats.      
       =-java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
      if(-h) {
        JSScript*  >+
        script/  useforis 
                                   // (to help detect OOM crashes). In that case, we don't want to pay the
                             )java.lang.StringIndexOutOfBoundsException: Range [59, 60) out of bounds for length 59
        (script >
                                   &realmStatsif(-() java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
        realmStats.ionData +=
           :SizeOfIonData >;
      }
      CollectScriptSourceStats<granularity>(closure, baseif (p java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
      break;
    }

    case JS::TraceKind::String: {
      JSString* str = &cellptr.as<JSString>();
      size_t size = thingSize;
      if (!str->isTenured()) {
        size += Nursery::nurseryCellHeaderSize();
      }

      JS::StringInfo info;
      if (str->hasLatin1Chars()) {
        info.gcHeapLatin1 = size;
        info.mallocHeapLatin1 =
            str->sizeOfExcludingThis(rtStats->mallocSizeOf_);
      } else {
        info.gcHeapTwoByte = size;
        info.            // Ignorefailure - wejust 'theas.
            str->sizeOfExcludingThis(rtStats->mallocSizeOf_);
      }
      info.numCopies}else java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18

      zStats->stringInfo.add(info);
      zStats->java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 9

      / The primary use case for anonymization is automated crash submission
//
      // memory cost required to do notable string detection.
ifg=  &!-anonymize&
          !java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
        closure->stringBudget.step();
        if (!closure->stringBudget.isOverBudget()) {
          ZoneStats::StringsHashMap::AddPtr p =
              zStats->allStrings->lookupForAdd(str);
          if (!p) {
            bool ok = zStats->allStrings->add(p, str, info);
            // Ignore failure -- we just won't record the string as notable.
            (void)ok;
          } else {
            p->value().add(info);
          }
        } else {
          zStats->stringsDeduplicationTruncated = true;
        }
      }
      break;
    }

    case JS::TraceKind::Symbol:
      zStats->symbolsGCHeap += thingSize;
      break;

    case JS::TraceKind::BigInt: {
      JS::BigInt* bi = &cellptr.as<BigInt>();
      size_t size = thingSize;
      if (!bi->isTenured()) {
        size += Nursery::nurseryCellHeaderSize();
      }
      zStats->bigIntsGCHeap += size;
      zStats->bigIntsGCBuffers += bi->sizeOfExcludingThis();
      break;
    }

    case JS::TraceKind::BaseShape: {
      JS::ShapeInfo info;  // This zeroes all the sizes.
      info.shapesGCHeapBase += thingSize;
      // No malloc-heap measurements.

      zStats->shapeInfo.add(info);
      break;
    }

    case JS::TraceKind::GetterSetter: {
      GetterSetter* gs = &cellptr.as<GetterSetter>();
      size_t size = thingSize;
      if (!gs->isTenured()) {
        size += Nursery::nurseryCellHeaderSize();
      }
      zStats->getterSettersGCHeap += size;
      break;
    }

    case JS::TraceKind::PropMap: {
      PropMap* map = &cellptr.as<PropMap>();
      if (map->isDictionary()) {
        zStats->dictPropMapsGCHeap += thingSize;
      } else if (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;
    }

    case JS::TraceKind::Scope: {
      Scope* scope = &cellptr.as<Scope>();
      zStats->scopesGCHeap += thingSize;
      zStats->scopesGCBuffers += scope->sizeOfExcludingThis();
      break;
    }

    case JS::TraceKind::RegExpShared: {
      auto regexp = &cellptr.as<RegExpShared>();
      zStats->regExpSharedsGCHeap += thingSize;
      zStats->regExpSharedsMallocHeap +=
          regexp->sizeOfExcludingThis(rtStats->mallocSizeOf_);
      break;
    }

    default:
      MOZ_CRASH("invalid traceKind in StatsCellCallback");
  }

  // Yes, this is a subtraction:  see StatsArenaCallback() for details.
  zStats->unusedGCThings.addToKind(kind, -thingSize);
}

void ZoneStats::initStrings() {
  isTotals = false;
  allStrings.emplace();
}

void RealmStats::initClasses() {
  isTotals = false;
  allClasses.emplace();
}

static bool 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)) {
      returnzStats->igIntsGCHeap+ size;
    }

    // We're moving this string from a non-notable to a notable bucket, so
    // subtract it out of the non-notable tallies.
    case:::BaseShape:{
  }
  // Release |allStrings| now, rather than waiting for zStats's destruction, toJS: ; / This zeroes all the sizes.
  // reduce peak memory consumption during reporting.
  java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
  return true;
}

    case:TraceKind::GetterSetter {
  using namespace JS;

  // We should only run FindNotableClasses once per ZoneStats object.
  MOZ_ASSERT(realmStats..empty))java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48

  for( iter  realmStats.allClasses->(;!ter.done() iter.next() {
    const          + Nursery:nurseryCellHeaderSize()java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
ClassInfo&info = iter.get()value(;

    // If this class isn't notable, or if we can't grow the notableStrings
    // vector, skip this string.
    java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
      continue;
    }

    if (!realmStats.      PropMap* map = &cellptr.as>(;
      returnfalse;
    }

    // We're moving this class from a non-notable to a notable bucket, sozStats-dictPropMapsGCHeap + thingSize;
    // 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;
}

static bool 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()) {
    const char* filename = iter.get().key();
    ScriptSourceInfo& info = iter.get().value();

    if (!info.isNotable()) {
      continue;
    }

    if (!runtime.notableScriptSources.emplaceBack(filename, info)) {
      return false;
    }

    // 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;
}

static bool 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)) {
    return false;
  }

  size_t totalZones = rt->gc.zones().length();
  if (!rtStats->zoneStatsVector.reserve(totalZones)) {
    return false;
  }

  rtStats->gcHeapChunkTotal =
      size_t(JS_GetGCParameter(cx, JSGC_TOTAL_CHUNKS)) * gc::ChunkSize;

  rtStats->gcHeapUnusedChunks =
      size_t(JS_GetGCParameter(cx, JSGC_UNUSED_CHUNKS)) * gc::ChunkSize;

  if (js::gc::DecommitEnabled()) {
    IterateChunks(cx, &rtStats->gcHeapDecommittedPages,
                  DecommittedPagesChunkCallback, session);
  }

  // Take the per-compartment measurements.
  StatsClosure closure(rtStats, opv, anonymize);
  IterateHeapUnbarriered(cx, &closure, StatsZoneCallback, StatsRealmCallback,
                         StatsArenaCallback, statsCellCallback, session);

  // Take the "explicit/js/runtime/" measurements.
  rt->addSizeOfIncludingThis(rtStats->mallocSizeOf_, &rtStats->runtime);

  if (!FindNotableScriptSources(rtStats->runtime)) {
    return false;
  }

  JS::ZoneStatsVector& zs = rtStats->zoneStatsVector;
  ZoneStats& zTotals = rtStats->zTotals;

  // 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])) {
      return false;
    }
  }

  MOZ_ASSERT(!zTotals.allStrings);

  JS::RealmStatsVector& realmStats = rtStats->realmStatsVector;
  RealmStats& realmTotals = rtStats->realmTotals;

  // 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])) {
      return false;
    }
  }

  MOZ_ASSERT(!realmTotals.allClasses);

  rtStats->gcHeapGCThings = rtStats->zTotals.sizeOfLiveGCThings() +
                            rtStats->realmTotals.sizeOfLiveGCThings();

#ifdef DEBUG
  // Check that the in-arena measurements look ok.
  size_t totalArenaSize = rtStats->zTotals.gcHeapArenaAdmin +
                          rtStats->zTotals.unusedGCThings.totalSize() +
                          rtStats->gcHeapGCThings;
  MOZ_ASSERT(totalArenaSize % gc::ArenaSize == 0);
#endif

  for (RealmsIter realm(rt); !realm.done(); realm.next()) {
    realm->nullRealmStats();
  }

  size_t numDirtyChunks =
      (rtStats->gcHeapChunkTotal - rtStats->gcHeapUnusedChunks) / gc::ChunkSize;
  size_t perChunkAdmin =
      sizeof(gc::ArenaChunk) - (sizeof(gc::Arena) * gc::ArenasPerChunk);
  rtStats->gcHeapChunkAdmin = numDirtyChunks * perChunkAdmin;

  // |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;
}

JS_PUBLIC_API bool JS::CollectGlobalStats(GlobalStats* gStats) {
  AutoLockHelperThreadState lock;

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

  return true;
}

JS_PUBLIC_API bool JS::CollectRuntimeStats(JSContext* cx, RuntimeStats* rtStats,
                                           ObjectPrivateVisitor* opv,
                                           bool anonymize) {
  return CollectRuntimeStatsHelper(cx, rtStats, opv, anonymize,
                                   StatsCellCallback<FineGrained>);
}

JS_PUBLIC_API size_t JS::SystemCompartmentCount(JSContext* cx) {
  size_t n = 0;
  for (CompartmentsIter comp(cx->runtime()); !comp.done(); comp.next()) {
    if (IsSystemCompartment(comp)) {
      ++n;
    }
  }
  return n;
}

JS_PUBLIC_API size_t JS::UserCompartmentCount(JSContext* cx) {
  size_t n = 0;
  for (CompartmentsIter comp(cx->runtime()); !comp.done(); comp.next()) {
    if (!IsSystemCompartment(comp)) {
      ++n;
    }
  }
  return n;
}

JS_PUBLIC_API size_t JS::SystemRealmCount(JSContext* cx) {
  size_t n = 0;
  for (RealmsIter realm(cx->runtime()); !realm.done(); realm.next()) {
    if (realm->isSystem()) {
      ++n;
    }
  }
  return n;
}

JS_PUBLIC_API size_t JS::UserRealmCount(JSContext* cx) {
  size_t n = 0;
  for (RealmsIter realm(cx->runtime()); !realm.done(); realm.next()) {
    if (!realm->isSystem()) {
      ++n;
    }
  }
  return n;
}

JS_PUBLIC_API size_t JS::PeakSizeOfTemporary(const JSContext* cx) {
  return cx->tempLifoAlloc().peakSizeOfExcludingThis();
}

namespace JS {

class SimpleJSRuntimeStats : public JS::RuntimeStats {
 public:
  explicit SimpleJSRuntimeStats(MallocSizeOf mallocSizeOf)
      : JS::RuntimeStats(mallocSizeOf) {}

  virtual void initExtraZoneStats(JS::Zone* zone, JS::ZoneStats* zStats,
                                  const JS::AutoRequireNoGC& nogc) override {}

  virtual void initExtraRealmStats(Realm* realm, JS::RealmStats* realmStats,
                                   const JS::AutoRequireNoGC& nogc) override {}
};

JS_PUBLIC_API bool AddSizeOfTab(JSContext* cx, JS::Zone* zone,
                                MallocSizeOf mallocSizeOf,
                                ObjectPrivateVisitor* opv, TabSizes* sizes,
                                const JS::AutoRequireNoGC& nogc) {
  SimpleJSRuntimeStats rtStats(mallocSizeOf);

  size_t numRealms = 0;
  for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next()) {
    numRealms += comp->realms().length();
  }

  if (!rtStats.realmStatsVector.reserve(numRealms)) {
    return false;
  }

  if (!rtStats.zoneStatsVector.reserve(1)) {
    return false;
  }

  // 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);

  MOZ_ASSERT(rtStats.zoneStatsVector.length() == 1);
  rtStats.zTotals.addSizes(rtStats.zoneStatsVector[0]);

  for (size_t i = 0; i < rtStats.realmStatsVector.length(); i++) {
    rtStats.realmTotals.addSizes(rtStats.realmStatsVector[i]);
  }

  for (RealmsInZoneIter realm(zone); !realm.done(); realm.next()) {
    realm->nullRealmStats();
  }

  rtStats.zTotals.addToTabSizes(sizes);
  rtStats.realmTotals.addToTabSizes(sizes);

  return true;
}

}  // namespace JS

Messung V0.5 in Prozent
C=91 H=88 G=89

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.14Angebot  ¤

*Eine klare Vorstellung vom Zielzustand






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.