#include "src/heap/object-stats.h"
#include <unordered_set>
#include "src/base/bits.h"
#include "src/codegen/assembler-inl.h"
#include "src/codegen/compilation-cache.h"
#include "src/common/globals.h"
#include "src/execution/isolate.h"
#include "src/heap/combined-heap.h"
#include "src/heap/heap-inl.h"
#include "src/heap/mark-compact.h"
#include "src/heap/marking-state-inl.h"
#include "src/logging/counters.h"
#include "src/objects/compilation-cache-table-inl.h"
#include "src/objects/heap-object.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/js-collection-inl.h"
#include "src/objects/literal-objects-inl.h"
#include "src/objects/prototype-info.h"
#include "src/objects/slots.h"
#include "src/objects/templates.h"
#include "src/objects/visitors.h"
#include "src/utils/memcopy.h"
#include "src/utils/ostreams.h"
namespace v8 {
namespace internal {
static base::LazyMutex object_stats_mutex = LAZY_MUTEX_INITIALIZER;
class FieldStatsCollector : public ObjectVisitorWithCageBases { … };
FieldStatsCollector::JSObjectFieldStats
FieldStatsCollector::GetInobjectFieldStats(Tagged<Map> map) { … }
void ObjectStats::ClearObjectStats(bool clear_last_time_stats) { … }
V8_NOINLINE static void PrintJSONArray(size_t* array, const int len) { … }
V8_NOINLINE static void DumpJSONArray(std::stringstream& stream, size_t* array,
const int len) { … }
void ObjectStats::PrintKeyAndId(const char* key, int gc_count) { … }
void ObjectStats::PrintInstanceTypeJSON(const char* key, int gc_count,
const char* name, int index) { … }
void ObjectStats::PrintJSON(const char* key) { … }
void ObjectStats::DumpInstanceTypeData(std::stringstream& stream,
const char* name, int index) { … }
void ObjectStats::Dump(std::stringstream& stream) { … }
void ObjectStats::CheckpointObjectStats() { … }
namespace {
int Log2ForSize(size_t size) { … }
}
int ObjectStats::HistogramIndexFromSize(size_t size) { … }
void ObjectStats::RecordObjectStats(InstanceType type, size_t size,
size_t over_allocated) { … }
void ObjectStats::RecordVirtualObjectStats(VirtualInstanceType type,
size_t size, size_t over_allocated) { … }
Isolate* ObjectStats::isolate() { … }
class ObjectStatsCollectorImpl { … };
ObjectStatsCollectorImpl::ObjectStatsCollectorImpl(Heap* heap,
ObjectStats* stats)
: … { … }
bool ObjectStatsCollectorImpl::ShouldRecordObject(Tagged<HeapObject> obj,
CowMode check_cow_array) { … }
template <typename Dictionary>
void ObjectStatsCollectorImpl::RecordHashTableVirtualObjectStats(
Tagged<HeapObject> parent, Tagged<Dictionary> hash_table,
ObjectStats::VirtualInstanceType type) { … }
bool ObjectStatsCollectorImpl::RecordSimpleVirtualObjectStats(
Tagged<HeapObject> parent, Tagged<HeapObject> obj,
ObjectStats::VirtualInstanceType type) { … }
bool ObjectStatsCollectorImpl::RecordVirtualObjectStats(
Tagged<HeapObject> parent, Tagged<HeapObject> obj,
ObjectStats::VirtualInstanceType type, size_t size, size_t over_allocated,
CowMode check_cow_array) { … }
void ObjectStatsCollectorImpl::RecordExternalResourceStats(
Address resource, ObjectStats::VirtualInstanceType type, size_t size) { … }
void ObjectStatsCollectorImpl::RecordVirtualAllocationSiteDetails(
Tagged<AllocationSite> site) { … }
void ObjectStatsCollectorImpl::RecordVirtualFunctionTemplateInfoDetails(
Tagged<FunctionTemplateInfo> fti) { … }
void ObjectStatsCollectorImpl::RecordVirtualJSGlobalObjectDetails(
Tagged<JSGlobalObject> object) { … }
void ObjectStatsCollectorImpl::RecordVirtualJSObjectDetails(
Tagged<JSObject> object) { … }
static ObjectStats::VirtualInstanceType GetFeedbackSlotType(
Tagged<MaybeObject> maybe_obj, FeedbackSlotKind kind, Isolate* isolate) { … }
void ObjectStatsCollectorImpl::RecordVirtualFeedbackVectorDetails(
Tagged<FeedbackVector> vector) { … }
void ObjectStatsCollectorImpl::RecordVirtualFixedArrayDetails(
Tagged<FixedArray> array) { … }
void ObjectStatsCollectorImpl::CollectStatistics(
Tagged<HeapObject> obj, Phase phase,
CollectFieldStats collect_field_stats) { … }
void ObjectStatsCollectorImpl::CollectGlobalStatistics() { … }
void ObjectStatsCollectorImpl::RecordObjectStats(Tagged<HeapObject> obj,
InstanceType type, size_t size,
size_t over_allocated) { … }
bool ObjectStatsCollectorImpl::CanRecordFixedArray(
Tagged<FixedArrayBase> array) { … }
bool ObjectStatsCollectorImpl::IsCowArray(Tagged<FixedArrayBase> array) { … }
bool ObjectStatsCollectorImpl::SameLiveness(Tagged<HeapObject> obj1,
Tagged<HeapObject> obj2) { … }
void ObjectStatsCollectorImpl::RecordVirtualMapDetails(Tagged<Map> map) { … }
void ObjectStatsCollectorImpl::RecordVirtualScriptDetails(
Tagged<Script> script) { … }
void ObjectStatsCollectorImpl::RecordVirtualExternalStringDetails(
Tagged<ExternalString> string) { … }
void ObjectStatsCollectorImpl::RecordVirtualSharedFunctionInfoDetails(
Tagged<SharedFunctionInfo> info) { … }
void ObjectStatsCollectorImpl::RecordVirtualArrayBoilerplateDescription(
Tagged<ArrayBoilerplateDescription> description) { … }
void ObjectStatsCollectorImpl::
RecordVirtualObjectsForConstantPoolOrEmbeddedObjects(
Tagged<HeapObject> parent, Tagged<HeapObject> object,
ObjectStats::VirtualInstanceType type) { … }
void ObjectStatsCollectorImpl::RecordVirtualBytecodeArrayDetails(
Tagged<BytecodeArray> bytecode) { … }
namespace {
ObjectStats::VirtualInstanceType CodeKindToVirtualInstanceType(CodeKind kind) { … }
}
void ObjectStatsCollectorImpl::RecordVirtualCodeDetails(
Tagged<InstructionStream> istream) { … }
void ObjectStatsCollectorImpl::RecordVirtualContext(Tagged<Context> context) { … }
class ObjectStatsVisitor { … };
namespace {
void IterateHeap(Heap* heap, ObjectStatsVisitor* visitor) { … }
}
void ObjectStatsCollector::Collect() { … }
}
}