| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Platform specific code for AIX goes here. For the POSIX comaptible parts | 5 // Platform specific code for AIX goes here. For the POSIX comaptible parts |
| 6 // the implementation is in platform-posix.cc. | 6 // the implementation is in platform-posix.cc. |
| 7 | 7 |
| 8 #include <pthread.h> | 8 #include <pthread.h> |
| 9 #include <semaphore.h> | 9 #include <semaphore.h> |
| 10 #include <signal.h> | 10 #include <signal.h> |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 void* result = mmapHelper(size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, | 208 void* result = mmapHelper(size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, |
| 209 kMmapFd, kMmapFdOffset); | 209 kMmapFd, kMmapFdOffset); |
| 210 | 210 |
| 211 if (result == MAP_FAILED) return NULL; | 211 if (result == MAP_FAILED) return NULL; |
| 212 | 212 |
| 213 return result; | 213 return result; |
| 214 } | 214 } |
| 215 | 215 |
| 216 | 216 |
| 217 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) { | 217 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) { |
| 218 #if defined(__native_client__) | |
| 219 // The Native Client port of V8 uses an interpreter, | |
| 220 // so code pages don't need PROT_EXEC. | |
| 221 int prot = PROT_READ | PROT_WRITE; | |
| 222 #else | |
| 223 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); | 218 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
| 224 #endif | 219 |
| 225 if (mprotect(base, size, prot) == -1) return false; | 220 if (mprotect(base, size, prot) == -1) return false; |
| 226 | 221 |
| 227 return true; | 222 return true; |
| 228 } | 223 } |
| 229 | 224 |
| 230 | 225 |
| 231 bool VirtualMemory::UncommitRegion(void* base, size_t size) { | 226 bool VirtualMemory::UncommitRegion(void* base, size_t size) { |
| 232 return mprotect(base, size, PROT_NONE) != -1; | 227 return mprotect(base, size, PROT_NONE) != -1; |
| 233 } | 228 } |
| 234 | 229 |
| 235 bool VirtualMemory::ReleasePartialRegion(void* base, size_t size, | 230 bool VirtualMemory::ReleasePartialRegion(void* base, size_t size, |
| 236 void* free_start, size_t free_size) { | 231 void* free_start, size_t free_size) { |
| 237 return munmap(free_start, free_size) == 0; | 232 return munmap(free_start, free_size) == 0; |
| 238 } | 233 } |
| 239 | 234 |
| 240 | 235 |
| 241 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { | 236 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { |
| 242 return munmap(base, size) == 0; | 237 return munmap(base, size) == 0; |
| 243 } | 238 } |
| 244 | 239 |
| 245 | 240 |
| 246 bool VirtualMemory::HasLazyCommits() { return true; } | 241 bool VirtualMemory::HasLazyCommits() { return true; } |
| 247 } // namespace base | 242 } // namespace base |
| 248 } // namespace v8 | 243 } // namespace v8 |
| OLD | NEW |