| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 OpenBSD and NetBSD goes here. For the | 5 // Platform-specific code for OpenBSD and NetBSD goes here. For the |
| 6 // POSIX-compatible parts, the implementation is in platform-posix.cc. | 6 // POSIX-compatible parts, 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 void* OS::Allocate(const size_t requested, | 56 void* OS::Allocate(const size_t requested, |
| 57 size_t* allocated, | 57 size_t* allocated, |
| 58 bool is_executable) { | 58 bool is_executable) { |
| 59 const size_t msize = RoundUp(requested, AllocateAlignment()); | 59 const size_t msize = RoundUp(requested, AllocateAlignment()); |
| 60 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); | 60 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
| 61 void* addr = OS::GetRandomMmapAddr(); | 61 void* addr = OS::GetRandomMmapAddr(); |
| 62 void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); | 62 void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); |
| 63 if (mbase == MAP_FAILED) { | 63 if (mbase == MAP_FAILED) return NULL; |
| 64 LOG(i::Isolate::Current(), | |
| 65 StringEvent("OS::Allocate", "mmap failed")); | |
| 66 return NULL; | |
| 67 } | |
| 68 *allocated = msize; | 64 *allocated = msize; |
| 69 return mbase; | 65 return mbase; |
| 70 } | 66 } |
| 71 | 67 |
| 72 | 68 |
| 73 class PosixMemoryMappedFile : public OS::MemoryMappedFile { | 69 class PosixMemoryMappedFile : public OS::MemoryMappedFile { |
| 74 public: | 70 public: |
| 75 PosixMemoryMappedFile(FILE* file, void* memory, int size) | 71 PosixMemoryMappedFile(FILE* file, void* memory, int size) |
| 76 : file_(file), memory_(memory), size_(size) { } | 72 : file_(file), memory_(memory), size_(size) { } |
| 77 virtual ~PosixMemoryMappedFile(); | 73 virtual ~PosixMemoryMappedFile(); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 return munmap(base, size) == 0; | 327 return munmap(base, size) == 0; |
| 332 } | 328 } |
| 333 | 329 |
| 334 | 330 |
| 335 bool VirtualMemory::HasLazyCommits() { | 331 bool VirtualMemory::HasLazyCommits() { |
| 336 // TODO(alph): implement for the platform. | 332 // TODO(alph): implement for the platform. |
| 337 return false; | 333 return false; |
| 338 } | 334 } |
| 339 | 335 |
| 340 } } // namespace v8::internal | 336 } } // namespace v8::internal |
| OLD | NEW |