5 #ifndef V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_INL_H_ 6 #define V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_INL_H_ 8 #include "src/profiler/heap-snapshot-generator.h" 10 #include "src/profiler/heap-profiler.h" 11 #include "src/string-hasher-inl.h" 16 HeapEntry* HeapGraphEdge::from()
const {
17 return &snapshot()->entries()[from_index()];
20 Isolate* HeapGraphEdge::isolate()
const {
return to_entry_->isolate(); }
22 HeapSnapshot* HeapGraphEdge::snapshot()
const {
23 return to_entry_->snapshot();
26 int HeapEntry::set_children_index(
int index) {
28 int next_index = index + children_count_;
29 children_end_index_ = index;
33 void HeapEntry::add_child(HeapGraphEdge* edge) {
34 snapshot_->children()[children_end_index_++] = edge;
37 HeapGraphEdge* HeapEntry::child(
int i) {
return children_begin()[
i]; }
39 std::vector<HeapGraphEdge*>::iterator HeapEntry::children_begin()
const {
40 return index_ == 0 ? snapshot_->children().begin()
41 : snapshot_->entries()[index_ - 1].children_end();
44 std::vector<HeapGraphEdge*>::iterator HeapEntry::children_end()
const {
45 DCHECK_GE(children_end_index_, 0);
46 return snapshot_->children().begin() + children_end_index_;
49 int HeapEntry::children_count()
const {
50 return static_cast<int>(children_end() - children_begin());
53 Isolate* HeapEntry::isolate()
const {
return snapshot_->profiler()->isolate(); }
55 uint32_t HeapSnapshotJSONSerializer::StringHash(
const void*
string) {
56 const char* s =
reinterpret_cast<const char*
>(string);
57 int len =
static_cast<int>(strlen(s));
58 return StringHasher::HashSequentialString(s, len,
59 v8::internal::kZeroHashSeed);
62 int HeapSnapshotJSONSerializer::to_node_index(
const HeapEntry* e) {
63 return to_node_index(e->index());
66 int HeapSnapshotJSONSerializer::to_node_index(
int entry_index) {
67 return entry_index * kNodeFieldsCount;
73 #endif // V8_PROFILER_HEAP_SNAPSHOT_GENERATOR_INL_H_