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 10 matching lines...) Expand all Loading... |
21 #ifndef V8_PLATFORM_H_ | 21 #ifndef V8_PLATFORM_H_ |
22 #define V8_PLATFORM_H_ | 22 #define V8_PLATFORM_H_ |
23 | 23 |
24 #include <stdarg.h> | 24 #include <stdarg.h> |
25 #include <string> | 25 #include <string> |
26 #include <vector> | 26 #include <vector> |
27 | 27 |
28 #include "src/base/build_config.h" | 28 #include "src/base/build_config.h" |
29 #include "src/platform/mutex.h" | 29 #include "src/platform/mutex.h" |
30 #include "src/platform/semaphore.h" | 30 #include "src/platform/semaphore.h" |
31 #include "src/vector.h" | |
32 | 31 |
33 #ifdef __sun | 32 #ifdef __sun |
34 # ifndef signbit | 33 # ifndef signbit |
35 namespace std { | 34 namespace std { |
36 int signbit(double x); | 35 int signbit(double x); |
37 } | 36 } |
38 # endif | 37 # endif |
39 #endif | 38 #endif |
40 | 39 |
41 #if V8_OS_QNX | 40 #if V8_OS_QNX |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 83 |
85 #define V8_FAST_TLS_SUPPORTED 1 | 84 #define V8_FAST_TLS_SUPPORTED 1 |
86 | 85 |
87 INLINE(intptr_t InternalGetExistingThreadLocal(intptr_t index)); | 86 INLINE(intptr_t InternalGetExistingThreadLocal(intptr_t index)); |
88 | 87 |
89 inline intptr_t InternalGetExistingThreadLocal(intptr_t index) { | 88 inline intptr_t InternalGetExistingThreadLocal(intptr_t index) { |
90 const intptr_t kTibInlineTlsOffset = 0xE10; | 89 const intptr_t kTibInlineTlsOffset = 0xE10; |
91 const intptr_t kTibExtraTlsOffset = 0xF94; | 90 const intptr_t kTibExtraTlsOffset = 0xF94; |
92 const intptr_t kMaxInlineSlots = 64; | 91 const intptr_t kMaxInlineSlots = 64; |
93 const intptr_t kMaxSlots = kMaxInlineSlots + 1024; | 92 const intptr_t kMaxSlots = kMaxInlineSlots + 1024; |
| 93 const intptr_t kPointerSize = sizeof(void*); |
94 ASSERT(0 <= index && index < kMaxSlots); | 94 ASSERT(0 <= index && index < kMaxSlots); |
95 if (index < kMaxInlineSlots) { | 95 if (index < kMaxInlineSlots) { |
96 return static_cast<intptr_t>(__readfsdword(kTibInlineTlsOffset + | 96 return static_cast<intptr_t>(__readfsdword(kTibInlineTlsOffset + |
97 kPointerSize * index)); | 97 kPointerSize * index)); |
98 } | 98 } |
99 intptr_t extra = static_cast<intptr_t>(__readfsdword(kTibExtraTlsOffset)); | 99 intptr_t extra = static_cast<intptr_t>(__readfsdword(kTibExtraTlsOffset)); |
100 ASSERT(extra != 0); | 100 ASSERT(extra != 0); |
101 return *reinterpret_cast<intptr_t*>(extra + | 101 return *reinterpret_cast<intptr_t*>(extra + |
102 kPointerSize * (index - kMaxInlineSlots)); | 102 kPointerSize * (index - kMaxInlineSlots)); |
103 } | 103 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 public: | 240 public: |
241 static MemoryMappedFile* open(const char* name); | 241 static MemoryMappedFile* open(const char* name); |
242 static MemoryMappedFile* create(const char* name, int size, void* initial); | 242 static MemoryMappedFile* create(const char* name, int size, void* initial); |
243 virtual ~MemoryMappedFile() { } | 243 virtual ~MemoryMappedFile() { } |
244 virtual void* memory() = 0; | 244 virtual void* memory() = 0; |
245 virtual int size() = 0; | 245 virtual int size() = 0; |
246 }; | 246 }; |
247 | 247 |
248 // Safe formatting print. Ensures that str is always null-terminated. | 248 // Safe formatting print. Ensures that str is always null-terminated. |
249 // Returns the number of chars written, or -1 if output was truncated. | 249 // Returns the number of chars written, or -1 if output was truncated. |
250 static int SNPrintF(Vector<char> str, const char* format, ...); | 250 static int SNPrintF(char* str, int length, const char* format, ...); |
251 static int VSNPrintF(Vector<char> str, | 251 static int VSNPrintF(char* str, |
| 252 int length, |
252 const char* format, | 253 const char* format, |
253 va_list args); | 254 va_list args); |
254 | 255 |
255 static char* StrChr(char* str, int c); | 256 static char* StrChr(char* str, int c); |
256 static void StrNCpy(Vector<char> dest, const char* src, size_t n); | 257 static void StrNCpy(char* dest, int length, const char* src, size_t n); |
257 | 258 |
258 // Support for the profiler. Can do nothing, in which case ticks | 259 // Support for the profiler. Can do nothing, in which case ticks |
259 // occuring in shared libraries will not be properly accounted for. | 260 // occuring in shared libraries will not be properly accounted for. |
260 struct SharedLibraryAddress { | 261 struct SharedLibraryAddress { |
261 SharedLibraryAddress( | 262 SharedLibraryAddress( |
262 const std::string& library_path, uintptr_t start, uintptr_t end) | 263 const std::string& library_path, uintptr_t start, uintptr_t end) |
263 : library_path(library_path), start(start), end(end) {} | 264 : library_path(library_path), start(start), end(end) {} |
264 | 265 |
265 std::string library_path; | 266 std::string library_path; |
266 uintptr_t start; | 267 uintptr_t start; |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 // Thread | 402 // Thread |
402 // | 403 // |
403 // Thread objects are used for creating and running threads. When the start() | 404 // Thread objects are used for creating and running threads. When the start() |
404 // method is called the new thread starts running the run() method in the new | 405 // method is called the new thread starts running the run() method in the new |
405 // thread. The Thread object should not be deallocated before the thread has | 406 // thread. The Thread object should not be deallocated before the thread has |
406 // terminated. | 407 // terminated. |
407 | 408 |
408 class Thread { | 409 class Thread { |
409 public: | 410 public: |
410 // Opaque data type for thread-local storage keys. | 411 // Opaque data type for thread-local storage keys. |
411 // LOCAL_STORAGE_KEY_MIN_VALUE and LOCAL_STORAGE_KEY_MAX_VALUE are specified | 412 typedef int32_t LocalStorageKey; |
412 // to ensure that enumeration type has correct value range (see Issue 830 for | |
413 // more details). | |
414 enum LocalStorageKey { | |
415 LOCAL_STORAGE_KEY_MIN_VALUE = kMinInt, | |
416 LOCAL_STORAGE_KEY_MAX_VALUE = kMaxInt | |
417 }; | |
418 | 413 |
419 class Options { | 414 class Options { |
420 public: | 415 public: |
421 Options() : name_("v8:<unknown>"), stack_size_(0) {} | 416 Options() : name_("v8:<unknown>"), stack_size_(0) {} |
422 Options(const char* name, int stack_size = 0) | 417 Options(const char* name, int stack_size = 0) |
423 : name_(name), stack_size_(stack_size) {} | 418 : name_(name), stack_size_(stack_size) {} |
424 | 419 |
425 const char* name() const { return name_; } | 420 const char* name() const { return name_; } |
426 int stack_size() const { return stack_size_; } | 421 int stack_size() const { return stack_size_; } |
427 | 422 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 char name_[kMaxThreadNameLength]; | 503 char name_[kMaxThreadNameLength]; |
509 int stack_size_; | 504 int stack_size_; |
510 Semaphore* start_semaphore_; | 505 Semaphore* start_semaphore_; |
511 | 506 |
512 DISALLOW_COPY_AND_ASSIGN(Thread); | 507 DISALLOW_COPY_AND_ASSIGN(Thread); |
513 }; | 508 }; |
514 | 509 |
515 } } // namespace v8::internal | 510 } } // namespace v8::internal |
516 | 511 |
517 #endif // V8_PLATFORM_H_ | 512 #endif // V8_PLATFORM_H_ |
OLD | NEW |