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/address_sanitizer.h" | 7 #include "platform/address_sanitizer.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/compiler_stats.h" | 9 #include "vm/compiler_stats.h" |
10 #include "vm/gc_marker.h" | 10 #include "vm/gc_marker.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 delete memory_; | 106 delete memory_; |
107 | 107 |
108 // For a heap page from a snapshot, the HeapPage object lives in the malloc | 108 // For a heap page from a snapshot, the HeapPage object lives in the malloc |
109 // heap rather than the page itself. | 109 // heap rather than the page itself. |
110 if (image_page) { | 110 if (image_page) { |
111 free(this); | 111 free(this); |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 void HeapPage::VisitObjects(ObjectVisitor* visitor) const { | 115 void HeapPage::VisitObjects(ObjectVisitor* visitor) const { |
| 116 ASSERT(Thread::Current()->IsAtSafepoint()); |
116 NoSafepointScope no_safepoint; | 117 NoSafepointScope no_safepoint; |
117 uword obj_addr = object_start(); | 118 uword obj_addr = object_start(); |
118 uword end_addr = object_end(); | 119 uword end_addr = object_end(); |
119 while (obj_addr < end_addr) { | 120 while (obj_addr < end_addr) { |
120 RawObject* raw_obj = RawObject::FromAddr(obj_addr); | 121 RawObject* raw_obj = RawObject::FromAddr(obj_addr); |
121 visitor->VisitObject(raw_obj); | 122 visitor->VisitObject(raw_obj); |
122 obj_addr += raw_obj->Size(); | 123 obj_addr += raw_obj->Size(); |
123 } | 124 } |
124 ASSERT(obj_addr == end_addr); | 125 ASSERT(obj_addr == end_addr); |
125 } | 126 } |
126 | 127 |
127 void HeapPage::VisitObjectPointers(ObjectPointerVisitor* visitor) const { | 128 void HeapPage::VisitObjectPointers(ObjectPointerVisitor* visitor) const { |
| 129 ASSERT(Thread::Current()->IsAtSafepoint()); |
128 NoSafepointScope no_safepoint; | 130 NoSafepointScope no_safepoint; |
129 uword obj_addr = object_start(); | 131 uword obj_addr = object_start(); |
130 uword end_addr = object_end(); | 132 uword end_addr = object_end(); |
131 while (obj_addr < end_addr) { | 133 while (obj_addr < end_addr) { |
132 RawObject* raw_obj = RawObject::FromAddr(obj_addr); | 134 RawObject* raw_obj = RawObject::FromAddr(obj_addr); |
133 obj_addr += raw_obj->VisitPointers(visitor); | 135 obj_addr += raw_obj->VisitPointers(visitor); |
134 } | 136 } |
135 ASSERT(obj_addr == end_addr); | 137 ASSERT(obj_addr == end_addr); |
136 } | 138 } |
137 | 139 |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 static_cast<intptr_t>(kObjectAlignment)); | 747 static_cast<intptr_t>(kObjectAlignment)); |
746 heap_map.AddProperty("pageSizeBytes", kPageSizeInWords * kWordSize); | 748 heap_map.AddProperty("pageSizeBytes", kPageSizeInWords * kWordSize); |
747 { | 749 { |
748 JSONObject class_list(&heap_map, "classList"); | 750 JSONObject class_list(&heap_map, "classList"); |
749 isolate->class_table()->PrintToJSONObject(&class_list); | 751 isolate->class_table()->PrintToJSONObject(&class_list); |
750 } | 752 } |
751 { | 753 { |
752 // "pages" is an array [page0, page1, ..., pageN], each page of the form | 754 // "pages" is an array [page0, page1, ..., pageN], each page of the form |
753 // {"object_start": "0x...", "objects": [size, class id, size, ...]} | 755 // {"object_start": "0x...", "objects": [size, class id, size, ...]} |
754 // TODO(19445): Use ExclusivePageIterator once HeapMap supports large pages. | 756 // TODO(19445): Use ExclusivePageIterator once HeapMap supports large pages. |
| 757 HeapIterationScope iteration(Thread::Current()); |
755 MutexLocker ml(pages_lock_); | 758 MutexLocker ml(pages_lock_); |
756 MakeIterable(); | 759 MakeIterable(); |
757 NoSafepointScope no_safepoint; | |
758 JSONArray all_pages(&heap_map, "pages"); | 760 JSONArray all_pages(&heap_map, "pages"); |
759 for (HeapPage* page = pages_; page != NULL; page = page->next()) { | 761 for (HeapPage* page = pages_; page != NULL; page = page->next()) { |
760 JSONObject page_container(&all_pages); | 762 JSONObject page_container(&all_pages); |
761 page_container.AddPropertyF("objectStart", "0x%" Px "", | 763 page_container.AddPropertyF("objectStart", "0x%" Px "", |
762 page->object_start()); | 764 page->object_start()); |
763 JSONArray page_map(&page_container, "objects"); | 765 JSONArray page_map(&page_container, "objects"); |
764 HeapMapAsJSONVisitor printer(&page_map); | 766 HeapMapAsJSONVisitor printer(&page_map); |
765 page->VisitObjects(&printer); | 767 page->VisitObjects(&printer); |
766 } | 768 } |
767 for (HeapPage* page = exec_pages_; page != NULL; page = page->next()) { | 769 for (HeapPage* page = exec_pages_; page != NULL; page = page->next()) { |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 return 0; | 1276 return 0; |
1275 } else { | 1277 } else { |
1276 ASSERT(total_time >= gc_time); | 1278 ASSERT(total_time >= gc_time); |
1277 int result = static_cast<int>( | 1279 int result = static_cast<int>( |
1278 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); | 1280 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); |
1279 return result; | 1281 return result; |
1280 } | 1282 } |
1281 } | 1283 } |
1282 | 1284 |
1283 } // namespace dart | 1285 } // namespace dart |
OLD | NEW |