| 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/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 Loading... |
| 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 heap_map.AddProperty("unit_size_bytes", kObjectAlignment); |
| 450 { |
| 451 // "pages" is an array [page0, page1, ..., pageN], each page an array |
| 452 // [size, class id, size, class id, ...] (size unit is kObjectAlignment). |
| 453 JSONArray all_pages(&heap_map, "pages"); |
| 454 for (HeapPage* page = pages_; page != NULL; page = page->next()) { |
| 455 JSONArray page_map(&all_pages); |
| 456 HeapMapAsJSONVisitor printer(&page_map); |
| 457 page->VisitObjects(&printer); |
| 458 } |
| 459 } |
| 460 } |
| 461 |
| 462 |
| 431 bool PageSpace::ShouldCollectCode() { | 463 bool PageSpace::ShouldCollectCode() { |
| 432 // Try to collect code if enough time has passed since the last attempt. | 464 // Try to collect code if enough time has passed since the last attempt. |
| 433 const int64_t start = OS::GetCurrentTimeMicros(); | 465 const int64_t start = OS::GetCurrentTimeMicros(); |
| 434 const int64_t last_code_collection_in_us = | 466 const int64_t last_code_collection_in_us = |
| 435 page_space_controller_.last_code_collection_in_us(); | 467 page_space_controller_.last_code_collection_in_us(); |
| 436 | 468 |
| 437 if ((start - last_code_collection_in_us) > | 469 if ((start - last_code_collection_in_us) > |
| 438 FLAG_code_collection_interval_in_us) { | 470 FLAG_code_collection_interval_in_us) { |
| 439 if (FLAG_log_code_drop) { | 471 if (FLAG_log_code_drop) { |
| 440 OS::Print("Trying to detach code.\n"); | 472 OS::Print("Trying to detach code.\n"); |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 return 0; | 735 return 0; |
| 704 } else { | 736 } else { |
| 705 ASSERT(total_time >= gc_time); | 737 ASSERT(total_time >= gc_time); |
| 706 int result= static_cast<int>((static_cast<double>(gc_time) / | 738 int result= static_cast<int>((static_cast<double>(gc_time) / |
| 707 static_cast<double>(total_time)) * 100); | 739 static_cast<double>(total_time)) * 100); |
| 708 return result; | 740 return result; |
| 709 } | 741 } |
| 710 } | 742 } |
| 711 | 743 |
| 712 } // namespace dart | 744 } // namespace dart |
| OLD | NEW |