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

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

Issue 1880233002: Address Siva's comments from https://codereview.chromium.org/1877973002/ (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Adjust assert: Protect may be called while mutator_thread does not exist" Created 4 years, 8 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/virtual_memory_android.cc ('k') | runtime/vm/virtual_memory_macos.cc » ('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/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_OS_LINUX) 6 #if defined(TARGET_OS_LINUX)
7 7
8 #include "vm/virtual_memory.h" 8 #include "vm/virtual_memory.h"
9 9
10 #include <sys/mman.h> // NOLINT 10 #include <sys/mman.h> // NOLINT
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 -1, 0); 75 -1, 0);
76 if (address == MAP_FAILED) { 76 if (address == MAP_FAILED) {
77 return false; 77 return false;
78 } 78 }
79 return true; 79 return true;
80 } 80 }
81 81
82 82
83 bool VirtualMemory::Protect(void* address, intptr_t size, Protection mode) { 83 bool VirtualMemory::Protect(void* address, intptr_t size, Protection mode) {
84 ASSERT(Thread::Current()->IsMutatorThread() || 84 ASSERT(Thread::Current()->IsMutatorThread() ||
85 !Isolate::Current()->HasMutatorThread() ||
85 Isolate::Current()->mutator_thread()->IsAtSafepoint()); 86 Isolate::Current()->mutator_thread()->IsAtSafepoint());
86 uword start_address = reinterpret_cast<uword>(address); 87 uword start_address = reinterpret_cast<uword>(address);
87 uword end_address = start_address + size; 88 uword end_address = start_address + size;
88 uword page_address = Utils::RoundDown(start_address, PageSize()); 89 uword page_address = Utils::RoundDown(start_address, PageSize());
89 int prot = 0; 90 int prot = 0;
90 switch (mode) { 91 switch (mode) {
91 case kNoAccess: 92 case kNoAccess:
92 prot = PROT_NONE; 93 prot = PROT_NONE;
93 break; 94 break;
94 case kReadOnly: 95 case kReadOnly:
(...skipping 11 matching lines...) Expand all
106 } 107 }
107 return (mprotect(reinterpret_cast<void*>(page_address), 108 return (mprotect(reinterpret_cast<void*>(page_address),
108 end_address - page_address, 109 end_address - page_address,
109 prot) == 0); 110 prot) == 0);
110 } 111 }
111 112
112 113
113 } // namespace dart 114 } // namespace dart
114 115
115 #endif // defined(TARGET_OS_LINUX) 116 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/vm/virtual_memory_android.cc ('k') | runtime/vm/virtual_memory_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698