OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/profiler/allocation-tracker.h" | 5 #include "src/profiler/allocation-tracker.h" |
6 | 6 |
7 #include "src/frames-inl.h" | 7 #include "src/frames-inl.h" |
8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 #include "src/profiler/heap-snapshot-generator-inl.h" | 9 #include "src/profiler/heap-snapshot-generator-inl.h" |
10 | 10 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 if (prev_range.start != 0) { | 183 if (prev_range.start != 0) { |
184 ranges_.insert(RangeMap::value_type(start, prev_range)); | 184 ranges_.insert(RangeMap::value_type(start, prev_range)); |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 | 188 |
189 void AllocationTracker::DeleteFunctionInfo(FunctionInfo** info) { | 189 void AllocationTracker::DeleteFunctionInfo(FunctionInfo** info) { |
190 delete *info; | 190 delete *info; |
191 } | 191 } |
192 | 192 |
193 | 193 AllocationTracker::AllocationTracker(HeapObjectsMap* ids, StringsStorage* names) |
194 AllocationTracker::AllocationTracker( | |
195 HeapObjectsMap* ids, StringsStorage* names) | |
196 : ids_(ids), | 194 : ids_(ids), |
197 names_(names), | 195 names_(names), |
198 id_to_function_info_index_(HashMap::PointersMatch), | 196 id_to_function_info_index_(base::HashMap::PointersMatch), |
199 info_index_for_other_state_(0) { | 197 info_index_for_other_state_(0) { |
200 FunctionInfo* info = new FunctionInfo(); | 198 FunctionInfo* info = new FunctionInfo(); |
201 info->name = "(root)"; | 199 info->name = "(root)"; |
202 function_info_list_.Add(info); | 200 function_info_list_.Add(info); |
203 } | 201 } |
204 | 202 |
205 | 203 |
206 AllocationTracker::~AllocationTracker() { | 204 AllocationTracker::~AllocationTracker() { |
207 unresolved_locations_.Iterate(DeleteUnresolvedLocation); | 205 unresolved_locations_.Iterate(DeleteUnresolvedLocation); |
208 function_info_list_.Iterate(&DeleteFunctionInfo); | 206 function_info_list_.Iterate(&DeleteFunctionInfo); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 252 |
255 | 253 |
256 static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) { | 254 static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) { |
257 return ComputeIntegerHash(static_cast<uint32_t>(id), | 255 return ComputeIntegerHash(static_cast<uint32_t>(id), |
258 v8::internal::kZeroHashSeed); | 256 v8::internal::kZeroHashSeed); |
259 } | 257 } |
260 | 258 |
261 | 259 |
262 unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared, | 260 unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared, |
263 SnapshotObjectId id) { | 261 SnapshotObjectId id) { |
264 HashMap::Entry* entry = id_to_function_info_index_.LookupOrInsert( | 262 base::HashMap::Entry* entry = id_to_function_info_index_.LookupOrInsert( |
265 reinterpret_cast<void*>(id), SnapshotObjectIdHash(id)); | 263 reinterpret_cast<void*>(id), SnapshotObjectIdHash(id)); |
266 if (entry->value == NULL) { | 264 if (entry->value == NULL) { |
267 FunctionInfo* info = new FunctionInfo(); | 265 FunctionInfo* info = new FunctionInfo(); |
268 info->name = names_->GetFunctionName(shared->DebugName()); | 266 info->name = names_->GetFunctionName(shared->DebugName()); |
269 info->function_id = id; | 267 info->function_id = id; |
270 if (shared->script()->IsScript()) { | 268 if (shared->script()->IsScript()) { |
271 Script* script = Script::cast(shared->script()); | 269 Script* script = Script::cast(shared->script()); |
272 if (script->name()->IsName()) { | 270 if (script->name()->IsName()) { |
273 Name* name = Name::cast(script->name()); | 271 Name* name = Name::cast(script->name()); |
274 info->script_name = names_->GetName(name); | 272 info->script_name = names_->GetName(name); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 const v8::WeakCallbackInfo<void>& data) { | 327 const v8::WeakCallbackInfo<void>& data) { |
330 UnresolvedLocation* loc = | 328 UnresolvedLocation* loc = |
331 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); | 329 reinterpret_cast<UnresolvedLocation*>(data.GetParameter()); |
332 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); | 330 GlobalHandles::Destroy(reinterpret_cast<Object**>(loc->script_.location())); |
333 loc->script_ = Handle<Script>::null(); | 331 loc->script_ = Handle<Script>::null(); |
334 } | 332 } |
335 | 333 |
336 | 334 |
337 } // namespace internal | 335 } // namespace internal |
338 } // namespace v8 | 336 } // namespace v8 |
OLD | NEW |