OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Platform specific code for Linux goes here. For the POSIX comaptible parts | 28 // Platform-specific code for QNX goes here. For the POSIX-compatible |
29 // the implementation is in platform-posix.cc. | 29 // parts the implementation is in platform-posix.cc. |
30 | 30 |
31 #include <pthread.h> | 31 #include <pthread.h> |
32 #include <semaphore.h> | 32 #include <semaphore.h> |
33 #include <signal.h> | 33 #include <signal.h> |
34 #include <sys/prctl.h> | |
35 #include <sys/time.h> | 34 #include <sys/time.h> |
36 #include <sys/resource.h> | 35 #include <sys/resource.h> |
37 #include <sys/syscall.h> | |
38 #include <sys/types.h> | 36 #include <sys/types.h> |
39 #include <stdlib.h> | 37 #include <stdlib.h> |
38 #include <ucontext.h> | |
39 #include <backtrace.h> | |
40 | 40 |
41 // Ubuntu Dapper requires memory pages to be marked as | 41 // QNX requires memory pages to be marked as executable. |
42 // executable. Otherwise, OS raises an exception when executing code | 42 // Otherwise, the OS raises an exception when executing code in that page. |
43 // in that page. | |
44 #include <sys/types.h> // mmap & munmap | 43 #include <sys/types.h> // mmap & munmap |
45 #include <sys/mman.h> // mmap & munmap | 44 #include <sys/mman.h> // mmap & munmap |
46 #include <sys/stat.h> // open | 45 #include <sys/stat.h> // open |
47 #include <fcntl.h> // open | 46 #include <fcntl.h> // open |
48 #include <unistd.h> // sysconf | 47 #include <unistd.h> // sysconf |
49 #include <strings.h> // index | 48 #include <strings.h> // index |
50 #include <errno.h> | 49 #include <errno.h> |
51 #include <stdarg.h> | 50 #include <stdarg.h> |
52 | 51 #include <sys/procfs.h> |
53 // GLibc on ARM defines mcontext_t has a typedef for 'struct sigcontext'. | |
54 // Old versions of the C library <signal.h> didn't define the type. | |
55 #if defined(__ANDROID__) && !defined(__BIONIC_HAVE_UCONTEXT_T) && \ | |
56 defined(__arm__) && !defined(__BIONIC_HAVE_STRUCT_SIGCONTEXT) | |
57 #include <asm/sigcontext.h> | |
58 #endif | |
59 | 52 |
60 #undef MAP_TYPE | 53 #undef MAP_TYPE |
61 | 54 |
62 #include "v8.h" | 55 #include "v8.h" |
63 | 56 |
64 #include "platform.h" | 57 #include "platform.h" |
65 #include "v8threads.h" | 58 #include "v8threads.h" |
66 #include "vm-state-inl.h" | 59 #include "vm-state-inl.h" |
67 | 60 |
68 | 61 |
69 namespace v8 { | 62 namespace v8 { |
70 namespace internal { | 63 namespace internal { |
71 | 64 |
65 // 0 is never a valid thread id on Qnx since tids and pids share a | |
66 // name space and pid 0 is reserved (see man 2 kill). | |
67 static const pthread_t kNoThread = (pthread_t) 0; | |
68 | |
72 | 69 |
73 #ifdef __arm__ | 70 #ifdef __arm__ |
74 | 71 |
75 bool OS::ArmUsingHardFloat() { | 72 bool OS::ArmUsingHardFloat() { |
76 // GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify | 73 // GCC versions 4.6 and above define __ARM_PCS or __ARM_PCS_VFP to specify |
77 // the Floating Point ABI used (PCS stands for Procedure Call Standard). | 74 // the Floating Point ABI used (PCS stands for Procedure Call Standard). |
78 // We use these as well as a couple of other defines to statically determine | 75 // We use these as well as a couple of other defines to statically determine |
79 // what FP ABI used. | 76 // what FP ABI used. |
80 // GCC versions 4.4 and below don't support hard-fp. | 77 // GCC versions 4.4 and below don't support hard-fp. |
81 // GCC versions 4.5 may support hard-fp without defining __ARM_PCS or | 78 // GCC versions 4.5 may support hard-fp without defining __ARM_PCS or |
(...skipping 21 matching lines...) Expand all Loading... | |
103 #else | 100 #else |
104 #error "Your version of GCC does not report the FP ABI compiled for." \ | 101 #error "Your version of GCC does not report the FP ABI compiled for." \ |
105 "Please report it on this issue" \ | 102 "Please report it on this issue" \ |
106 "http://code.google.com/p/v8/issues/detail?id=2140" | 103 "http://code.google.com/p/v8/issues/detail?id=2140" |
107 | 104 |
108 #endif | 105 #endif |
109 #endif | 106 #endif |
110 #undef GCC_VERSION | 107 #undef GCC_VERSION |
111 } | 108 } |
112 | 109 |
113 #endif // def __arm__ | 110 #endif // __arm__ |
114 | 111 |
115 | 112 |
116 const char* OS::LocalTimezone(double time) { | 113 const char* OS::LocalTimezone(double time) { |
117 if (std::isnan(time)) return ""; | 114 if (std::isnan(time)) return ""; |
118 time_t tv = static_cast<time_t>(floor(time/msPerSecond)); | 115 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); |
119 struct tm* t = localtime(&tv); | 116 struct tm* t = localtime(&tv); |
120 if (NULL == t) return ""; | 117 if (NULL == t) return ""; |
121 return t->tm_zone; | 118 return t->tm_zone; |
122 } | 119 } |
123 | 120 |
124 | 121 |
125 double OS::LocalTimeOffset() { | 122 double OS::LocalTimeOffset() { |
126 time_t tv = time(NULL); | 123 time_t tv = time(NULL); |
127 struct tm* t = localtime(&tv); | 124 struct tm* t = localtime(&tv); |
128 // tm_gmtoff includes any daylight savings offset, so subtract it. | 125 // tm_gmtoff includes any daylight savings offset, so subtract it. |
129 return static_cast<double>(t->tm_gmtoff * msPerSecond - | 126 return static_cast<double>(t->tm_gmtoff * msPerSecond - |
130 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); | 127 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); |
131 } | 128 } |
132 | 129 |
133 | 130 |
134 void* OS::Allocate(const size_t requested, | 131 void* OS::Allocate(const size_t requested, |
135 size_t* allocated, | 132 size_t* allocated, |
136 bool is_executable) { | 133 bool is_executable) { |
137 const size_t msize = RoundUp(requested, AllocateAlignment()); | 134 const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE)); |
Benedikt Meurer
2013/11/15 11:49:59
Why not AllocateAlignment() here?
c.truta
2013/11/18 13:36:32
Wasn't deliberate. Fixed.
| |
138 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); | 135 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
139 void* addr = OS::GetRandomMmapAddr(); | 136 void* addr = OS::GetRandomMmapAddr(); |
140 void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | 137 void* mbase = mmap(addr, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
141 if (mbase == MAP_FAILED) { | 138 if (mbase == MAP_FAILED) { |
142 LOG(i::Isolate::Current(), | 139 LOG(i::Isolate::Current(), |
143 StringEvent("OS::Allocate", "mmap failed")); | 140 StringEvent("OS::Allocate", "mmap failed")); |
144 return NULL; | 141 return NULL; |
145 } | 142 } |
146 *allocated = msize; | 143 *allocated = msize; |
147 return mbase; | 144 return mbase; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 } | 197 } |
201 | 198 |
202 | 199 |
203 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 200 PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
204 if (memory_) OS::Free(memory_, size_); | 201 if (memory_) OS::Free(memory_, size_); |
205 fclose(file_); | 202 fclose(file_); |
206 } | 203 } |
207 | 204 |
208 | 205 |
209 void OS::LogSharedLibraryAddresses(Isolate* isolate) { | 206 void OS::LogSharedLibraryAddresses(Isolate* isolate) { |
210 // This function assumes that the layout of the file is as follows: | 207 procfs_mapinfo *mapinfos = NULL, *mapinfo; |
211 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] | 208 int proc_fd, num, i; |
212 // If we encounter an unexpected situation we abort scanning further entries. | |
213 FILE* fp = fopen("/proc/self/maps", "r"); | |
214 if (fp == NULL) return; | |
215 | 209 |
216 // Allocate enough room to be able to store a full file name. | 210 struct { |
217 const int kLibNameLen = FILENAME_MAX + 1; | 211 procfs_debuginfo info; |
218 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); | 212 char buff[PATH_MAX]; |
213 } map; | |
219 | 214 |
220 // This loop will terminate once the scanning hits an EOF. | 215 char buf[PATH_MAX + 1]; |
221 while (true) { | 216 snprintf(buf, PATH_MAX + 1, "/proc/%d/as", getpid()); |
222 uintptr_t start, end; | |
223 char attr_r, attr_w, attr_x, attr_p; | |
224 // Parse the addresses and permission bits at the beginning of the line. | |
225 if (fscanf(fp, "%" V8PRIxPTR "-%" V8PRIxPTR, &start, &end) != 2) break; | |
226 if (fscanf(fp, " %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4) break; | |
227 | 217 |
228 int c; | 218 if ((proc_fd = open(buf, O_RDONLY)) == -1) { |
229 if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') { | 219 close(proc_fd); |
230 // Found a read-only executable entry. Skip characters until we reach | 220 return; |
231 // the beginning of the filename or the end of the line. | 221 } |
232 do { | |
233 c = getc(fp); | |
234 } while ((c != EOF) && (c != '\n') && (c != '/') && (c != '[')); | |
235 if (c == EOF) break; // EOF: Was unexpected, just exit. | |
236 | 222 |
237 // Process the filename if found. | 223 /* Get the number of map entries. */ |
238 if ((c == '/') || (c == '[')) { | 224 if (devctl(proc_fd, DCMD_PROC_MAPINFO, NULL, 0, &num) != EOK) { |
239 // Push the '/' or '[' back into the stream to be read below. | 225 close(proc_fd); |
240 ungetc(c, fp); | 226 return; |
227 } | |
241 | 228 |
242 // Read to the end of the line. Exit if the read fails. | 229 mapinfos = reinterpret_cast<procfs_mapinfo *>( |
243 if (fgets(lib_name, kLibNameLen, fp) == NULL) break; | 230 malloc(num * sizeof(procfs_mapinfo))); |
231 if (mapinfos == NULL) { | |
232 close(proc_fd); | |
233 return; | |
234 } | |
244 | 235 |
245 // Drop the newline character read by fgets. We do not need to check | 236 /* Fill the map entries. */ |
246 // for a zero-length string because we know that we at least read the | 237 if (devctl(proc_fd, DCMD_PROC_PAGEDATA, |
247 // '/' or '[' character. | 238 mapinfos, num * sizeof(procfs_mapinfo), &num) != EOK) { |
248 lib_name[strlen(lib_name) - 1] = '\0'; | 239 free(mapinfos); |
249 } else { | 240 close(proc_fd); |
250 // No library name found, just record the raw address range. | 241 return; |
251 snprintf(lib_name, kLibNameLen, | 242 } |
252 "%08" V8PRIxPTR "-%08" V8PRIxPTR, start, end); | 243 |
244 for (i = 0; i < num; i++) { | |
245 mapinfo = mapinfos + i; | |
246 if (mapinfo->flags & MAP_ELF) { | |
247 map.info.vaddr = mapinfo->vaddr; | |
248 if (devctl(proc_fd, DCMD_PROC_MAPDEBUG, &map, sizeof(map), 0) != EOK) { | |
249 continue; | |
253 } | 250 } |
254 LOG(isolate, SharedLibraryEvent(lib_name, start, end)); | 251 LOG(isolate, SharedLibraryEvent(map.info.path, |
255 } else { | 252 mapinfo->vaddr, |
256 // Entry not describing executable data. Skip to end of line to set up | 253 mapinfo->vaddr + mapinfo->size)); |
257 // reading the next entry. | |
258 do { | |
259 c = getc(fp); | |
260 } while ((c != EOF) && (c != '\n')); | |
261 if (c == EOF) break; | |
262 } | 254 } |
263 } | 255 } |
264 free(lib_name); | 256 free(mapinfos); |
265 fclose(fp); | 257 close(proc_fd); |
266 } | 258 } |
267 | 259 |
268 | 260 |
261 static const char kGCFakeMmap[] = "/tmp/__v8_gc__"; | |
262 | |
263 | |
269 void OS::SignalCodeMovingGC() { | 264 void OS::SignalCodeMovingGC() { |
Benedikt Meurer
2013/11/15 11:49:59
Is there any support for perf/ll_prof in QNX? Othe
| |
270 // Support for ll_prof.py. | 265 // Support for ll_prof.py. |
271 // | 266 // |
272 // The Linux profiler built into the kernel logs all mmap's with | 267 // The QNX profiler built into the kernel logs all mmap's with |
273 // PROT_EXEC so that analysis tools can properly attribute ticks. We | 268 // PROT_EXEC so that analysis tools can properly attribute ticks. We |
274 // do a mmap with a name known by ll_prof.py and immediately munmap | 269 // do a mmap with a name known by ll_prof.py and immediately munmap |
275 // it. This injects a GC marker into the stream of events generated | 270 // it. This injects a GC marker into the stream of events generated |
276 // by the kernel and allows us to synchronize V8 code log and the | 271 // by the kernel and allows us to synchronize V8 code log and the |
277 // kernel log. | 272 // kernel log. |
278 int size = sysconf(_SC_PAGESIZE); | 273 int size = sysconf(_SC_PAGESIZE); |
279 FILE* f = fopen(FLAG_gc_fake_mmap, "w+"); | 274 FILE* f = fopen(kGCFakeMmap, "w+"); |
280 if (f == NULL) { | |
281 OS::PrintError("Failed to open %s\n", FLAG_gc_fake_mmap); | |
282 OS::Abort(); | |
283 } | |
284 void* addr = mmap(OS::GetRandomMmapAddr(), | 275 void* addr = mmap(OS::GetRandomMmapAddr(), |
285 size, | 276 size, |
286 #if defined(__native_client__) | |
287 // The Native Client port of V8 uses an interpreter, | |
288 // so code pages don't need PROT_EXEC. | |
289 PROT_READ, | |
290 #else | |
291 PROT_READ | PROT_EXEC, | 277 PROT_READ | PROT_EXEC, |
292 #endif | |
293 MAP_PRIVATE, | 278 MAP_PRIVATE, |
294 fileno(f), | 279 fileno(f), |
295 0); | 280 0); |
296 ASSERT(addr != MAP_FAILED); | 281 ASSERT(addr != MAP_FAILED); |
297 OS::Free(addr, size); | 282 OS::Free(addr, size); |
298 fclose(f); | 283 fclose(f); |
299 } | 284 } |
300 | 285 |
301 | 286 |
302 // Constants used for mmap. | 287 // Constants used for mmap. |
303 static const int kMmapFd = -1; | 288 static const int kMmapFd = -1; |
304 static const int kMmapFdOffset = 0; | 289 static const int kMmapFdOffset = 0; |
305 | 290 |
306 | 291 |
307 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } | 292 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } |
308 | 293 |
309 | 294 |
310 VirtualMemory::VirtualMemory(size_t size) | 295 VirtualMemory::VirtualMemory(size_t size) |
311 : address_(ReserveRegion(size)), size_(size) { } | 296 : address_(ReserveRegion(size)), size_(size) { } |
312 | 297 |
313 | 298 |
314 VirtualMemory::VirtualMemory(size_t size, size_t alignment) | 299 VirtualMemory::VirtualMemory(size_t size, size_t alignment) |
315 : address_(NULL), size_(0) { | 300 : address_(NULL), size_(0) { |
316 ASSERT(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); | 301 ASSERT(IsAligned(alignment, static_cast<intptr_t>(OS::AllocateAlignment()))); |
317 size_t request_size = RoundUp(size + alignment, | 302 size_t request_size = RoundUp(size + alignment, |
318 static_cast<intptr_t>(OS::AllocateAlignment())); | 303 static_cast<intptr_t>(OS::AllocateAlignment())); |
319 void* reservation = mmap(OS::GetRandomMmapAddr(), | 304 void* reservation = mmap(OS::GetRandomMmapAddr(), |
320 request_size, | 305 request_size, |
321 PROT_NONE, | 306 PROT_NONE, |
322 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, | 307 MAP_PRIVATE | MAP_ANONYMOUS | MAP_LAZY, |
323 kMmapFd, | 308 kMmapFd, |
324 kMmapFdOffset); | 309 kMmapFdOffset); |
325 if (reservation == MAP_FAILED) return; | 310 if (reservation == MAP_FAILED) return; |
326 | 311 |
327 Address base = static_cast<Address>(reservation); | 312 Address base = static_cast<Address>(reservation); |
328 Address aligned_base = RoundUp(base, alignment); | 313 Address aligned_base = RoundUp(base, alignment); |
329 ASSERT_LE(base, aligned_base); | 314 ASSERT_LE(base, aligned_base); |
330 | 315 |
331 // Unmap extra memory reserved before and after the desired block. | 316 // Unmap extra memory reserved before and after the desired block. |
332 if (aligned_base != base) { | 317 if (aligned_base != base) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 bool VirtualMemory::Guard(void* address) { | 369 bool VirtualMemory::Guard(void* address) { |
385 OS::Guard(address, OS::CommitPageSize()); | 370 OS::Guard(address, OS::CommitPageSize()); |
386 return true; | 371 return true; |
387 } | 372 } |
388 | 373 |
389 | 374 |
390 void* VirtualMemory::ReserveRegion(size_t size) { | 375 void* VirtualMemory::ReserveRegion(size_t size) { |
391 void* result = mmap(OS::GetRandomMmapAddr(), | 376 void* result = mmap(OS::GetRandomMmapAddr(), |
392 size, | 377 size, |
393 PROT_NONE, | 378 PROT_NONE, |
394 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, | 379 MAP_PRIVATE | MAP_ANONYMOUS | MAP_LAZY, |
395 kMmapFd, | 380 kMmapFd, |
396 kMmapFdOffset); | 381 kMmapFdOffset); |
397 | 382 |
398 if (result == MAP_FAILED) return NULL; | 383 if (result == MAP_FAILED) return NULL; |
399 | 384 |
400 return result; | 385 return result; |
401 } | 386 } |
402 | 387 |
403 | 388 |
404 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) { | 389 bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) { |
405 #if defined(__native_client__) | |
406 // The Native Client port of V8 uses an interpreter, | |
407 // so code pages don't need PROT_EXEC. | |
408 int prot = PROT_READ | PROT_WRITE; | |
409 #else | |
410 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); | 390 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
411 #endif | |
412 if (MAP_FAILED == mmap(base, | 391 if (MAP_FAILED == mmap(base, |
413 size, | 392 size, |
414 prot, | 393 prot, |
415 MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, | 394 MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, |
416 kMmapFd, | 395 kMmapFd, |
417 kMmapFdOffset)) { | 396 kMmapFdOffset)) { |
418 return false; | 397 return false; |
419 } | 398 } |
420 | 399 |
421 return true; | 400 return true; |
422 } | 401 } |
423 | 402 |
424 | 403 |
425 bool VirtualMemory::UncommitRegion(void* base, size_t size) { | 404 bool VirtualMemory::UncommitRegion(void* base, size_t size) { |
426 return mmap(base, | 405 return mmap(base, |
427 size, | 406 size, |
428 PROT_NONE, | 407 PROT_NONE, |
429 MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_FIXED, | 408 MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED | MAP_LAZY, |
430 kMmapFd, | 409 kMmapFd, |
431 kMmapFdOffset) != MAP_FAILED; | 410 kMmapFdOffset) != MAP_FAILED; |
432 } | 411 } |
433 | 412 |
434 | 413 |
435 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { | 414 bool VirtualMemory::ReleaseRegion(void* base, size_t size) { |
436 return munmap(base, size) == 0; | 415 return munmap(base, size) == 0; |
437 } | 416 } |
438 | 417 |
439 | 418 |
440 bool VirtualMemory::HasLazyCommits() { | 419 bool VirtualMemory::HasLazyCommits() { |
441 return true; | 420 return false; |
442 } | 421 } |
443 | 422 |
444 } } // namespace v8::internal | 423 } } // namespace v8::internal |
OLD | NEW |