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 Linux goes here. For the POSIX-compatible | 5 // Platform-specific code for Linux 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 <pthread.h> | 8 #include <pthread.h> |
9 #include <semaphore.h> | 9 #include <semaphore.h> |
10 #include <signal.h> | 10 #include <signal.h> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 | 113 |
114 | 114 |
115 void* OS::Allocate(const size_t requested, | 115 void* OS::Allocate(const size_t requested, |
116 size_t* allocated, | 116 size_t* allocated, |
117 bool is_executable) { | 117 bool is_executable) { |
118 const size_t msize = RoundUp(requested, AllocateAlignment()); | 118 const size_t msize = RoundUp(requested, AllocateAlignment()); |
119 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); | 119 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
120 void* addr = OS::GetRandomMmapAddr(); | 120 void* addr = OS::GetRandomMmapAddr(); |
121 void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | 121 void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
122 if (mbase == MAP_FAILED) { | 122 if (mbase == MAP_FAILED) return NULL; |
123 LOG(i::Isolate::Current(), | |
124 StringEvent("OS::Allocate", "mmap failed")); | |
125 return NULL; | |
126 } | |
127 *allocated = msize; | 123 *allocated = msize; |
128 return mbase; | 124 return mbase; |
129 } | 125 } |
130 | 126 |
131 | 127 |
132 class PosixMemoryMappedFile : public OS::MemoryMappedFile { | 128 class PosixMemoryMappedFile : public OS::MemoryMappedFile { |
133 public: | 129 public: |
134 PosixMemoryMappedFile(FILE* file, void* memory, int size) | 130 PosixMemoryMappedFile(FILE* file, void* memory, int size) |
135 : file_(file), memory_(memory), size_(size) { } | 131 : file_(file), memory_(memory), size_(size) { } |
136 virtual ~PosixMemoryMappedFile(); | 132 virtual ~PosixMemoryMappedFile(); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 #endif | 421 #endif |
426 return munmap(base, size) == 0; | 422 return munmap(base, size) == 0; |
427 } | 423 } |
428 | 424 |
429 | 425 |
430 bool VirtualMemory::HasLazyCommits() { | 426 bool VirtualMemory::HasLazyCommits() { |
431 return true; | 427 return true; |
432 } | 428 } |
433 | 429 |
434 } } // namespace v8::internal | 430 } } // namespace v8::internal |
OLD | NEW |