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

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

Issue 1710443003: Fix background compilation: allocate stubs at safepoint (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Comments Created 4 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/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"
11 #include "vm/os.h" 11 #include "vm/os.h"
12 12
13 #include "vm/isolate.h"
14
13 namespace dart { 15 namespace dart {
14 16
15 uword VirtualMemory::page_size_ = 0; 17 uword VirtualMemory::page_size_ = 0;
16 18
17 19
18 void VirtualMemory::InitOnce() { 20 void VirtualMemory::InitOnce() {
19 SYSTEM_INFO info; 21 SYSTEM_INFO info;
20 GetSystemInfo(&info); 22 GetSystemInfo(&info);
21 page_size_ = info.dwPageSize; 23 page_size_ = info.dwPageSize;
22 } 24 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 int prot = executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE; 58 int prot = executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
57 if (VirtualAlloc(reinterpret_cast<void*>(addr), size, MEM_COMMIT, prot) == 59 if (VirtualAlloc(reinterpret_cast<void*>(addr), size, MEM_COMMIT, prot) ==
58 NULL) { 60 NULL) {
59 return false; 61 return false;
60 } 62 }
61 return true; 63 return true;
62 } 64 }
63 65
64 66
65 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() ||
69 Isolate::Current()->mutator_thread()->IsAtSafepoint());
66 uword start_address = reinterpret_cast<uword>(address); 70 uword start_address = reinterpret_cast<uword>(address);
67 uword end_address = start_address + size; 71 uword end_address = start_address + size;
68 uword page_address = Utils::RoundDown(start_address, PageSize()); 72 uword page_address = Utils::RoundDown(start_address, PageSize());
69 DWORD prot = 0; 73 DWORD prot = 0;
70 switch (mode) { 74 switch (mode) {
71 case kNoAccess: 75 case kNoAccess:
72 prot = PAGE_NOACCESS; 76 prot = PAGE_NOACCESS;
73 break; 77 break;
74 case kReadOnly: 78 case kReadOnly:
75 prot = PAGE_READONLY; 79 prot = PAGE_READONLY;
(...skipping 12 matching lines...) Expand all
88 bool result = VirtualProtect(reinterpret_cast<void*>(page_address), 92 bool result = VirtualProtect(reinterpret_cast<void*>(page_address),
89 end_address - page_address, 93 end_address - page_address,
90 prot, 94 prot,
91 &old_prot); 95 &old_prot);
92 return result; 96 return result;
93 } 97 }
94 98
95 } // namespace dart 99 } // namespace dart
96 100
97 #endif // defined(TARGET_OS_WINDOWS) 101 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/vm/virtual_memory_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698