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

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

Issue 2191723002: Fix race condition with HasMutatorThread that was being used without a lock. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address self review comments. Created 4 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
« runtime/vm/isolate.h ('K') | « runtime/vm/virtual_memory_macos.cc ('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/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "vm/virtual_memory.h" 8 #include "vm/virtual_memory.h"
9 9
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 if (VirtualAlloc(reinterpret_cast<void*>(addr), size, MEM_COMMIT, prot) == 59 if (VirtualAlloc(reinterpret_cast<void*>(addr), size, MEM_COMMIT, prot) ==
60 NULL) { 60 NULL) {
61 return false; 61 return false;
62 } 62 }
63 return true; 63 return true;
64 } 64 }
65 65
66 66
67 bool VirtualMemory::Protect(void* address, intptr_t size, Protection mode) { 67 bool VirtualMemory::Protect(void* address, intptr_t size, Protection mode) {
68 ASSERT(Thread::Current()->IsMutatorThread() || 68 ASSERT(Thread::Current()->IsMutatorThread() ||
69 !Isolate::Current()->HasMutatorThread() ||
70 Isolate::Current()->mutator_thread()->IsAtSafepoint()); 69 Isolate::Current()->mutator_thread()->IsAtSafepoint());
71 uword start_address = reinterpret_cast<uword>(address); 70 uword start_address = reinterpret_cast<uword>(address);
72 uword end_address = start_address + size; 71 uword end_address = start_address + size;
73 uword page_address = Utils::RoundDown(start_address, PageSize()); 72 uword page_address = Utils::RoundDown(start_address, PageSize());
74 DWORD prot = 0; 73 DWORD prot = 0;
75 switch (mode) { 74 switch (mode) {
76 case kNoAccess: 75 case kNoAccess:
77 prot = PAGE_NOACCESS; 76 prot = PAGE_NOACCESS;
78 break; 77 break;
79 case kReadOnly: 78 case kReadOnly:
(...skipping 13 matching lines...) Expand all
93 bool result = VirtualProtect(reinterpret_cast<void*>(page_address), 92 bool result = VirtualProtect(reinterpret_cast<void*>(page_address),
94 end_address - page_address, 93 end_address - page_address,
95 prot, 94 prot,
96 &old_prot); 95 &old_prot);
97 return result; 96 return result;
98 } 97 }
99 98
100 } // namespace dart 99 } // namespace dart
101 100
102 #endif // defined(TARGET_OS_WINDOWS) 101 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« runtime/vm/isolate.h ('K') | « runtime/vm/virtual_memory_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698