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 MacOS goes here. For the POSIX-compatible | 5 // Platform-specific code for MacOS goes here. For the POSIX-compatible |
6 // parts, the implementation is in platform-posix.cc. | 6 // parts, the implementation is in platform-posix.cc. |
7 | 7 |
8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 #include <sys/mman.h> | 10 #include <sys/mman.h> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 size_t* allocated, | 54 size_t* allocated, |
55 bool is_executable) { | 55 bool is_executable) { |
56 const size_t msize = RoundUp(requested, getpagesize()); | 56 const size_t msize = RoundUp(requested, getpagesize()); |
57 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); | 57 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
58 void* mbase = mmap(OS::GetRandomMmapAddr(), | 58 void* mbase = mmap(OS::GetRandomMmapAddr(), |
59 msize, | 59 msize, |
60 prot, | 60 prot, |
61 MAP_PRIVATE | MAP_ANON, | 61 MAP_PRIVATE | MAP_ANON, |
62 kMmapFd, | 62 kMmapFd, |
63 kMmapFdOffset); | 63 kMmapFdOffset); |
64 if (mbase == MAP_FAILED) { | 64 if (mbase == MAP_FAILED) return NULL; |
65 LOG(Isolate::Current(), StringEvent("OS::Allocate", "mmap failed")); | |
66 return NULL; | |
67 } | |
68 *allocated = msize; | 65 *allocated = msize; |
69 return mbase; | 66 return mbase; |
70 } | 67 } |
71 | 68 |
72 | 69 |
73 class PosixMemoryMappedFile : public OS::MemoryMappedFile { | 70 class PosixMemoryMappedFile : public OS::MemoryMappedFile { |
74 public: | 71 public: |
75 PosixMemoryMappedFile(FILE* file, void* memory, int size) | 72 PosixMemoryMappedFile(FILE* file, void* memory, int size) |
76 : file_(file), memory_(memory), size_(size) { } | 73 : file_(file), memory_(memory), size_(size) { } |
77 virtual ~PosixMemoryMappedFile(); | 74 virtual ~PosixMemoryMappedFile(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 bool VirtualMemory::ReleaseRegion(void* address, size_t size) { | 298 bool VirtualMemory::ReleaseRegion(void* address, size_t size) { |
302 return munmap(address, size) == 0; | 299 return munmap(address, size) == 0; |
303 } | 300 } |
304 | 301 |
305 | 302 |
306 bool VirtualMemory::HasLazyCommits() { | 303 bool VirtualMemory::HasLazyCommits() { |
307 return false; | 304 return false; |
308 } | 305 } |
309 | 306 |
310 } } // namespace v8::internal | 307 } } // namespace v8::internal |
OLD | NEW |