| 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 15 matching lines...) Expand all Loading... |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "heap-profiler.h" | 30 #include "heap-profiler.h" |
| 31 #include "profile-generator.h" | 31 #include "profile-generator.h" |
| 32 | 32 |
| 33 namespace v8 { | 33 namespace v8 { |
| 34 namespace internal { | 34 namespace internal { |
| 35 | 35 |
| 36 HeapProfiler::HeapProfiler() | 36 HeapProfiler::HeapProfiler(Heap* heap) |
| 37 : snapshots_(new HeapSnapshotsCollection()), | 37 : snapshots_(new HeapSnapshotsCollection(heap)), |
| 38 next_snapshot_uid_(1) { | 38 next_snapshot_uid_(1) { |
| 39 } | 39 } |
| 40 | 40 |
| 41 | 41 |
| 42 HeapProfiler::~HeapProfiler() { | 42 HeapProfiler::~HeapProfiler() { |
| 43 delete snapshots_; | 43 delete snapshots_; |
| 44 } | 44 } |
| 45 | 45 |
| 46 | 46 |
| 47 void HeapProfiler::ResetSnapshots() { | 47 void HeapProfiler::ResetSnapshots() { |
| 48 Heap* the_heap = heap(); |
| 48 delete snapshots_; | 49 delete snapshots_; |
| 49 snapshots_ = new HeapSnapshotsCollection(); | 50 snapshots_ = new HeapSnapshotsCollection(the_heap); |
| 50 } | 51 } |
| 51 | 52 |
| 52 | 53 |
| 53 void HeapProfiler::SetUp() { | 54 void HeapProfiler::SetUp() { |
| 54 Isolate* isolate = Isolate::Current(); | 55 Isolate* isolate = Isolate::Current(); |
| 55 if (isolate->heap_profiler() == NULL) { | 56 if (isolate->heap_profiler() == NULL) { |
| 56 isolate->set_heap_profiler(new HeapProfiler()); | 57 isolate->set_heap_profiler(new HeapProfiler(isolate->heap())); |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 | 60 |
| 60 | 61 |
| 61 void HeapProfiler::TearDown() { | 62 void HeapProfiler::TearDown() { |
| 62 Isolate* isolate = Isolate::Current(); | 63 Isolate* isolate = Isolate::Current(); |
| 63 delete isolate->heap_profiler(); | 64 delete isolate->heap_profiler(); |
| 64 isolate->set_heap_profiler(NULL); | 65 isolate->set_heap_profiler(NULL); |
| 65 } | 66 } |
| 66 | 67 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 const char* name, | 133 const char* name, |
| 133 int type, | 134 int type, |
| 134 v8::ActivityControl* control, | 135 v8::ActivityControl* control, |
| 135 v8::HeapProfiler::ObjectNameResolver* resolver) { | 136 v8::HeapProfiler::ObjectNameResolver* resolver) { |
| 136 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); | 137 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); |
| 137 HeapSnapshot* result = | 138 HeapSnapshot* result = |
| 138 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); | 139 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); |
| 139 bool generation_completed = true; | 140 bool generation_completed = true; |
| 140 switch (s_type) { | 141 switch (s_type) { |
| 141 case HeapSnapshot::kFull: { | 142 case HeapSnapshot::kFull: { |
| 142 HeapSnapshotGenerator generator(result, control, resolver); | 143 HeapSnapshotGenerator generator(result, control, resolver, heap()); |
| 143 generation_completed = generator.GenerateSnapshot(); | 144 generation_completed = generator.GenerateSnapshot(); |
| 144 break; | 145 break; |
| 145 } | 146 } |
| 146 default: | 147 default: |
| 147 UNREACHABLE(); | 148 UNREACHABLE(); |
| 148 } | 149 } |
| 149 if (!generation_completed) { | 150 if (!generation_completed) { |
| 150 delete result; | 151 delete result; |
| 151 result = NULL; | 152 result = NULL; |
| 152 } | 153 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 profiler->ResetSnapshots(); | 224 profiler->ResetSnapshots(); |
| 224 } | 225 } |
| 225 | 226 |
| 226 | 227 |
| 227 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { | 228 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { |
| 228 snapshots_->ObjectMoveEvent(from, to); | 229 snapshots_->ObjectMoveEvent(from, to); |
| 229 } | 230 } |
| 230 | 231 |
| 231 | 232 |
| 232 } } // namespace v8::internal | 233 } } // namespace v8::internal |
| OLD | NEW |