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

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

Issue 2993383002: [vm] Compute per-HeapPage usage during sweeping. (Closed)
Patch Set: Created 3 years, 4 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
« no previous file with comments | « runtime/vm/pages.h ('k') | no next file » | 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/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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 bool is_executable = (type == kExecutable); 64 bool is_executable = (type == kExecutable);
65 // Create the new page executable (RWX) only if we're not in W^X mode 65 // Create the new page executable (RWX) only if we're not in W^X mode
66 bool create_executable = !FLAG_write_protect_code && is_executable; 66 bool create_executable = !FLAG_write_protect_code && is_executable;
67 if (!memory->Commit(create_executable, name)) { 67 if (!memory->Commit(create_executable, name)) {
68 return NULL; 68 return NULL;
69 } 69 }
70 HeapPage* result = reinterpret_cast<HeapPage*>(memory->address()); 70 HeapPage* result = reinterpret_cast<HeapPage*>(memory->address());
71 ASSERT(result != NULL); 71 ASSERT(result != NULL);
72 result->memory_ = memory; 72 result->memory_ = memory;
73 result->next_ = NULL; 73 result->next_ = NULL;
74 result->used_in_bytes_ = 0;
74 result->type_ = type; 75 result->type_ = type;
75 76
76 LSAN_REGISTER_ROOT_REGION(result, sizeof(*result)); 77 LSAN_REGISTER_ROOT_REGION(result, sizeof(*result));
77 78
78 return result; 79 return result;
79 } 80 }
80 81
81 HeapPage* HeapPage::Allocate(intptr_t size_in_words, 82 HeapPage* HeapPage::Allocate(intptr_t size_in_words,
82 PageType type, 83 PageType type,
83 const char* name) { 84 const char* name) {
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 uword offset = HeapPage::ObjectStartOffset(); 1086 uword offset = HeapPage::ObjectStartOffset();
1086 pointer = reinterpret_cast<void*>(reinterpret_cast<uword>(pointer) - offset); 1087 pointer = reinterpret_cast<void*>(reinterpret_cast<uword>(pointer) - offset);
1087 size += offset; 1088 size += offset;
1088 1089
1089 VirtualMemory* memory = VirtualMemory::ForImagePage(pointer, size); 1090 VirtualMemory* memory = VirtualMemory::ForImagePage(pointer, size);
1090 ASSERT(memory != NULL); 1091 ASSERT(memory != NULL);
1091 HeapPage* page = reinterpret_cast<HeapPage*>(malloc(sizeof(HeapPage))); 1092 HeapPage* page = reinterpret_cast<HeapPage*>(malloc(sizeof(HeapPage)));
1092 page->memory_ = memory; 1093 page->memory_ = memory;
1093 page->next_ = NULL; 1094 page->next_ = NULL;
1094 page->object_end_ = memory->end(); 1095 page->object_end_ = memory->end();
1096 page->used_in_bytes_ = page->object_end_ - page->object_start();
1095 1097
1096 MutexLocker ml(pages_lock_); 1098 MutexLocker ml(pages_lock_);
1097 HeapPage **first, **tail; 1099 HeapPage **first, **tail;
1098 if (is_executable) { 1100 if (is_executable) {
1099 ASSERT(Utils::IsAligned(pointer, OS::PreferredCodeAlignment())); 1101 ASSERT(Utils::IsAligned(pointer, OS::PreferredCodeAlignment()));
1100 page->type_ = HeapPage::kExecutable; 1102 page->type_ = HeapPage::kExecutable;
1101 first = &exec_pages_; 1103 first = &exec_pages_;
1102 tail = &exec_pages_tail_; 1104 tail = &exec_pages_tail_;
1103 } else { 1105 } else {
1104 page->type_ = HeapPage::kData; 1106 page->type_ = HeapPage::kData;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « runtime/vm/pages.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698