| OLD | NEW |
| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 -1, 0); | 76 -1, 0); |
| 77 if (address == MAP_FAILED) { | 77 if (address == MAP_FAILED) { |
| 78 return false; | 78 return false; |
| 79 } | 79 } |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 bool VirtualMemory::Protect(void* address, intptr_t size, Protection mode) { | 84 bool VirtualMemory::Protect(void* address, intptr_t size, Protection mode) { |
| 85 ASSERT(Thread::Current()->IsMutatorThread() || | 85 ASSERT(Thread::Current()->IsMutatorThread() || |
| 86 !Isolate::Current()->HasMutatorThread() || |
| 86 Isolate::Current()->mutator_thread()->IsAtSafepoint()); | 87 Isolate::Current()->mutator_thread()->IsAtSafepoint()); |
| 87 uword start_address = reinterpret_cast<uword>(address); | 88 uword start_address = reinterpret_cast<uword>(address); |
| 88 uword end_address = start_address + size; | 89 uword end_address = start_address + size; |
| 89 uword page_address = Utils::RoundDown(start_address, PageSize()); | 90 uword page_address = Utils::RoundDown(start_address, PageSize()); |
| 90 int prot = 0; | 91 int prot = 0; |
| 91 switch (mode) { | 92 switch (mode) { |
| 92 case kNoAccess: | 93 case kNoAccess: |
| 93 prot = PROT_NONE; | 94 prot = PROT_NONE; |
| 94 break; | 95 break; |
| 95 case kReadOnly: | 96 case kReadOnly: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 106 break; | 107 break; |
| 107 } | 108 } |
| 108 return (mprotect(reinterpret_cast<void*>(page_address), | 109 return (mprotect(reinterpret_cast<void*>(page_address), |
| 109 end_address - page_address, | 110 end_address - page_address, |
| 110 prot) == 0); | 111 prot) == 0); |
| 111 } | 112 } |
| 112 | 113 |
| 113 } // namespace dart | 114 } // namespace dart |
| 114 | 115 |
| 115 #endif // defined(TARGET_OS_ANDROID) | 116 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |