28 #ifndef V8_HEAP_SNAPSHOT_GENERATOR_H_
29 #define V8_HEAP_SNAPSHOT_GENERATOR_H_
36 class AllocationTracker;
37 class AllocationTraceNode;
61 ASSERT(type_ == kElement || type_ == kHidden);
65 ASSERT(type_ == kContextVariable
72 INLINE(HeapEntry* from()
const);
73 HeapEntry*
to()
const {
return to_entry_; }
119 unsigned trace_node_id);
123 const char*
name() {
return name_; }
128 INLINE(
int index()
const);
130 INLINE(
int set_children_index(
int index));
132 children_arr()[children_count_++] = edge;
137 void SetIndexedReference(
139 void SetNamedReference(
143 const char* prefix,
const char* edge_name,
int max_depth,
int indent);
147 const char* TypeAsString();
150 int children_count_: 28;
157 unsigned trace_node_id_;
174 const char*
title() {
return title_; }
175 unsigned uid() {
return uid_; }
177 HeapEntry*
root() {
return &entries_[root_index_]; }
178 HeapEntry*
gc_roots() {
return &entries_[gc_roots_index_]; }
181 return &entries_[gc_subroot_indexes_[index]];
188 return max_snapshot_js_object_id_;
195 unsigned trace_node_id);
204 void Print(
int max_depth);
213 int natives_root_index_;
236 bool accessed =
true);
265 : id(id), addr(addr), size(size), accessed(
true) { }
267 : id(id), addr(addr), size(size), accessed(accessed) { }
273 struct TimeInterval {
282 List<EntryInfo> entries_;
283 List<TimeInterval> time_intervals_;
315 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(thing)),
316 v8::internal::kZeroHashSeed);
384 const char* GetSystemEntryName(
HeapObject*
object);
387 void ExtractJSGlobalProxyReferences(
int entry,
JSGlobalProxy* proxy);
388 void ExtractJSObjectReferences(
int entry,
JSObject* js_obj);
389 void ExtractStringReferences(
int entry,
String*
obj);
390 void ExtractContextReferences(
int entry,
Context* context);
391 void ExtractMapReferences(
int entry,
Map*
map);
392 void ExtractSharedFunctionInfoReferences(
int entry,
394 void ExtractScriptReferences(
int entry,
Script* script);
395 void ExtractAccessorPairReferences(
int entry,
AccessorPair* accessors);
396 void ExtractCodeCacheReferences(
int entry,
CodeCache* code_cache);
397 void ExtractCodeReferences(
int entry,
Code* code);
398 void ExtractBoxReferences(
int entry,
Box* box);
399 void ExtractCellReferences(
int entry,
Cell* cell);
400 void ExtractPropertyCellReferences(
int entry,
PropertyCell* cell);
401 void ExtractAllocationSiteReferences(
int entry,
AllocationSite* site);
402 void ExtractJSArrayBufferReferences(
int entry,
JSArrayBuffer* buffer);
403 void ExtractClosureReferences(
JSObject* js_obj,
int entry);
404 void ExtractPropertyReferences(
JSObject* js_obj,
int entry);
405 bool ExtractAccessorPairProperty(
JSObject* js_obj,
int entry,
407 void ExtractElementReferences(
JSObject* js_obj,
int entry);
408 void ExtractInternalReferences(
JSObject* js_obj,
int entry);
409 bool IsEssentialObject(
Object*
object);
410 void SetContextReference(
HeapObject* parent_obj,
415 void SetNativeBindReference(
HeapObject* parent_obj,
417 const char* reference_name,
419 void SetElementReference(
HeapObject* parent_obj,
423 void SetInternalReference(
HeapObject* parent_obj,
425 const char* reference_name,
427 int field_offset = -1);
428 void SetInternalReference(
HeapObject* parent_obj,
432 int field_offset = -1);
433 void SetHiddenReference(
HeapObject* parent_obj,
439 const char* reference_name,
442 void SetPropertyReference(
HeapObject* parent_obj,
444 Name* reference_name,
446 const char* name_format_string =
NULL,
447 int field_offset = -1);
448 void SetUserGlobalReference(
Object* user_global);
449 void SetRootGcRootsReference();
451 void SetGcSubrootReference(
453 const char* GetStrongGcSubrootName(
Object*
object);
454 void TagObject(
Object*
obj,
const char* tag);
458 static inline HeapObject* GetNthGcSubrootObject(
int delta);
459 static inline int GetGcSubrootOrder(
HeapObject* subroot);
473 static HeapObject*
const kFirstGcSubrootObject;
474 static HeapObject*
const kLastGcSubrootObject;
498 void FillRetainedObjects();
499 void FillImplicitReferences();
502 void SetRootNativeRootsReference();
503 void SetWrapperNativeReferences(
HeapObject* wrapper,
509 v8::internal::kZeroHashSeed);
511 static bool RetainedInfosMatch(
void* key1,
void* key2) {
512 return key1 == key2 ||
514 reinterpret_cast<v8::RetainedObjectInfo*>(key2));
516 INLINE(
static bool StringsMatch(
void* key1,
void* key2)) {
517 return strcmp(reinterpret_cast<char*>(key1),
518 reinterpret_cast<char*>(key2)) == 0;
527 bool embedder_queried_;
537 static HeapThing const kNativesRootObject;
554 bool FillReferences();
556 bool ProgressReport(
bool force =
false);
557 void SetProgressTotal(
int iterations_count);
566 int progress_counter_;
578 : snapshot_(snapshot),
579 strings_(StringsMatch),
587 INLINE(
static bool StringsMatch(
void* key1,
void* key2)) {
588 return strcmp(reinterpret_cast<char*>(key1),
589 reinterpret_cast<char*>(key2)) == 0;
592 INLINE(
static uint32_t StringHash(
const void*
string)) {
593 const char* s =
reinterpret_cast<const char*
>(string);
594 int len =
static_cast<int>(strlen(s));
596 s, len, v8::internal::kZeroHashSeed);
599 int GetStringId(
const char* s);
600 int entry_index(HeapEntry* e) {
return e->index() * kNodeFieldsCount; }
601 void SerializeEdge(HeapGraphEdge* edge,
bool first_edge);
602 void SerializeEdges();
603 void SerializeImpl();
604 void SerializeNode(HeapEntry* entry);
605 void SerializeNodes();
606 void SerializeSnapshot();
607 void SerializeTraceTree();
608 void SerializeTraceNode(AllocationTraceNode* node);
609 void SerializeTraceNodeInfos();
610 void SerializeString(
const unsigned char* s);
611 void SerializeStrings();
613 static const int kEdgeFieldsCount;
614 static const int kNodeFieldsCount;
616 HeapSnapshot* snapshot_;
620 OutputStreamWriter* writer_;
631 #endif // V8_HEAP_SNAPSHOT_GENERATOR_H_
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
virtual bool ProgressReport(bool force)=0
virtual HeapEntry * AllocateEntry(HeapThing ptr)=0
virtual ~V8HeapExplorer()
void TagBuiltinCodeObject(Code *code, const char *name)
void UpdateHeapObjectsMap()
size_t GetUsedMemorySize() const
static const SnapshotObjectId kGcRootsFirstSubrootId
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths true
virtual HeapEntry * AllocateEntry(HeapThing ptr)
HeapProfiler * profiler()
virtual intptr_t GetHash()=0
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf map
HeapEntry * AddEntry(Address address, HeapEntry::Type type, const char *name, size_t size)
void AddRootEntries(SnapshotFiller *filler)
HeapEntry * natives_root()
static const int kNoEntry
static SnapshotObjectId GetNthGcSubrootId(int delta)
void Print(int max_depth)
void TagCodeObject(Code *code)
static const SnapshotObjectId kNativesRootObjectId
SnapshotObjectId FindOrAddEntry(Address addr, unsigned int size, bool accessed=true)
TypeImpl< ZoneTypeConfig > Type
void UpdateObjectSize(Address addr, int size)
bool IterateAndExtractReferences(SnapshotFiller *filler)
int children_count() const
const char * name() const
size_t RawSnapshotSize() const
#define ASSERT(condition)
SnapshotObjectId PushHeapObjectsStats(OutputStream *stream)
V8HeapExplorer(HeapSnapshot *snapshot, SnapshottingProgressReportingInterface *progress, v8::HeapProfiler::ObjectNameResolver *resolver)
void set_name(const char *name)
void SetTag(Object *obj, const char *tag)
HeapEntry * AddNativesRootEntry()
virtual ~SnapshottingProgressReportingInterface()
unsigned trace_node_id() const
int EstimateObjectsCount()
static const SnapshotObjectId kGcRootsObjectId
SnapshotObjectId GenerateId(v8::RetainedObjectInfo *info)
HeapEntry * AddGcRootsEntry()
SnapshotObjectId last_assigned_id() const
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object size
bool MoveObject(Address from, Address to, int size)
NativeObjectsExplorer(HeapSnapshot *snapshot, SnapshottingProgressReportingInterface *progress)
List< HeapEntry > & entries()
const char * GetTag(Object *obj)
friend class HeapSnapshotTester
static const int kObjectIdStep
HeapSnapshotGenerator(HeapSnapshot *snapshot, v8::ActivityControl *control, v8::HeapProfiler::ObjectNameResolver *resolver, Heap *heap)
static String * GetConstructorName(JSObject *object)
HeapEntry * gc_subroot(int index)
bool Contains(Object *object)
uint32_t occupancy() const
static HeapObject *const kInternalRootObject
virtual void ProgressStep()=0
bool IterateAndExtractReferences(SnapshotFiller *filler)
HeapEntry * AddRootEntry()
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra code(assertions) for debugging") DEFINE_bool(code_comments
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
static const SnapshotObjectId kFirstAvailableObjectId
List< HeapGraphEdge > & edges()
SnapshotObjectId FindEntry(Address addr)
HeapSnapshot(HeapProfiler *profiler, const char *title, unsigned uid)
virtual ~HeapEntriesAllocator()
friend class HeapSnapshotJSONSerializerEnumerator
HeapEntry * GetEntryById(SnapshotObjectId id)
void AddRootEntries(SnapshotFiller *filler)
HeapEntry * AddEntry(HeapEntry::Type type, const char *name, SnapshotObjectId id, size_t size, unsigned trace_node_id)
void Serialize(v8::OutputStream *stream)
static uint32_t HashSequentialString(const schar *chars, int length, uint32_t seed)
void StopHeapObjectsTracking()
int FindUntrackedObjects()
uint32_t ComputeIntegerHash(uint32_t key, uint32_t seed)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
static const SnapshotObjectId kInternalRootObjectId
virtual ~NativeObjectsExplorer()
INLINE(static HeapObject *EnsureDoubleAligned(Heap *heap, HeapObject *object, int size))
List< HeapEntry * > * GetSortedEntriesList()
uint32_t SnapshotObjectId
void Pair(HeapThing thing, int entry)
HeapEntry * AddGcSubrootEntry(int tag)
TemplateHashMapImpl< FreeStoreAllocationPolicy > HashMap
void Print(const v8::FunctionCallbackInfo< v8::Value > &args)
HeapObjectsMap(Heap *heap)
void RememberLastJSObjectId()
List< HeapGraphEdge * > & children()
int EstimateObjectsCount(HeapIterator *iterator)
HeapSnapshot * snapshot()
friend class HeapSnapshotJSONSerializerIterator
SnapshotObjectId max_snapshot_js_object_id() const
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
void add_child(HeapGraphEdge *edge)
Vector< HeapGraphEdge * > children()
HeapSnapshotJSONSerializer(HeapSnapshot *snapshot)