| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/heap.h" | 5 #include "vm/heap.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/compiler_stats.h" | 9 #include "vm/compiler_stats.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| 11 #include "vm/heap_profiler.h" |
| 11 #include "vm/isolate.h" | 12 #include "vm/isolate.h" |
| 12 #include "vm/object.h" | 13 #include "vm/object.h" |
| 13 #include "vm/os.h" | 14 #include "vm/os.h" |
| 14 #include "vm/pages.h" | 15 #include "vm/pages.h" |
| 15 #include "vm/scavenger.h" | 16 #include "vm/scavenger.h" |
| 17 #include "vm/stack_frame.h" |
| 16 #include "vm/verifier.h" | 18 #include "vm/verifier.h" |
| 17 #include "vm/virtual_memory.h" | 19 #include "vm/virtual_memory.h" |
| 18 | 20 |
| 19 namespace dart { | 21 namespace dart { |
| 20 | 22 |
| 21 DEFINE_FLAG(bool, verbose_gc, false, "Enables verbose GC."); | 23 DEFINE_FLAG(bool, verbose_gc, false, "Enables verbose GC."); |
| 22 DEFINE_FLAG(bool, verify_before_gc, false, | 24 DEFINE_FLAG(bool, verify_before_gc, false, |
| 23 "Enables heap verification before GC."); | 25 "Enables heap verification before GC."); |
| 24 DEFINE_FLAG(bool, verify_after_gc, false, | 26 DEFINE_FLAG(bool, verify_after_gc, false, |
| 25 "Enables heap verification after GC."); | 27 "Enables heap verification after GC."); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 void Heap::PrintSizes() const { | 215 void Heap::PrintSizes() const { |
| 214 OS::PrintErr("New space (%dk of %dk) " | 216 OS::PrintErr("New space (%dk of %dk) " |
| 215 "Old space (%dk of %dk) " | 217 "Old space (%dk of %dk) " |
| 216 "Code space (%dk of %dk)\n", | 218 "Code space (%dk of %dk)\n", |
| 217 (new_space_->in_use() / KB), (new_space_->capacity() / KB), | 219 (new_space_->in_use() / KB), (new_space_->capacity() / KB), |
| 218 (old_space_->in_use() / KB), (old_space_->capacity() / KB), | 220 (old_space_->in_use() / KB), (old_space_->capacity() / KB), |
| 219 (code_space_->in_use() / KB), (code_space_->capacity() / KB)); | 221 (code_space_->in_use() / KB), (code_space_->capacity() / KB)); |
| 220 } | 222 } |
| 221 | 223 |
| 222 | 224 |
| 225 void Heap::Profile(Dart_HeapProfileWriteCallback callback, void* stream) const { |
| 226 HeapProfiler profiler(callback, stream); |
| 227 |
| 228 // Dump the root set. |
| 229 HeapProfilerRootVisitor root_visitor(&profiler); |
| 230 Isolate* isolate = Isolate::Current(); |
| 231 Isolate* vm_isolate = Dart::vm_isolate(); |
| 232 isolate->VisitObjectPointers(&root_visitor, false, |
| 233 StackFrameIterator::kDontValidateFrames); |
| 234 HeapProfilerWeakRootVisitor weak_root_visitor(&root_visitor); |
| 235 isolate->VisitWeakPersistentHandles(&weak_root_visitor, true); |
| 236 |
| 237 // Dump the current and VM isolate heaps. |
| 238 HeapProfilerObjectVisitor object_visitor(&profiler); |
| 239 isolate->heap()->new_space_->VisitObjects(&object_visitor); |
| 240 isolate->heap()->old_space_->VisitObjects(&object_visitor); |
| 241 isolate->heap()->code_space_->VisitObjects(&object_visitor); |
| 242 vm_isolate->heap()->new_space_->VisitObjects(&object_visitor); |
| 243 vm_isolate->heap()->old_space_->VisitObjects(&object_visitor); |
| 244 } |
| 245 |
| 246 |
| 223 #if defined(DEBUG) | 247 #if defined(DEBUG) |
| 224 NoGCScope::NoGCScope() : StackResource(Isolate::Current()) { | 248 NoGCScope::NoGCScope() : StackResource(Isolate::Current()) { |
| 225 isolate()->IncrementNoGCScopeDepth(); | 249 isolate()->IncrementNoGCScopeDepth(); |
| 226 } | 250 } |
| 227 | 251 |
| 228 | 252 |
| 229 NoGCScope::~NoGCScope() { | 253 NoGCScope::~NoGCScope() { |
| 230 isolate()->DecrementNoGCScopeDepth(); | 254 isolate()->DecrementNoGCScopeDepth(); |
| 231 } | 255 } |
| 232 #endif // defined(DEBUG) | 256 #endif // defined(DEBUG) |
| 233 | 257 |
| 234 } // namespace dart | 258 } // namespace dart |
| OLD | NEW |