OLD | NEW |
1 // Copyright 2009-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2009-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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 v8::RetainedObjectInfo* HeapProfiler::ExecuteWrapperClassCallback( | 65 v8::RetainedObjectInfo* HeapProfiler::ExecuteWrapperClassCallback( |
66 uint16_t class_id, Object** wrapper) { | 66 uint16_t class_id, Object** wrapper) { |
67 if (wrapper_callbacks_.length() <= class_id) return NULL; | 67 if (wrapper_callbacks_.length() <= class_id) return NULL; |
68 return wrapper_callbacks_[class_id]( | 68 return wrapper_callbacks_[class_id]( |
69 class_id, Utils::ToLocal(Handle<Object>(wrapper))); | 69 class_id, Utils::ToLocal(Handle<Object>(wrapper))); |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 HeapSnapshot* HeapProfiler::TakeSnapshot( | 73 HeapSnapshot* HeapProfiler::TakeSnapshot( |
74 const char* name, | 74 const char* name, |
75 int type, | |
76 v8::ActivityControl* control, | 75 v8::ActivityControl* control, |
77 v8::HeapProfiler::ObjectNameResolver* resolver) { | 76 v8::HeapProfiler::ObjectNameResolver* resolver) { |
78 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); | 77 HeapSnapshot* result = snapshots_->NewSnapshot(name, next_snapshot_uid_++); |
79 HeapSnapshot* result = | 78 { |
80 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); | 79 HeapSnapshotGenerator generator(result, control, resolver, heap()); |
81 bool generation_completed = true; | 80 if (!generator.GenerateSnapshot()) { |
82 switch (s_type) { | 81 delete result; |
83 case HeapSnapshot::kFull: { | 82 result = NULL; |
84 HeapSnapshotGenerator generator(result, control, resolver, heap()); | |
85 generation_completed = generator.GenerateSnapshot(); | |
86 break; | |
87 } | 83 } |
88 default: | |
89 UNREACHABLE(); | |
90 } | |
91 if (!generation_completed) { | |
92 delete result; | |
93 result = NULL; | |
94 } | 84 } |
95 snapshots_->SnapshotGenerationFinished(result); | 85 snapshots_->SnapshotGenerationFinished(result); |
96 return result; | 86 return result; |
97 } | 87 } |
98 | 88 |
99 | 89 |
100 HeapSnapshot* HeapProfiler::TakeSnapshot( | 90 HeapSnapshot* HeapProfiler::TakeSnapshot( |
101 String* name, | 91 String* name, |
102 int type, | |
103 v8::ActivityControl* control, | 92 v8::ActivityControl* control, |
104 v8::HeapProfiler::ObjectNameResolver* resolver) { | 93 v8::HeapProfiler::ObjectNameResolver* resolver) { |
105 return TakeSnapshot(snapshots_->names()->GetName(name), type, control, | 94 return TakeSnapshot(snapshots_->names()->GetName(name), control, resolver); |
106 resolver); | |
107 } | 95 } |
108 | 96 |
109 void HeapProfiler::StartHeapObjectsTracking() { | 97 void HeapProfiler::StartHeapObjectsTracking() { |
110 snapshots_->StartHeapObjectsTracking(); | 98 snapshots_->StartHeapObjectsTracking(); |
111 } | 99 } |
112 | 100 |
113 | 101 |
114 SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) { | 102 SnapshotObjectId HeapProfiler::PushHeapObjectsStats(OutputStream* stream) { |
115 return snapshots_->PushHeapObjectsStats(stream); | 103 return snapshots_->PushHeapObjectsStats(stream); |
116 } | 104 } |
(...skipping 30 matching lines...) Expand all Loading... |
147 return snapshots_->FindObjectId(HeapObject::cast(*obj)->address()); | 135 return snapshots_->FindObjectId(HeapObject::cast(*obj)->address()); |
148 } | 136 } |
149 | 137 |
150 | 138 |
151 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { | 139 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { |
152 snapshots_->ObjectMoveEvent(from, to); | 140 snapshots_->ObjectMoveEvent(from, to); |
153 } | 141 } |
154 | 142 |
155 | 143 |
156 } } // namespace v8::internal | 144 } } // namespace v8::internal |
OLD | NEW |