OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 | 57 |
58 double ceiling(double x) { | 58 double ceiling(double x) { |
59 return ceil(x); | 59 return ceil(x); |
60 } | 60 } |
61 | 61 |
62 | 62 |
63 static Mutex* limit_mutex = NULL; | 63 static Mutex* limit_mutex = NULL; |
64 | 64 |
65 | 65 |
66 void OS::PostSetUp() { | |
67 POSIXPostSetUp(); | |
68 } | |
69 | |
70 | |
71 uint64_t OS::CpuFeaturesImpliedByPlatform() { | 66 uint64_t OS::CpuFeaturesImpliedByPlatform() { |
72 return 0; // Nothing special about Cygwin. | 67 return 0; // Nothing special about Cygwin. |
73 } | 68 } |
74 | 69 |
75 | 70 |
76 int OS::ActivationFrameAlignment() { | 71 int OS::ActivationFrameAlignment() { |
77 // With gcc 4.4 the tree vectorization optimizer can generate code | 72 // With gcc 4.4 the tree vectorization optimizer can generate code |
78 // that requires 16 byte alignment such as movdqa on x86. | 73 // that requires 16 byte alignment such as movdqa on x86. |
79 return 16; | 74 return 16; |
80 } | 75 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 Max(highest_ever_allocated, | 114 Max(highest_ever_allocated, |
120 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); | 115 reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size)); |
121 } | 116 } |
122 | 117 |
123 | 118 |
124 bool OS::IsOutsideAllocatedSpace(void* address) { | 119 bool OS::IsOutsideAllocatedSpace(void* address) { |
125 return address < lowest_ever_allocated || address >= highest_ever_allocated; | 120 return address < lowest_ever_allocated || address >= highest_ever_allocated; |
126 } | 121 } |
127 | 122 |
128 | 123 |
129 size_t OS::AllocateAlignment() { | |
130 return sysconf(_SC_PAGESIZE); | |
131 } | |
132 | |
133 | |
134 void* OS::Allocate(const size_t requested, | 124 void* OS::Allocate(const size_t requested, |
135 size_t* allocated, | 125 size_t* allocated, |
136 bool is_executable) { | 126 bool is_executable) { |
137 const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE)); | 127 const size_t msize = RoundUp(requested, sysconf(_SC_PAGESIZE)); |
138 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); | 128 int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); |
139 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); | 129 void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
140 if (mbase == MAP_FAILED) { | 130 if (mbase == MAP_FAILED) { |
141 LOG(ISOLATE, StringEvent("OS::Allocate", "mmap failed")); | 131 LOG(ISOLATE, StringEvent("OS::Allocate", "mmap failed")); |
142 return NULL; | 132 return NULL; |
143 } | 133 } |
144 *allocated = msize; | 134 *allocated = msize; |
145 UpdateAllocatedSpaceLimits(mbase, msize); | 135 UpdateAllocatedSpaceLimits(mbase, msize); |
146 return mbase; | 136 return mbase; |
147 } | 137 } |
148 | 138 |
149 | 139 |
150 void OS::Free(void* address, const size_t size) { | |
151 // TODO(1240712): munmap has a return value which is ignored here. | |
152 int result = munmap(address, size); | |
153 USE(result); | |
154 ASSERT(result == 0); | |
155 } | |
156 | |
157 | |
158 void OS::ProtectCode(void* address, const size_t size) { | |
159 DWORD old_protect; | |
160 VirtualProtect(address, size, PAGE_EXECUTE_READ, &old_protect); | |
161 } | |
162 | |
163 | |
164 void OS::Guard(void* address, const size_t size) { | |
165 DWORD oldprotect; | |
166 VirtualProtect(address, size, PAGE_READONLY | PAGE_GUARD, &oldprotect); | |
167 } | |
168 | |
169 | |
170 void OS::Sleep(int milliseconds) { | |
171 unsigned int ms = static_cast<unsigned int>(milliseconds); | |
172 usleep(1000 * ms); | |
173 } | |
174 | |
175 | |
176 int OS::NumberOfCores() { | |
177 return sysconf(_SC_NPROCESSORS_ONLN); | |
178 } | |
179 | |
180 | |
181 void OS::Abort() { | |
182 // Redirect to std abort to signal abnormal program termination. | |
183 abort(); | |
184 } | |
185 | |
186 | |
187 void OS::DebugBreak() { | |
188 asm("int $3"); | |
189 } | |
190 | |
191 | |
192 void OS::DumpBacktrace() { | 140 void OS::DumpBacktrace() { |
193 // Currently unsupported. | 141 // Currently unsupported. |
194 } | 142 } |
195 | 143 |
196 | 144 |
197 class PosixMemoryMappedFile : public OS::MemoryMappedFile { | 145 class PosixMemoryMappedFile : public OS::MemoryMappedFile { |
198 public: | 146 public: |
199 PosixMemoryMappedFile(FILE* file, void* memory, int size) | 147 PosixMemoryMappedFile(FILE* file, void* memory, int size) |
200 : file_(file), memory_(memory), size_(size) { } | 148 : file_(file), memory_(memory), size_(size) { } |
201 virtual ~PosixMemoryMappedFile(); | 149 virtual ~PosixMemoryMappedFile(); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 limit_mutex = CreateMutex(); | 598 limit_mutex = CreateMutex(); |
651 } | 599 } |
652 | 600 |
653 | 601 |
654 void OS::TearDown() { | 602 void OS::TearDown() { |
655 delete limit_mutex; | 603 delete limit_mutex; |
656 } | 604 } |
657 | 605 |
658 | 606 |
659 } } // namespace v8::internal | 607 } } // namespace v8::internal |
OLD | NEW |