Chromium Code Reviews| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 // __GNUC_PREREQ is not defined in GCC for Mac OS X, so we define our own macro | 107 // __GNUC_PREREQ is not defined in GCC for Mac OS X, so we define our own macro |
| 108 #if __GNUC_VERSION__ >= 29600 && __GNUC_VERSION__ < 40100 | 108 #if __GNUC_VERSION__ >= 29600 && __GNUC_VERSION__ < 40100 |
| 109 #include <limits> | 109 #include <limits> |
| 110 #undef V8_INFINITY | 110 #undef V8_INFINITY |
| 111 #define V8_INFINITY std::numeric_limits<double>::infinity() | 111 #define V8_INFINITY std::numeric_limits<double>::infinity() |
| 112 #endif | 112 #endif |
| 113 | 113 |
| 114 #endif // __GNUC__ | 114 #endif // __GNUC__ |
| 115 | 115 |
| 116 #include "atomicops.h" | 116 #include "atomicops.h" |
| 117 #include "platform-tls.h" | |
| 117 #include "utils.h" | 118 #include "utils.h" |
| 118 #include "v8globals.h" | 119 #include "v8globals.h" |
| 119 | 120 |
| 120 namespace v8 { | 121 namespace v8 { |
| 121 namespace internal { | 122 namespace internal { |
| 122 | 123 |
| 123 // Use AtomicWord for a machine-sized pointer. It is assumed that | 124 // Use AtomicWord for a machine-sized pointer. It is assumed that |
| 124 // reads and writes of naturally aligned values of this type are atomic. | 125 // reads and writes of naturally aligned values of this type are atomic. |
| 125 typedef intptr_t AtomicWord; | 126 typedef intptr_t AtomicWord; |
| 126 | 127 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 return static_cast<int>(reinterpret_cast<intptr_t>(GetThreadLocal(key))); | 422 return static_cast<int>(reinterpret_cast<intptr_t>(GetThreadLocal(key))); |
| 422 } | 423 } |
| 423 static void SetThreadLocal(LocalStorageKey key, void* value); | 424 static void SetThreadLocal(LocalStorageKey key, void* value); |
| 424 static void SetThreadLocalInt(LocalStorageKey key, int value) { | 425 static void SetThreadLocalInt(LocalStorageKey key, int value) { |
| 425 SetThreadLocal(key, reinterpret_cast<void*>(static_cast<intptr_t>(value))); | 426 SetThreadLocal(key, reinterpret_cast<void*>(static_cast<intptr_t>(value))); |
| 426 } | 427 } |
| 427 static bool HasThreadLocal(LocalStorageKey key) { | 428 static bool HasThreadLocal(LocalStorageKey key) { |
| 428 return GetThreadLocal(key) != NULL; | 429 return GetThreadLocal(key) != NULL; |
| 429 } | 430 } |
| 430 | 431 |
| 432 #ifdef V8_FAST_TLS_SUPPORTED | |
| 433 static inline void* GetExistingThreadLocal(LocalStorageKey key) { | |
|
antonm
2011/03/25 16:44:44
maybe make this method a template by a return type
Vitaly Repeshko
2011/03/27 15:54:48
I'd like to avoid significant interface changes in
| |
| 434 void* result = reinterpret_cast<void*>( | |
| 435 InternalGetExistingThreadLocal(static_cast<intptr_t>(key))); | |
| 436 ASSERT(result == GetThreadLocal(key)); | |
| 437 return result; | |
| 438 } | |
| 439 #else | |
| 440 static inline void* GetExistingThreadLocal(LocalStorageKey key) { | |
| 441 return GetThreadLocal(key); | |
| 442 } | |
| 443 #endif | |
| 444 | |
| 431 // A hint to the scheduler to let another thread run. | 445 // A hint to the scheduler to let another thread run. |
| 432 static void YieldCPU(); | 446 static void YieldCPU(); |
| 433 | 447 |
| 434 Isolate* isolate() const { return isolate_; } | 448 Isolate* isolate() const { return isolate_; } |
| 435 | 449 |
| 436 // The thread name length is limited to 16 based on Linux's implementation of | 450 // The thread name length is limited to 16 based on Linux's implementation of |
| 437 // prctl(). | 451 // prctl(). |
| 438 static const int kMaxThreadNameLength = 16; | 452 static const int kMaxThreadNameLength = 16; |
| 439 private: | 453 private: |
| 440 void set_name(const char *name); | 454 void set_name(const char *name); |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 651 int samples_taken_; // Counts stack samples taken. | 665 int samples_taken_; // Counts stack samples taken. |
| 652 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 666 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
| 653 }; | 667 }; |
| 654 | 668 |
| 655 | 669 |
| 656 #endif // ENABLE_LOGGING_AND_PROFILING | 670 #endif // ENABLE_LOGGING_AND_PROFILING |
| 657 | 671 |
| 658 } } // namespace v8::internal | 672 } } // namespace v8::internal |
| 659 | 673 |
| 660 #endif // V8_PLATFORM_H_ | 674 #endif // V8_PLATFORM_H_ |
| OLD | NEW |