| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 void HeapProfiler::TearDown() { | 61 void HeapProfiler::TearDown() { |
| 62 Isolate* isolate = Isolate::Current(); | 62 Isolate* isolate = Isolate::Current(); |
| 63 delete isolate->heap_profiler(); | 63 delete isolate->heap_profiler(); |
| 64 isolate->set_heap_profiler(NULL); | 64 isolate->set_heap_profiler(NULL); |
| 65 } | 65 } |
| 66 | 66 |
| 67 | 67 |
| 68 HeapSnapshot* HeapProfiler::TakeSnapshot(const char* name, | 68 HeapSnapshot* HeapProfiler::TakeSnapshot( |
| 69 int type, | 69 const char* name, |
| 70 v8::ActivityControl* control) { | 70 int type, |
| 71 v8::ActivityControl* control, |
| 72 v8::HeapProfiler::ObjectNameResolver* resolver) { |
| 71 ASSERT(Isolate::Current()->heap_profiler() != NULL); | 73 ASSERT(Isolate::Current()->heap_profiler() != NULL); |
| 72 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name, | 74 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name, |
| 73 type, | 75 type, |
| 74 control); | 76 control, |
| 77 resolver); |
| 75 } | 78 } |
| 76 | 79 |
| 77 | 80 |
| 78 HeapSnapshot* HeapProfiler::TakeSnapshot(String* name, | 81 HeapSnapshot* HeapProfiler::TakeSnapshot( |
| 79 int type, | 82 String* name, |
| 80 v8::ActivityControl* control) { | 83 int type, |
| 84 v8::ActivityControl* control, |
| 85 v8::HeapProfiler::ObjectNameResolver* resolver) { |
| 81 ASSERT(Isolate::Current()->heap_profiler() != NULL); | 86 ASSERT(Isolate::Current()->heap_profiler() != NULL); |
| 82 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name, | 87 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name, |
| 83 type, | 88 type, |
| 84 control); | 89 control, |
| 90 resolver); |
| 85 } | 91 } |
| 86 | 92 |
| 87 | 93 |
| 88 void HeapProfiler::StartHeapObjectsTracking() { | 94 void HeapProfiler::StartHeapObjectsTracking() { |
| 89 ASSERT(Isolate::Current()->heap_profiler() != NULL); | 95 ASSERT(Isolate::Current()->heap_profiler() != NULL); |
| 90 Isolate::Current()->heap_profiler()->StartHeapObjectsTrackingImpl(); | 96 Isolate::Current()->heap_profiler()->StartHeapObjectsTrackingImpl(); |
| 91 } | 97 } |
| 92 | 98 |
| 93 | 99 |
| 94 void HeapProfiler::StopHeapObjectsTracking() { | 100 void HeapProfiler::StopHeapObjectsTracking() { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 115 | 121 |
| 116 | 122 |
| 117 v8::RetainedObjectInfo* HeapProfiler::ExecuteWrapperClassCallback( | 123 v8::RetainedObjectInfo* HeapProfiler::ExecuteWrapperClassCallback( |
| 118 uint16_t class_id, Object** wrapper) { | 124 uint16_t class_id, Object** wrapper) { |
| 119 if (wrapper_callbacks_.length() <= class_id) return NULL; | 125 if (wrapper_callbacks_.length() <= class_id) return NULL; |
| 120 return wrapper_callbacks_[class_id]( | 126 return wrapper_callbacks_[class_id]( |
| 121 class_id, Utils::ToLocal(Handle<Object>(wrapper))); | 127 class_id, Utils::ToLocal(Handle<Object>(wrapper))); |
| 122 } | 128 } |
| 123 | 129 |
| 124 | 130 |
| 125 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, | 131 HeapSnapshot* HeapProfiler::TakeSnapshotImpl( |
| 126 int type, | 132 const char* name, |
| 127 v8::ActivityControl* control) { | 133 int type, |
| 134 v8::ActivityControl* control, |
| 135 v8::HeapProfiler::ObjectNameResolver* resolver) { |
| 128 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); | 136 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); |
| 129 HeapSnapshot* result = | 137 HeapSnapshot* result = |
| 130 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); | 138 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); |
| 131 bool generation_completed = true; | 139 bool generation_completed = true; |
| 132 switch (s_type) { | 140 switch (s_type) { |
| 133 case HeapSnapshot::kFull: { | 141 case HeapSnapshot::kFull: { |
| 134 HeapSnapshotGenerator generator(result, control); | 142 HeapSnapshotGenerator generator(result, control, resolver); |
| 135 generation_completed = generator.GenerateSnapshot(); | 143 generation_completed = generator.GenerateSnapshot(); |
| 136 break; | 144 break; |
| 137 } | 145 } |
| 138 default: | 146 default: |
| 139 UNREACHABLE(); | 147 UNREACHABLE(); |
| 140 } | 148 } |
| 141 if (!generation_completed) { | 149 if (!generation_completed) { |
| 142 delete result; | 150 delete result; |
| 143 result = NULL; | 151 result = NULL; |
| 144 } | 152 } |
| 145 snapshots_->SnapshotGenerationFinished(result); | 153 snapshots_->SnapshotGenerationFinished(result); |
| 146 return result; | 154 return result; |
| 147 } | 155 } |
| 148 | 156 |
| 149 | 157 |
| 150 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(String* name, | 158 HeapSnapshot* HeapProfiler::TakeSnapshotImpl( |
| 151 int type, | 159 String* name, |
| 152 v8::ActivityControl* control) { | 160 int type, |
| 153 return TakeSnapshotImpl(snapshots_->names()->GetName(name), type, control); | 161 v8::ActivityControl* control, |
| 162 v8::HeapProfiler::ObjectNameResolver* resolver) { |
| 163 return TakeSnapshotImpl(snapshots_->names()->GetName(name), type, control, |
| 164 resolver); |
| 154 } | 165 } |
| 155 | 166 |
| 156 void HeapProfiler::StartHeapObjectsTrackingImpl() { | 167 void HeapProfiler::StartHeapObjectsTrackingImpl() { |
| 157 snapshots_->StartHeapObjectsTracking(); | 168 snapshots_->StartHeapObjectsTracking(); |
| 158 } | 169 } |
| 159 | 170 |
| 160 | 171 |
| 161 SnapshotObjectId HeapProfiler::PushHeapObjectsStatsImpl(OutputStream* stream) { | 172 SnapshotObjectId HeapProfiler::PushHeapObjectsStatsImpl(OutputStream* stream) { |
| 162 return snapshots_->PushHeapObjectsStats(stream); | 173 return snapshots_->PushHeapObjectsStats(stream); |
| 163 } | 174 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 profiler->ResetSnapshots(); | 223 profiler->ResetSnapshots(); |
| 213 } | 224 } |
| 214 | 225 |
| 215 | 226 |
| 216 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { | 227 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { |
| 217 snapshots_->ObjectMoveEvent(from, to); | 228 snapshots_->ObjectMoveEvent(from, to); |
| 218 } | 229 } |
| 219 | 230 |
| 220 | 231 |
| 221 } } // namespace v8::internal | 232 } } // namespace v8::internal |
| OLD | NEW |