Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: runtime/vm/pages.cc

Issue 197663006: Heap maps: add VM service message. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/pages.h" 5 #include "vm/pages.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/compiler_stats.h" 8 #include "vm/compiler_stats.h"
9 #include "vm/gc_marker.h" 9 #include "vm/gc_marker.h"
10 #include "vm/gc_sweeper.h" 10 #include "vm/gc_sweeper.h"
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 space.AddProperty("name", "PageSpace"); 421 space.AddProperty("name", "PageSpace");
422 space.AddProperty("user_name", "old"); 422 space.AddProperty("user_name", "old");
423 space.AddProperty("collections", collections()); 423 space.AddProperty("collections", collections());
424 space.AddProperty("used", UsedInWords() * kWordSize); 424 space.AddProperty("used", UsedInWords() * kWordSize);
425 space.AddProperty("capacity", CapacityInWords() * kWordSize); 425 space.AddProperty("capacity", CapacityInWords() * kWordSize);
426 space.AddProperty("external", ExternalInWords() * kWordSize); 426 space.AddProperty("external", ExternalInWords() * kWordSize);
427 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros())); 427 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros()));
428 } 428 }
429 429
430 430
431 class HeapMapAsJSONVisitor : public ObjectVisitor {
432 public:
433 explicit HeapMapAsJSONVisitor(JSONArray* array)
434 : ObjectVisitor(NULL), array_(array) {}
435 virtual void VisitObject(RawObject* obj) {
436 array_->AddValue(obj->Size() / kObjectAlignment);
437 // Freelist is most interesting, so map it to a fixed unused value.
438 ASSERT(0 == kIllegalCid);
439 array_->AddValue(obj->IsFreeListElement() ? 0 : obj->GetClassId());
Cutch 2014/03/12 19:02:02 I'm concerned about mapping kFreeListElement to kI
koda 2014/03/12 19:08:01 Good idea. Done.
440 }
441 private:
442 JSONArray* array_;
443 };
444
445
446 void PageSpace::PrintHeapMapToJSONStream(JSONStream* stream) {
447 JSONObject heap_map(stream);
448 heap_map.AddProperty("type", "HeapMap");
449 heap_map.AddProperty("id", "heapmap");
Cutch 2014/03/12 19:02:02 heap_map.AddProperty("free_class_id", kFreeListEle
koda 2014/03/12 19:08:01 Done.
450 {
451 JSONArray all_pages(&heap_map, "pages");
Cutch 2014/03/12 19:02:02 Maybe add a comment here saying the format of "pag
koda 2014/03/12 19:08:01 Done.
452 for (HeapPage* page = pages_; page != NULL; page = page->next()) {
453 JSONArray page_map(&all_pages);
454 HeapMapAsJSONVisitor printer(&page_map);
455 page->VisitObjects(&printer);
456 }
457 }
458 }
459
460
431 bool PageSpace::ShouldCollectCode() { 461 bool PageSpace::ShouldCollectCode() {
432 // Try to collect code if enough time has passed since the last attempt. 462 // Try to collect code if enough time has passed since the last attempt.
433 const int64_t start = OS::GetCurrentTimeMicros(); 463 const int64_t start = OS::GetCurrentTimeMicros();
434 const int64_t last_code_collection_in_us = 464 const int64_t last_code_collection_in_us =
435 page_space_controller_.last_code_collection_in_us(); 465 page_space_controller_.last_code_collection_in_us();
436 466
437 if ((start - last_code_collection_in_us) > 467 if ((start - last_code_collection_in_us) >
438 FLAG_code_collection_interval_in_us) { 468 FLAG_code_collection_interval_in_us) {
439 if (FLAG_log_code_drop) { 469 if (FLAG_log_code_drop) {
440 OS::Print("Trying to detach code.\n"); 470 OS::Print("Trying to detach code.\n");
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 return 0; 733 return 0;
704 } else { 734 } else {
705 ASSERT(total_time >= gc_time); 735 ASSERT(total_time >= gc_time);
706 int result= static_cast<int>((static_cast<double>(gc_time) / 736 int result= static_cast<int>((static_cast<double>(gc_time) /
707 static_cast<double>(total_time)) * 100); 737 static_cast<double>(total_time)) * 100);
708 return result; 738 return result;
709 } 739 }
710 } 740 }
711 741
712 } // namespace dart 742 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698