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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 // ---------------------------------------------------------------------------- | 133 // ---------------------------------------------------------------------------- |
134 // OS | 134 // OS |
135 // | 135 // |
136 // This class has static methods for the different platform specific | 136 // This class has static methods for the different platform specific |
137 // functions. Add methods here to cope with differences between the | 137 // functions. Add methods here to cope with differences between the |
138 // supported platforms. | 138 // supported platforms. |
139 | 139 |
140 class OS { | 140 class OS { |
141 public: | 141 public: |
142 // Initializes the platform OS support that depend on CPU features. This is | |
143 // called after CPU initialization. | |
144 static void PostSetUp(); | |
145 | |
146 // Returns the accumulated user time for thread. This routine | 142 // Returns the accumulated user time for thread. This routine |
147 // can be used for profiling. The implementation should | 143 // can be used for profiling. The implementation should |
148 // strive for high-precision timer resolution, preferable | 144 // strive for high-precision timer resolution, preferable |
149 // micro-second resolution. | 145 // micro-second resolution. |
150 static int GetUserTime(uint32_t* secs, uint32_t* usecs); | 146 static int GetUserTime(uint32_t* secs, uint32_t* usecs); |
151 | 147 |
152 // Returns current time as the number of milliseconds since | 148 // Returns current time as the number of milliseconds since |
153 // 00:00:00 UTC, January 1, 1970. | 149 // 00:00:00 UTC, January 1, 1970. |
154 static double TimeCurrentMillis(); | 150 static double TimeCurrentMillis(); |
155 | 151 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 static double nan_value(); | 284 static double nan_value(); |
289 | 285 |
290 // Support runtime detection of whether the hard float option of the | 286 // Support runtime detection of whether the hard float option of the |
291 // EABI is used. | 287 // EABI is used. |
292 static bool ArmUsingHardFloat(); | 288 static bool ArmUsingHardFloat(); |
293 | 289 |
294 // Returns the activation frame alignment constraint or zero if | 290 // Returns the activation frame alignment constraint or zero if |
295 // the platform doesn't care. Guaranteed to be a power of two. | 291 // the platform doesn't care. Guaranteed to be a power of two. |
296 static int ActivationFrameAlignment(); | 292 static int ActivationFrameAlignment(); |
297 | 293 |
298 #if defined(V8_TARGET_ARCH_IA32) || defined(V8_TARGET_ARCH_X87) | |
299 // Limit below which the extra overhead of the MemCopy function is likely | |
300 // to outweigh the benefits of faster copying. | |
301 static const int kMinComplexMemCopy = 64; | |
302 | |
303 // Copy memory area. No restrictions. | |
304 static void MemMove(void* dest, const void* src, size_t size); | |
305 typedef void (*MemMoveFunction)(void* dest, const void* src, size_t size); | |
306 | |
307 // Keep the distinction of "move" vs. "copy" for the benefit of other | |
308 // architectures. | |
309 static void MemCopy(void* dest, const void* src, size_t size) { | |
310 MemMove(dest, src, size); | |
311 } | |
312 #elif defined(V8_HOST_ARCH_ARM) | |
313 typedef void (*MemCopyUint8Function)(uint8_t* dest, | |
314 const uint8_t* src, | |
315 size_t size); | |
316 static MemCopyUint8Function memcopy_uint8_function; | |
317 static void MemCopyUint8Wrapper(uint8_t* dest, | |
318 const uint8_t* src, | |
319 size_t chars) { | |
320 memcpy(dest, src, chars); | |
321 } | |
322 // For values < 16, the assembler function is slower than the inlined C code. | |
323 static const int kMinComplexMemCopy = 16; | |
324 static void MemCopy(void* dest, const void* src, size_t size) { | |
325 (*memcopy_uint8_function)(reinterpret_cast<uint8_t*>(dest), | |
326 reinterpret_cast<const uint8_t*>(src), | |
327 size); | |
328 } | |
329 static void MemMove(void* dest, const void* src, size_t size) { | |
330 memmove(dest, src, size); | |
331 } | |
332 | |
333 typedef void (*MemCopyUint16Uint8Function)(uint16_t* dest, | |
334 const uint8_t* src, | |
335 size_t size); | |
336 static MemCopyUint16Uint8Function memcopy_uint16_uint8_function; | |
337 static void MemCopyUint16Uint8Wrapper(uint16_t* dest, | |
338 const uint8_t* src, | |
339 size_t chars); | |
340 // For values < 12, the assembler function is slower than the inlined C code. | |
341 static const int kMinComplexConvertMemCopy = 12; | |
342 static void MemCopyUint16Uint8(uint16_t* dest, | |
343 const uint8_t* src, | |
344 size_t size) { | |
345 (*memcopy_uint16_uint8_function)(dest, src, size); | |
346 } | |
347 #elif defined(V8_HOST_ARCH_MIPS) | |
348 typedef void (*MemCopyUint8Function)(uint8_t* dest, | |
349 const uint8_t* src, | |
350 size_t size); | |
351 static MemCopyUint8Function memcopy_uint8_function; | |
352 static void MemCopyUint8Wrapper(uint8_t* dest, | |
353 const uint8_t* src, | |
354 size_t chars) { | |
355 memcpy(dest, src, chars); | |
356 } | |
357 // For values < 16, the assembler function is slower than the inlined C code. | |
358 static const int kMinComplexMemCopy = 16; | |
359 static void MemCopy(void* dest, const void* src, size_t size) { | |
360 (*memcopy_uint8_function)(reinterpret_cast<uint8_t*>(dest), | |
361 reinterpret_cast<const uint8_t*>(src), | |
362 size); | |
363 } | |
364 static void MemMove(void* dest, const void* src, size_t size) { | |
365 memmove(dest, src, size); | |
366 } | |
367 #else | |
368 // Copy memory area to disjoint memory area. | |
369 static void MemCopy(void* dest, const void* src, size_t size) { | |
370 memcpy(dest, src, size); | |
371 } | |
372 static void MemMove(void* dest, const void* src, size_t size) { | |
373 memmove(dest, src, size); | |
374 } | |
375 static const int kMinComplexMemCopy = 16 * kPointerSize; | |
376 #endif // V8_TARGET_ARCH_IA32 | |
377 | |
378 static int GetCurrentProcessId(); | 294 static int GetCurrentProcessId(); |
379 | 295 |
380 private: | 296 private: |
381 static const int msPerSecond = 1000; | 297 static const int msPerSecond = 1000; |
382 | 298 |
383 DISALLOW_IMPLICIT_CONSTRUCTORS(OS); | 299 DISALLOW_IMPLICIT_CONSTRUCTORS(OS); |
384 }; | 300 }; |
385 | 301 |
386 // Represents and controls an area of reserved memory. | 302 // Represents and controls an area of reserved memory. |
387 // Control of the reserved memory can be assigned to another VirtualMemory | 303 // Control of the reserved memory can be assigned to another VirtualMemory |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 char name_[kMaxThreadNameLength]; | 503 char name_[kMaxThreadNameLength]; |
588 int stack_size_; | 504 int stack_size_; |
589 Semaphore* start_semaphore_; | 505 Semaphore* start_semaphore_; |
590 | 506 |
591 DISALLOW_COPY_AND_ASSIGN(Thread); | 507 DISALLOW_COPY_AND_ASSIGN(Thread); |
592 }; | 508 }; |
593 | 509 |
594 } } // namespace v8::internal | 510 } } // namespace v8::internal |
595 | 511 |
596 #endif // V8_PLATFORM_H_ | 512 #endif // V8_PLATFORM_H_ |
OLD | NEW |