| 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/flags.h" | 9 #include "vm/flags.h" |
| 10 #include "vm/heap_profiler.h" | 10 #include "vm/heap_profiler.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 HeapProfilerWeakRootVisitor weak_root_visitor(&root_visitor); | 279 HeapProfilerWeakRootVisitor weak_root_visitor(&root_visitor); |
| 280 isolate->VisitWeakPersistentHandles(&weak_root_visitor, true); | 280 isolate->VisitWeakPersistentHandles(&weak_root_visitor, true); |
| 281 | 281 |
| 282 // Dump the current and VM isolate heaps. | 282 // Dump the current and VM isolate heaps. |
| 283 HeapProfilerObjectVisitor object_visitor(isolate, &profiler); | 283 HeapProfilerObjectVisitor object_visitor(isolate, &profiler); |
| 284 isolate->heap()->IterateObjects(&object_visitor); | 284 isolate->heap()->IterateObjects(&object_visitor); |
| 285 vm_isolate->heap()->IterateObjects(&object_visitor); | 285 vm_isolate->heap()->IterateObjects(&object_visitor); |
| 286 } | 286 } |
| 287 | 287 |
| 288 | 288 |
| 289 void Heap::ProfileToFile(const char* reason) const { |
| 290 Dart_FileOpenCallback file_open = Isolate::file_open_callback(); |
| 291 ASSERT(file_open != NULL); |
| 292 Dart_FileWriteCallback file_write = Isolate::file_write_callback(); |
| 293 ASSERT(file_write != NULL); |
| 294 Dart_FileCloseCallback file_close = Isolate::file_close_callback(); |
| 295 ASSERT(file_close != NULL); |
| 296 Isolate* isolate = Isolate::Current(); |
| 297 const char* format = "%s-%s.hprof"; |
| 298 intptr_t len = OS::SNPrint(NULL, 0, format, isolate->name(), reason); |
| 299 char* filename = isolate->current_zone()->Alloc<char>(len + 1); |
| 300 OS::SNPrint(filename, len + 1, format, isolate->name(), reason); |
| 301 void* file = (*file_open)(filename); |
| 302 if (file != NULL) { |
| 303 Profile(file_write, file); |
| 304 (*file_close)(file); |
| 305 } |
| 306 } |
| 307 |
| 308 |
| 289 const char* Heap::GCReasonToString(GCReason gc_reason) { | 309 const char* Heap::GCReasonToString(GCReason gc_reason) { |
| 290 switch (gc_reason) { | 310 switch (gc_reason) { |
| 291 case kNewSpace: | 311 case kNewSpace: |
| 292 return "new space"; | 312 return "new space"; |
| 293 case kPromotionFailure: | 313 case kPromotionFailure: |
| 294 return "promotion failure"; | 314 return "promotion failure"; |
| 295 case kOldSpace: | 315 case kOldSpace: |
| 296 return "old space"; | 316 return "old space"; |
| 297 case kCodeSpace: | 317 case kCodeSpace: |
| 298 return "code space"; | 318 return "code space"; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 isolate()->IncrementNoGCScopeDepth(); | 358 isolate()->IncrementNoGCScopeDepth(); |
| 339 } | 359 } |
| 340 | 360 |
| 341 | 361 |
| 342 NoGCScope::~NoGCScope() { | 362 NoGCScope::~NoGCScope() { |
| 343 isolate()->DecrementNoGCScopeDepth(); | 363 isolate()->DecrementNoGCScopeDepth(); |
| 344 } | 364 } |
| 345 #endif // defined(DEBUG) | 365 #endif // defined(DEBUG) |
| 346 | 366 |
| 347 } // namespace dart | 367 } // namespace dart |
| OLD | NEW |