OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // one bucket. | 89 // one bucket. |
90 case OTHER: | 90 case OTHER: |
91 case EXTERNAL: | 91 case EXTERNAL: |
92 return program_entry_; | 92 return program_entry_; |
93 default: return NULL; | 93 default: return NULL; |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 | 97 |
98 HeapEntry* HeapGraphEdge::from() const { | 98 HeapEntry* HeapGraphEdge::from() const { |
99 return const_cast<HeapEntry*>( | 99 return &snapshot()->entries()[from_index_]; |
100 reinterpret_cast<const HeapEntry*>(this - child_index_) - 1); | |
101 } | 100 } |
102 | 101 |
103 | 102 |
| 103 HeapSnapshot* HeapGraphEdge::snapshot() const { |
| 104 return to_entry_->snapshot(); |
| 105 } |
| 106 |
| 107 |
| 108 int HeapEntry::index() const { |
| 109 return static_cast<int>(this - &snapshot_->entries().first()); |
| 110 } |
| 111 |
| 112 |
| 113 int HeapEntry::set_children_index(int index) { |
| 114 children_index_ = index; |
| 115 int next_index = index + children_count_; |
| 116 children_count_ = 0; |
| 117 return next_index; |
| 118 } |
| 119 |
| 120 |
| 121 int HeapEntry::set_retainers_index(int index) { |
| 122 retainers_index_ = index; |
| 123 int next_index = index + retainers_count_; |
| 124 retainers_count_ = 0; |
| 125 return next_index; |
| 126 } |
| 127 |
| 128 |
| 129 HeapGraphEdge** HeapEntry::children_arr() { |
| 130 ASSERT(children_index_ >= 0); |
| 131 return &snapshot_->children()[children_index_]; |
| 132 } |
| 133 |
| 134 |
| 135 HeapGraphEdge** HeapEntry::retainers_arr() { |
| 136 ASSERT(retainers_index_ >= 0); |
| 137 return &snapshot_->retainers()[retainers_index_]; |
| 138 } |
| 139 |
| 140 |
| 141 HeapEntry* HeapEntry::dominator() const { |
| 142 ASSERT(dominator_ >= 0); |
| 143 return &snapshot_->entries()[dominator_]; |
| 144 } |
| 145 |
| 146 |
104 SnapshotObjectId HeapObjectsMap::GetNthGcSubrootId(int delta) { | 147 SnapshotObjectId HeapObjectsMap::GetNthGcSubrootId(int delta) { |
105 return kGcRootsFirstSubrootId + delta * kObjectIdStep; | 148 return kGcRootsFirstSubrootId + delta * kObjectIdStep; |
106 } | 149 } |
107 | 150 |
108 | 151 |
109 HeapObject* V8HeapExplorer::GetNthGcSubrootObject(int delta) { | 152 HeapObject* V8HeapExplorer::GetNthGcSubrootObject(int delta) { |
110 return reinterpret_cast<HeapObject*>( | 153 return reinterpret_cast<HeapObject*>( |
111 reinterpret_cast<char*>(kFirstGcSubrootObject) + | 154 reinterpret_cast<char*>(kFirstGcSubrootObject) + |
112 delta * HeapObjectsMap::kObjectIdStep); | 155 delta * HeapObjectsMap::kObjectIdStep); |
113 } | 156 } |
114 | 157 |
115 | 158 |
116 int V8HeapExplorer::GetGcSubrootOrder(HeapObject* subroot) { | 159 int V8HeapExplorer::GetGcSubrootOrder(HeapObject* subroot) { |
117 return static_cast<int>( | 160 return static_cast<int>( |
118 (reinterpret_cast<char*>(subroot) - | 161 (reinterpret_cast<char*>(subroot) - |
119 reinterpret_cast<char*>(kFirstGcSubrootObject)) / | 162 reinterpret_cast<char*>(kFirstGcSubrootObject)) / |
120 HeapObjectsMap::kObjectIdStep); | 163 HeapObjectsMap::kObjectIdStep); |
121 } | 164 } |
122 | 165 |
123 } } // namespace v8::internal | 166 } } // namespace v8::internal |
124 | 167 |
125 #endif // V8_PROFILE_GENERATOR_INL_H_ | 168 #endif // V8_PROFILE_GENERATOR_INL_H_ |
OLD | NEW |