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

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

Issue 1710443003: Fix background compilation: allocate stubs at safepoint (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: d 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
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_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 MAP_PRIVATE | MAP_ANON | MAP_FIXED, 73 MAP_PRIVATE | MAP_ANON | MAP_FIXED,
74 -1, 0); 74 -1, 0);
75 if (address == MAP_FAILED) { 75 if (address == MAP_FAILED) {
76 return false; 76 return false;
77 } 77 }
78 return true; 78 return true;
79 } 79 }
80 80
81 81
82 bool VirtualMemory::Protect(void* address, intptr_t size, Protection mode) { 82 bool VirtualMemory::Protect(void* address, intptr_t size, Protection mode) {
83 ASSERT(Thread::Current()->IsMutatorThread() ||
84 Isolate::Current()->mutator_thread()->IsAtSafepoint());
83 uword start_address = reinterpret_cast<uword>(address); 85 uword start_address = reinterpret_cast<uword>(address);
84 uword end_address = start_address + size; 86 uword end_address = start_address + size;
85 uword page_address = Utils::RoundDown(start_address, PageSize()); 87 uword page_address = Utils::RoundDown(start_address, PageSize());
86 int prot = 0; 88 int prot = 0;
87 switch (mode) { 89 switch (mode) {
88 case kNoAccess: 90 case kNoAccess:
89 prot = PROT_NONE; 91 prot = PROT_NONE;
90 break; 92 break;
91 case kReadOnly: 93 case kReadOnly:
92 prot = PROT_READ; 94 prot = PROT_READ;
93 break; 95 break;
94 case kReadWrite: 96 case kReadWrite:
95 prot = PROT_READ | PROT_WRITE; 97 prot = PROT_READ | PROT_WRITE;
96 break; 98 break;
97 case kReadExecute: 99 case kReadExecute:
98 prot = PROT_READ | PROT_EXEC; 100 prot = PROT_READ | PROT_EXEC;
99 break; 101 break;
100 case kReadWriteExecute: 102 case kReadWriteExecute:
101 prot = PROT_READ | PROT_WRITE | PROT_EXEC; 103 prot = PROT_READ | PROT_WRITE | PROT_EXEC;
102 break; 104 break;
103 } 105 }
104 return (mprotect(reinterpret_cast<void*>(page_address), 106 return (mprotect(reinterpret_cast<void*>(page_address),
105 end_address - page_address, 107 end_address - page_address,
106 prot) == 0); 108 prot) == 0);
107 } 109 }
108 110
109 } // namespace dart 111 } // namespace dart
110 112
111 #endif // defined(TARGET_OS_ANDROID) 113 #endif // defined(TARGET_OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698