| 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 16 matching lines...) Expand all Loading... |
| 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 | 36 |
| 37 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 38 HeapProfiler::HeapProfiler() | 37 HeapProfiler::HeapProfiler() |
| 39 : snapshots_(new HeapSnapshotsCollection()), | 38 : snapshots_(new HeapSnapshotsCollection()), |
| 40 next_snapshot_uid_(1) { | 39 next_snapshot_uid_(1) { |
| 41 } | 40 } |
| 42 | 41 |
| 43 | 42 |
| 44 HeapProfiler::~HeapProfiler() { | 43 HeapProfiler::~HeapProfiler() { |
| 45 delete snapshots_; | 44 delete snapshots_; |
| 46 } | 45 } |
| 47 | 46 |
| 48 | 47 |
| 49 void HeapProfiler::ResetSnapshots() { | 48 void HeapProfiler::ResetSnapshots() { |
| 50 delete snapshots_; | 49 delete snapshots_; |
| 51 snapshots_ = new HeapSnapshotsCollection(); | 50 snapshots_ = new HeapSnapshotsCollection(); |
| 52 } | 51 } |
| 53 | 52 |
| 54 | 53 |
| 55 #endif // ENABLE_LOGGING_AND_PROFILING | |
| 56 | |
| 57 void HeapProfiler::Setup() { | 54 void HeapProfiler::Setup() { |
| 58 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 59 Isolate* isolate = Isolate::Current(); | 55 Isolate* isolate = Isolate::Current(); |
| 60 if (isolate->heap_profiler() == NULL) { | 56 if (isolate->heap_profiler() == NULL) { |
| 61 isolate->set_heap_profiler(new HeapProfiler()); | 57 isolate->set_heap_profiler(new HeapProfiler()); |
| 62 } | 58 } |
| 63 #endif | |
| 64 } | 59 } |
| 65 | 60 |
| 66 | 61 |
| 67 void HeapProfiler::TearDown() { | 62 void HeapProfiler::TearDown() { |
| 68 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 69 Isolate* isolate = Isolate::Current(); | 63 Isolate* isolate = Isolate::Current(); |
| 70 delete isolate->heap_profiler(); | 64 delete isolate->heap_profiler(); |
| 71 isolate->set_heap_profiler(NULL); | 65 isolate->set_heap_profiler(NULL); |
| 72 #endif | |
| 73 } | 66 } |
| 74 | 67 |
| 75 | 68 |
| 76 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 77 | |
| 78 HeapSnapshot* HeapProfiler::TakeSnapshot(const char* name, | 69 HeapSnapshot* HeapProfiler::TakeSnapshot(const char* name, |
| 79 int type, | 70 int type, |
| 80 v8::ActivityControl* control) { | 71 v8::ActivityControl* control) { |
| 81 ASSERT(Isolate::Current()->heap_profiler() != NULL); | 72 ASSERT(Isolate::Current()->heap_profiler() != NULL); |
| 82 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name, | 73 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name, |
| 83 type, | 74 type, |
| 84 control); | 75 control); |
| 85 } | 76 } |
| 86 | 77 |
| 87 | 78 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 HeapProfiler* profiler = Isolate::Current()->heap_profiler(); | 163 HeapProfiler* profiler = Isolate::Current()->heap_profiler(); |
| 173 ASSERT(profiler != NULL); | 164 ASSERT(profiler != NULL); |
| 174 profiler->ResetSnapshots(); | 165 profiler->ResetSnapshots(); |
| 175 } | 166 } |
| 176 | 167 |
| 177 | 168 |
| 178 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { | 169 void HeapProfiler::ObjectMoveEvent(Address from, Address to) { |
| 179 snapshots_->ObjectMoveEvent(from, to); | 170 snapshots_->ObjectMoveEvent(from, to); |
| 180 } | 171 } |
| 181 | 172 |
| 182 #endif // ENABLE_LOGGING_AND_PROFILING | |
| 183 | |
| 184 | 173 |
| 185 } } // namespace v8::internal | 174 } } // namespace v8::internal |
| OLD | NEW |