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 <mach/mach_init.h> | 9 #include <mach/mach_init.h> |
10 #include <mach-o/dyld.h> | 10 #include <mach-o/dyld.h> |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include <sys/resource.h> | 29 #include <sys/resource.h> |
30 #include <sys/sysctl.h> | 30 #include <sys/sysctl.h> |
31 #include <sys/time.h> | 31 #include <sys/time.h> |
32 #include <sys/types.h> | 32 #include <sys/types.h> |
33 | 33 |
34 #include <cmath> | 34 #include <cmath> |
35 | 35 |
36 #undef MAP_TYPE | 36 #undef MAP_TYPE |
37 | 37 |
38 #include "src/base/macros.h" | 38 #include "src/base/macros.h" |
| 39 #include "src/base/platform/platform-posix.h" |
39 #include "src/base/platform/platform.h" | 40 #include "src/base/platform/platform.h" |
40 | 41 |
41 | 42 |
42 namespace v8 { | 43 namespace v8 { |
43 namespace base { | 44 namespace base { |
44 | 45 |
45 | 46 |
46 // Constants used for mmap. | 47 // Constants used for mmap. |
47 // kMmapFd is used to pass vm_alloc flags to tag the region with the user | 48 // kMmapFd is used to pass vm_alloc flags to tag the region with the user |
48 // defined tag 255 This helps identify V8-allocated regions in memory analysis | 49 // defined tag 255 This helps identify V8-allocated regions in memory analysis |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 result.push_back(SharedLibraryAddress(_dyld_get_image_name(i), start, | 92 result.push_back(SharedLibraryAddress(_dyld_get_image_name(i), start, |
92 start + size, slide)); | 93 start + size, slide)); |
93 } | 94 } |
94 return result; | 95 return result; |
95 } | 96 } |
96 | 97 |
97 | 98 |
98 void OS::SignalCodeMovingGC() { | 99 void OS::SignalCodeMovingGC() { |
99 } | 100 } |
100 | 101 |
101 | 102 TimezoneCache* OS::CreateTimezoneCache() { return new PosixTimezoneCache(); } |
102 const char* OS::LocalTimezone(double time, TimezoneCache* cache) { | |
103 if (std::isnan(time)) return ""; | |
104 time_t tv = static_cast<time_t>(std::floor(time/msPerSecond)); | |
105 struct tm tm; | |
106 struct tm* t = localtime_r(&tv, &tm); | |
107 if (NULL == t) return ""; | |
108 return t->tm_zone; | |
109 } | |
110 | |
111 | |
112 double OS::LocalTimeOffset(TimezoneCache* cache) { | |
113 time_t tv = time(NULL); | |
114 struct tm tm; | |
115 struct tm* t = localtime_r(&tv, &tm); | |
116 // tm_gmtoff includes any daylight savings offset, so subtract it. | |
117 return static_cast<double>(t->tm_gmtoff * msPerSecond - | |
118 (t->tm_isdst > 0 ? 3600 * msPerSecond : 0)); | |
119 } | |
120 | |
121 | 103 |
122 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } | 104 VirtualMemory::VirtualMemory() : address_(NULL), size_(0) { } |
123 | 105 |
124 | 106 |
125 VirtualMemory::VirtualMemory(size_t size) | 107 VirtualMemory::VirtualMemory(size_t size) |
126 : address_(ReserveRegion(size)), size_(size) { } | 108 : address_(ReserveRegion(size)), size_(size) { } |
127 | 109 |
128 | 110 |
129 VirtualMemory::VirtualMemory(size_t size, size_t alignment) | 111 VirtualMemory::VirtualMemory(size_t size, size_t alignment) |
130 : address_(NULL), size_(0) { | 112 : address_(NULL), size_(0) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } | 229 } |
248 | 230 |
249 bool VirtualMemory::ReleaseRegion(void* address, size_t size) { | 231 bool VirtualMemory::ReleaseRegion(void* address, size_t size) { |
250 return munmap(address, size) == 0; | 232 return munmap(address, size) == 0; |
251 } | 233 } |
252 | 234 |
253 bool VirtualMemory::HasLazyCommits() { return true; } | 235 bool VirtualMemory::HasLazyCommits() { return true; } |
254 | 236 |
255 } // namespace base | 237 } // namespace base |
256 } // namespace v8 | 238 } // namespace v8 |
OLD | NEW |