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 // This module contains the platform-specific code. This make the rest of the | 5 // This module contains the platform-specific code. This make the rest of the |
6 // code less dependent on operating system, compilers and runtime libraries. | 6 // code less dependent on operating system, compilers and runtime libraries. |
7 // This module does specifically not deal with differences between different | 7 // This module does specifically not deal with differences between different |
8 // processor architecture. | 8 // processor architecture. |
9 // The platform classes have the same definition for all platforms. The | 9 // The platform classes have the same definition for all platforms. The |
10 // implementation for a particular platform is put in platform_<os>.cc. | 10 // implementation for a particular platform is put in platform_<os>.cc. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 // ---------------------------------------------------------------------------- | 135 // ---------------------------------------------------------------------------- |
136 // OS | 136 // OS |
137 // | 137 // |
138 // This class has static methods for the different platform specific | 138 // This class has static methods for the different platform specific |
139 // functions. Add methods here to cope with differences between the | 139 // functions. Add methods here to cope with differences between the |
140 // supported platforms. | 140 // supported platforms. |
141 | 141 |
142 class OS { | 142 class OS { |
143 public: | 143 public: |
| 144 // Initialize the OS class. |
| 145 // - random_seed: Used for the GetRandomMmapAddress() if non-zero. |
| 146 // - hard_abort: If true, OS::Abort() will crash instead of aborting. |
| 147 // - gc_fake_mmap: Name of the file for fake gc mmap used in ll_prof. |
| 148 static void Initialize(int64_t random_seed, |
| 149 bool hard_abort, |
| 150 const char* const gc_fake_mmap); |
| 151 |
144 // Returns the accumulated user time for thread. This routine | 152 // Returns the accumulated user time for thread. This routine |
145 // can be used for profiling. The implementation should | 153 // can be used for profiling. The implementation should |
146 // strive for high-precision timer resolution, preferable | 154 // strive for high-precision timer resolution, preferable |
147 // micro-second resolution. | 155 // micro-second resolution. |
148 static int GetUserTime(uint32_t* secs, uint32_t* usecs); | 156 static int GetUserTime(uint32_t* secs, uint32_t* usecs); |
149 | 157 |
150 // Returns current time as the number of milliseconds since | 158 // Returns current time as the number of milliseconds since |
151 // 00:00:00 UTC, January 1, 1970. | 159 // 00:00:00 UTC, January 1, 1970. |
152 static double TimeCurrentMillis(); | 160 static double TimeCurrentMillis(); |
153 | 161 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // This is the granularity at which the ProtectCode(...) call can set page | 213 // This is the granularity at which the ProtectCode(...) call can set page |
206 // permissions. | 214 // permissions. |
207 static intptr_t CommitPageSize(); | 215 static intptr_t CommitPageSize(); |
208 | 216 |
209 // Mark code segments non-writable. | 217 // Mark code segments non-writable. |
210 static void ProtectCode(void* address, const size_t size); | 218 static void ProtectCode(void* address, const size_t size); |
211 | 219 |
212 // Assign memory as a guard page so that access will cause an exception. | 220 // Assign memory as a guard page so that access will cause an exception. |
213 static void Guard(void* address, const size_t size); | 221 static void Guard(void* address, const size_t size); |
214 | 222 |
215 // Set a fixed random seed for the random number generator used for | |
216 // GetRandomMmapAddr. | |
217 static void SetRandomSeed(int64_t seed); | |
218 | |
219 // Generate a random address to be used for hinting mmap(). | 223 // Generate a random address to be used for hinting mmap(). |
220 static void* GetRandomMmapAddr(); | 224 static void* GetRandomMmapAddr(); |
221 | 225 |
222 // Get the Alignment guaranteed by Allocate(). | 226 // Get the Alignment guaranteed by Allocate(). |
223 static size_t AllocateAlignment(); | 227 static size_t AllocateAlignment(); |
224 | 228 |
225 // Sleep for a number of milliseconds. | 229 // Sleep for a number of milliseconds. |
226 static void Sleep(const int milliseconds); | 230 static void Sleep(const int milliseconds); |
227 | 231 |
228 // Abort the current process. | 232 // Abort the current process. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 303 |
300 // Returns the activation frame alignment constraint or zero if | 304 // Returns the activation frame alignment constraint or zero if |
301 // the platform doesn't care. Guaranteed to be a power of two. | 305 // the platform doesn't care. Guaranteed to be a power of two. |
302 static int ActivationFrameAlignment(); | 306 static int ActivationFrameAlignment(); |
303 | 307 |
304 static int GetCurrentProcessId(); | 308 static int GetCurrentProcessId(); |
305 | 309 |
306 private: | 310 private: |
307 static const int msPerSecond = 1000; | 311 static const int msPerSecond = 1000; |
308 | 312 |
| 313 #if V8_OS_POSIX |
| 314 static const char* GetGCFakeMMapFile(); |
| 315 #endif |
| 316 |
309 DISALLOW_IMPLICIT_CONSTRUCTORS(OS); | 317 DISALLOW_IMPLICIT_CONSTRUCTORS(OS); |
310 }; | 318 }; |
311 | 319 |
312 // Represents and controls an area of reserved memory. | 320 // Represents and controls an area of reserved memory. |
313 // Control of the reserved memory can be assigned to another VirtualMemory | 321 // Control of the reserved memory can be assigned to another VirtualMemory |
314 // object by assignment or copy-contructing. This removes the reserved memory | 322 // object by assignment or copy-contructing. This removes the reserved memory |
315 // from the original object. | 323 // from the original object. |
316 class VirtualMemory { | 324 class VirtualMemory { |
317 public: | 325 public: |
318 // Empty VirtualMemory object, controlling no reserved memory. | 326 // Empty VirtualMemory object, controlling no reserved memory. |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 char name_[kMaxThreadNameLength]; | 515 char name_[kMaxThreadNameLength]; |
508 int stack_size_; | 516 int stack_size_; |
509 Semaphore* start_semaphore_; | 517 Semaphore* start_semaphore_; |
510 | 518 |
511 DISALLOW_COPY_AND_ASSIGN(Thread); | 519 DISALLOW_COPY_AND_ASSIGN(Thread); |
512 }; | 520 }; |
513 | 521 |
514 } } // namespace v8::internal | 522 } } // namespace v8::internal |
515 | 523 |
516 #endif // V8_PLATFORM_H_ | 524 #endif // V8_PLATFORM_H_ |
OLD | NEW |