OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 28 matching lines...) Expand all Loading... |
39 AllocationTraceTree* tree, SnapshotObjectId shared_function_info_id) | 39 AllocationTraceTree* tree, SnapshotObjectId shared_function_info_id) |
40 : tree_(tree), | 40 : tree_(tree), |
41 function_id_(shared_function_info_id), | 41 function_id_(shared_function_info_id), |
42 total_size_(0), | 42 total_size_(0), |
43 allocation_count_(0), | 43 allocation_count_(0), |
44 id_(tree->next_node_id()) { | 44 id_(tree->next_node_id()) { |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 AllocationTraceNode::~AllocationTraceNode() { | 48 AllocationTraceNode::~AllocationTraceNode() { |
| 49 for (int i = 0; i < children_.length(); i++) delete children_[i]; |
49 } | 50 } |
50 | 51 |
51 | 52 |
52 AllocationTraceNode* AllocationTraceNode::FindChild(SnapshotObjectId id) { | 53 AllocationTraceNode* AllocationTraceNode::FindChild(SnapshotObjectId id) { |
53 for (int i = 0; i < children_.length(); i++) { | 54 for (int i = 0; i < children_.length(); i++) { |
54 AllocationTraceNode* node = children_[i]; | 55 AllocationTraceNode* node = children_[i]; |
55 if (node->function_id() == id) return node; | 56 if (node->function_id() == id) return node; |
56 } | 57 } |
57 return NULL; | 58 return NULL; |
58 } | 59 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 AllocationTracker::AllocationTracker( | 149 AllocationTracker::AllocationTracker( |
149 HeapObjectsMap* ids, StringsStorage* names) | 150 HeapObjectsMap* ids, StringsStorage* names) |
150 : ids_(ids), | 151 : ids_(ids), |
151 names_(names), | 152 names_(names), |
152 id_to_function_info_(AddressesMatch) { | 153 id_to_function_info_(AddressesMatch) { |
153 } | 154 } |
154 | 155 |
155 | 156 |
156 AllocationTracker::~AllocationTracker() { | 157 AllocationTracker::~AllocationTracker() { |
157 unresolved_locations_.Iterate(DeleteUnresolvedLocation); | 158 unresolved_locations_.Iterate(DeleteUnresolvedLocation); |
| 159 for (HashMap::Entry* p = id_to_function_info_.Start(); |
| 160 p != NULL; |
| 161 p = id_to_function_info_.Next(p)) { |
| 162 delete reinterpret_cast<AllocationTracker::FunctionInfo* >(p->value); |
| 163 } |
158 } | 164 } |
159 | 165 |
160 | 166 |
161 void AllocationTracker::PrepareForSerialization() { | 167 void AllocationTracker::PrepareForSerialization() { |
162 List<UnresolvedLocation*> copy(unresolved_locations_.length()); | 168 List<UnresolvedLocation*> copy(unresolved_locations_.length()); |
163 copy.AddAll(unresolved_locations_); | 169 copy.AddAll(unresolved_locations_); |
164 unresolved_locations_.Clear(); | 170 unresolved_locations_.Clear(); |
165 for (int i = 0; i < copy.length(); i++) { | 171 for (int i = 0; i < copy.length(); i++) { |
166 copy[i]->Resolve(); | 172 copy[i]->Resolve(); |
167 delete copy[i]; | 173 delete copy[i]; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 void AllocationTracker::UnresolvedLocation::HandleWeakScript( | 275 void AllocationTracker::UnresolvedLocation::HandleWeakScript( |
270 const v8::WeakCallbackData<v8::Value, void>& data) { | 276 const v8::WeakCallbackData<v8::Value, void>& data) { |
271 UnresolvedLocation* loc = | 277 UnresolvedLocation* loc = |
272 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); | 278 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); |
273 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); | 279 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); |
274 loc->script_ = Handle<Script>::null(); | 280 loc->script_ = Handle<Script>::null(); |
275 } | 281 } |
276 | 282 |
277 | 283 |
278 } } // namespace v8::internal | 284 } } // namespace v8::internal |
OLD | NEW |