Chromium Code Reviews| 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 "platform/address_sanitizer.h" | |
|
zra
2017/01/23 16:58:58
DBC: alphabetize.
| |
| 8 #include "vm/compiler_stats.h" | 9 #include "vm/compiler_stats.h" |
| 9 #include "vm/gc_marker.h" | 10 #include "vm/gc_marker.h" |
| 10 #include "vm/gc_sweeper.h" | 11 #include "vm/gc_sweeper.h" |
| 11 #include "vm/lockers.h" | 12 #include "vm/lockers.h" |
| 12 #include "vm/object.h" | 13 #include "vm/object.h" |
| 13 #include "vm/object_set.h" | 14 #include "vm/object_set.h" |
| 14 #include "vm/os_thread.h" | 15 #include "vm/os_thread.h" |
| 15 #include "vm/safepoint.h" | 16 #include "vm/safepoint.h" |
| 16 #include "vm/virtual_memory.h" | 17 #include "vm/virtual_memory.h" |
| 17 | 18 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 // Create the new page executable (RWX) only if we're not in W^X mode | 63 // Create the new page executable (RWX) only if we're not in W^X mode |
| 63 bool create_executable = !FLAG_write_protect_code && is_executable; | 64 bool create_executable = !FLAG_write_protect_code && is_executable; |
| 64 if (!memory->Commit(create_executable)) { | 65 if (!memory->Commit(create_executable)) { |
| 65 return NULL; | 66 return NULL; |
| 66 } | 67 } |
| 67 HeapPage* result = reinterpret_cast<HeapPage*>(memory->address()); | 68 HeapPage* result = reinterpret_cast<HeapPage*>(memory->address()); |
| 68 ASSERT(result != NULL); | 69 ASSERT(result != NULL); |
| 69 result->memory_ = memory; | 70 result->memory_ = memory; |
| 70 result->next_ = NULL; | 71 result->next_ = NULL; |
| 71 result->type_ = type; | 72 result->type_ = type; |
| 73 | |
| 74 LSAN_REGISTER_ROOT_REGION(memory->address(), | |
| 75 static_cast<size_t>(memory->size())); | |
| 76 | |
| 72 return result; | 77 return result; |
| 73 } | 78 } |
| 74 | 79 |
| 75 | 80 |
| 76 HeapPage* HeapPage::Allocate(intptr_t size_in_words, PageType type) { | 81 HeapPage* HeapPage::Allocate(intptr_t size_in_words, PageType type) { |
| 77 VirtualMemory* memory = | 82 VirtualMemory* memory = |
| 78 VirtualMemory::Reserve(size_in_words << kWordSizeLog2); | 83 VirtualMemory::Reserve(size_in_words << kWordSizeLog2); |
| 79 if (memory == NULL) { | 84 if (memory == NULL) { |
| 80 return NULL; | 85 return NULL; |
| 81 } | 86 } |
| 82 HeapPage* result = Initialize(memory, type); | 87 HeapPage* result = Initialize(memory, type); |
| 83 if (result == NULL) { | 88 if (result == NULL) { |
| 84 delete memory; // Release reservation to OS. | 89 delete memory; // Release reservation to OS. |
| 85 return NULL; | 90 return NULL; |
| 86 } | 91 } |
| 87 return result; | 92 return result; |
| 88 } | 93 } |
| 89 | 94 |
| 90 | 95 |
| 91 void HeapPage::Deallocate() { | 96 void HeapPage::Deallocate() { |
| 97 LSAN_UNREGISTER_ROOT_REGION(memory_->address(), | |
| 98 static_cast<size_t>(memory_->size())); | |
| 99 | |
| 92 // The memory for this object will become unavailable after the delete below. | 100 // The memory for this object will become unavailable after the delete below. |
| 93 delete memory_; | 101 delete memory_; |
| 94 } | 102 } |
| 95 | 103 |
| 96 | 104 |
| 97 void HeapPage::VisitObjects(ObjectVisitor* visitor) const { | 105 void HeapPage::VisitObjects(ObjectVisitor* visitor) const { |
| 98 NoSafepointScope no_safepoint; | 106 NoSafepointScope no_safepoint; |
| 99 uword obj_addr = object_start(); | 107 uword obj_addr = object_start(); |
| 100 uword end_addr = object_end(); | 108 uword end_addr = object_end(); |
| 101 while (obj_addr < end_addr) { | 109 while (obj_addr < end_addr) { |
| (...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1269 return 0; | 1277 return 0; |
| 1270 } else { | 1278 } else { |
| 1271 ASSERT(total_time >= gc_time); | 1279 ASSERT(total_time >= gc_time); |
| 1272 int result = static_cast<int>( | 1280 int result = static_cast<int>( |
| 1273 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); | 1281 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); |
| 1274 return result; | 1282 return result; |
| 1275 } | 1283 } |
| 1276 } | 1284 } |
| 1277 | 1285 |
| 1278 } // namespace dart | 1286 } // namespace dart |
| OLD | NEW |