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

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

Issue 2646363005: VM: Tell lsan about mmap()ed regions used for our heap (Closed)
Patch Set: Mark Dart2JSCompilerStats/Dart2JSCompileAll as Crash, Fail Created 3 years, 10 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/tests/vm/vm.status ('k') | tests/standalone/standalone.status » ('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/address_sanitizer.h"
7 #include "platform/assert.h" 8 #include "platform/assert.h"
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"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(result, sizeof(*result));
75
72 return result; 76 return result;
73 } 77 }
74 78
75 79
76 HeapPage* HeapPage::Allocate(intptr_t size_in_words, PageType type) { 80 HeapPage* HeapPage::Allocate(intptr_t size_in_words, PageType type) {
77 VirtualMemory* memory = 81 VirtualMemory* memory =
78 VirtualMemory::Reserve(size_in_words << kWordSizeLog2); 82 VirtualMemory::Reserve(size_in_words << kWordSizeLog2);
79 if (memory == NULL) { 83 if (memory == NULL) {
80 return NULL; 84 return NULL;
81 } 85 }
82 HeapPage* result = Initialize(memory, type); 86 HeapPage* result = Initialize(memory, type);
83 if (result == NULL) { 87 if (result == NULL) {
84 delete memory; // Release reservation to OS. 88 delete memory; // Release reservation to OS.
85 return NULL; 89 return NULL;
86 } 90 }
87 return result; 91 return result;
88 } 92 }
89 93
90 94
91 void HeapPage::Deallocate() { 95 void HeapPage::Deallocate() {
96 bool is_embedder_allocated = embedder_allocated();
97
98 if (!is_embedder_allocated) {
99 LSAN_UNREGISTER_ROOT_REGION(this, sizeof(*this));
100 }
101
92 // For a regular heap pages, the memory for this object will become 102 // For a regular heap pages, the memory for this object will become
93 // unavailable after the delete below. 103 // unavailable after the delete below.
94 bool is_embedder_allocated = embedder_allocated();
95 delete memory_; 104 delete memory_;
96 105
97 // For a heap page from a snapshot, the HeapPage object lives in the malloc 106 // For a heap page from a snapshot, the HeapPage object lives in the malloc
98 // heap rather than the page itself. 107 // heap rather than the page itself.
99 if (is_embedder_allocated) { 108 if (is_embedder_allocated) {
100 free(this); 109 free(this);
101 } 110 }
102 } 111 }
103 112
104 113
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 return 0; 1300 return 0;
1292 } else { 1301 } else {
1293 ASSERT(total_time >= gc_time); 1302 ASSERT(total_time >= gc_time);
1294 int result = static_cast<int>( 1303 int result = static_cast<int>(
1295 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); 1304 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100);
1296 return result; 1305 return result;
1297 } 1306 }
1298 } 1307 }
1299 1308
1300 } // namespace dart 1309 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | tests/standalone/standalone.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698