OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include <sys/socket.h> | 35 #include <sys/socket.h> |
36 #include <sys/types.h> | 36 #include <sys/types.h> |
37 #include <stdlib.h> | 37 #include <stdlib.h> |
38 | 38 |
39 // Ubuntu Dapper requires memory pages to be marked as | 39 // Ubuntu Dapper requires memory pages to be marked as |
40 // executable. Otherwise, OS raises an exception when executing code | 40 // executable. Otherwise, OS raises an exception when executing code |
41 // in that page. | 41 // in that page. |
42 #include <sys/types.h> // mmap & munmap | 42 #include <sys/types.h> // mmap & munmap |
43 #include <sys/mman.h> // mmap & munmap | 43 #include <sys/mman.h> // mmap & munmap |
44 #include <sys/stat.h> // open | 44 #include <sys/stat.h> // open |
45 #include <sys/fcntl.h> // open | 45 #include <fcntl.h> // open |
46 #include <unistd.h> // getpagesize | 46 #include <unistd.h> // sysconf |
47 #include <execinfo.h> // backtrace, backtrace_symbols | 47 #include <execinfo.h> // backtrace, backtrace_symbols |
48 #include <strings.h> // index | 48 #include <strings.h> // index |
49 #include <errno.h> | 49 #include <errno.h> |
50 #include <stdarg.h> | 50 #include <stdarg.h> |
51 | 51 |
52 #include <arpa/inet.h> | 52 #include <arpa/inet.h> |
53 #include <netinet/in.h> | 53 #include <netinet/in.h> |
54 #include <netdb.h> | 54 #include <netdb.h> |
55 | 55 |
56 #undef MAP_TYPE | 56 #undef MAP_TYPE |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); | 223 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); |
224 } | 224 } |
225 | 225 |
226 | 226 |
227 bool OS::IsOutsideAllocatedSpace(void* address) { | 227 bool OS::IsOutsideAllocatedSpace(void* address) { |
228 return address < lowest_ever_allocated || address >= highest_ever_allocated; | 228 return address < lowest_ever_allocated || address >= highest_ever_allocated; |
229 } | 229 } |
230 | 230 |
231 | 231 |
232 size_t OS::AllocateAlignment() { | 232 size_t OS::AllocateAlignment() { |
233 return getpagesize(); | 233 return sysconf(_SC_PAGESIZE); |
234 } | 234 } |
235 | 235 |
236 | 236 |
237 void* OS::Allocate(const size_t requested, | 237 void* OS::Allocate(const size_t requested, |
238 size_t* allocated, | 238 size_t* allocated, |
239 bool executable) { | 239 bool executable) { |
240 const size_t msize = RoundUp(requested, getpagesize()); | 240 const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE)); |
241 int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0); | 241 int prot = PROT_READ | PROT_WRITE | (executable ? PROT_EXEC : 0); |
242 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | 242 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
243 if (mbase == MAP_FAILED) { | 243 if (mbase == MAP_FAILED) { |
244 LOG(StringEvent("OS::Allocate", "mmap failed")); | 244 LOG(StringEvent("OS::Allocate", "mmap failed")); |
245 return NULL; | 245 return NULL; |
246 } | 246 } |
247 *allocated = msize; | 247 *allocated = msize; |
248 UpdateAllocatedSpaceLimits(mbase, msize); | 248 UpdateAllocatedSpaceLimits(mbase, msize); |
249 return mbase; | 249 return mbase; |
250 } | 250 } |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 } | 893 } |
894 | 894 |
895 // This sampler is no longer the active sampler. | 895 // This sampler is no longer the active sampler. |
896 active_sampler_ = NULL; | 896 active_sampler_ = NULL; |
897 active_ = false; | 897 active_ = false; |
898 } | 898 } |
899 | 899 |
900 #endif // ENABLE_LOGGING_AND_PROFILING | 900 #endif // ENABLE_LOGGING_AND_PROFILING |
901 | 901 |
902 } } // namespace v8::internal | 902 } } // namespace v8::internal |
OLD | NEW |