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

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 array_->AddValue(obj->GetClassId());
438 }
439 private:
440 JSONArray* array_;
441 };
442
443
444 void PageSpace::PrintHeapMapToJSONStream(JSONStream* stream) {
445 JSONObject heap_map(stream);
446 heap_map.AddProperty("type", "HeapMap");
447 heap_map.AddProperty("id", "heapmap");
448 heap_map.AddProperty("free_class_id", kFreeListElement);
449 {
450 // "pages" is an array [page0, page1, ..., pageN], each page an array
451 // [size, class id, size, class id, ...] (size unit is kObjectAlignment).
Cutch 2014/03/12 20:37:41 Should we send the value of kObjectAlignment or is
koda 2014/03/12 20:44:17 Added it as "unit_size_bytes". (It's two words, h
452 JSONArray all_pages(&heap_map, "pages");
453 for (HeapPage* page = pages_; page != NULL; page = page->next()) {
454 JSONArray page_map(&all_pages);
455 HeapMapAsJSONVisitor printer(&page_map);
456 page->VisitObjects(&printer);
457 }
458 }
459 }
460
461
431 bool PageSpace::ShouldCollectCode() { 462 bool PageSpace::ShouldCollectCode() {
432 // Try to collect code if enough time has passed since the last attempt. 463 // Try to collect code if enough time has passed since the last attempt.
433 const int64_t start = OS::GetCurrentTimeMicros(); 464 const int64_t start = OS::GetCurrentTimeMicros();
434 const int64_t last_code_collection_in_us = 465 const int64_t last_code_collection_in_us =
435 page_space_controller_.last_code_collection_in_us(); 466 page_space_controller_.last_code_collection_in_us();
436 467
437 if ((start - last_code_collection_in_us) > 468 if ((start - last_code_collection_in_us) >
438 FLAG_code_collection_interval_in_us) { 469 FLAG_code_collection_interval_in_us) {
439 if (FLAG_log_code_drop) { 470 if (FLAG_log_code_drop) {
440 OS::Print("Trying to detach code.\n"); 471 OS::Print("Trying to detach code.\n");
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 return 0; 734 return 0;
704 } else { 735 } else {
705 ASSERT(total_time >= gc_time); 736 ASSERT(total_time >= gc_time);
706 int result= static_cast<int>((static_cast<double>(gc_time) / 737 int result= static_cast<int>((static_cast<double>(gc_time) /
707 static_cast<double>(total_time)) * 100); 738 static_cast<double>(total_time)) * 100);
708 return result; 739 return result;
709 } 740 }
710 } 741 }
711 742
712 } // namespace dart 743 } // 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