Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1344)

Side by Side Diff: src/base/platform/platform.h

Issue 2396933002: Revert of Reland "Turn libbase into a component" (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/base/platform/mutex.h ('k') | src/base/platform/semaphore.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.
11 // The build system then uses the implementation for the target platform. 11 // The build system then uses the implementation for the target platform.
12 // 12 //
13 // This design has been chosen because it is simple and fast. Alternatively, 13 // This design has been chosen because it is simple and fast. Alternatively,
14 // the platform dependent classes could have been implemented using abstract 14 // the platform dependent classes could have been implemented using abstract
15 // superclasses with virtual methods and having specializations for each 15 // superclasses with virtual methods and having specializations for each
16 // platform. This design was rejected because it was more complicated and 16 // platform. This design was rejected because it was more complicated and
17 // slower. It would require factory methods for selecting the right 17 // slower. It would require factory methods for selecting the right
18 // implementation and the overhead of virtual methods for performance 18 // implementation and the overhead of virtual methods for performance
19 // sensitive like mutex locking/unlocking. 19 // sensitive like mutex locking/unlocking.
20 20
21 #ifndef V8_BASE_PLATFORM_PLATFORM_H_ 21 #ifndef V8_BASE_PLATFORM_PLATFORM_H_
22 #define V8_BASE_PLATFORM_PLATFORM_H_ 22 #define V8_BASE_PLATFORM_PLATFORM_H_
23 23
24 #include <cstdarg> 24 #include <cstdarg>
25 #include <string> 25 #include <string>
26 #include <vector> 26 #include <vector>
27 27
28 #include "src/base/base-export.h"
29 #include "src/base/build_config.h" 28 #include "src/base/build_config.h"
30 #include "src/base/compiler-specific.h" 29 #include "src/base/compiler-specific.h"
31 #include "src/base/platform/mutex.h" 30 #include "src/base/platform/mutex.h"
32 #include "src/base/platform/semaphore.h" 31 #include "src/base/platform/semaphore.h"
33 32
34 #if V8_OS_QNX 33 #if V8_OS_QNX
35 #include "src/base/qnx-math.h" 34 #include "src/base/qnx-math.h"
36 #endif 35 #endif
37 36
38 namespace v8 { 37 namespace v8 {
(...skipping 24 matching lines...) Expand all
63 intptr_t extra = static_cast<intptr_t>(__readfsdword(kTibExtraTlsOffset)); 62 intptr_t extra = static_cast<intptr_t>(__readfsdword(kTibExtraTlsOffset));
64 DCHECK(extra != 0); 63 DCHECK(extra != 0);
65 return *reinterpret_cast<intptr_t*>(extra + 64 return *reinterpret_cast<intptr_t*>(extra +
66 kPointerSize * (index - kMaxInlineSlots)); 65 kPointerSize * (index - kMaxInlineSlots));
67 } 66 }
68 67
69 #elif defined(__APPLE__) && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64) 68 #elif defined(__APPLE__) && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64)
70 69
71 #define V8_FAST_TLS_SUPPORTED 1 70 #define V8_FAST_TLS_SUPPORTED 1
72 71
73 extern V8_BASE_EXPORT intptr_t kMacTlsBaseOffset; 72 extern intptr_t kMacTlsBaseOffset;
74 73
75 INLINE(intptr_t InternalGetExistingThreadLocal(intptr_t index)); 74 INLINE(intptr_t InternalGetExistingThreadLocal(intptr_t index));
76 75
77 inline intptr_t InternalGetExistingThreadLocal(intptr_t index) { 76 inline intptr_t InternalGetExistingThreadLocal(intptr_t index) {
78 intptr_t result; 77 intptr_t result;
79 #if V8_HOST_ARCH_IA32 78 #if V8_HOST_ARCH_IA32
80 asm("movl %%gs:(%1,%2,4), %0;" 79 asm("movl %%gs:(%1,%2,4), %0;"
81 :"=r"(result) // Output must be a writable register. 80 :"=r"(result) // Output must be a writable register.
82 :"r"(kMacTlsBaseOffset), "r"(index)); 81 :"r"(kMacTlsBaseOffset), "r"(index));
83 #else 82 #else
(...skipping 12 matching lines...) Expand all
96 class TimezoneCache; 95 class TimezoneCache;
97 96
98 97
99 // ---------------------------------------------------------------------------- 98 // ----------------------------------------------------------------------------
100 // OS 99 // OS
101 // 100 //
102 // This class has static methods for the different platform specific 101 // This class has static methods for the different platform specific
103 // functions. Add methods here to cope with differences between the 102 // functions. Add methods here to cope with differences between the
104 // supported platforms. 103 // supported platforms.
105 104
106 class V8_BASE_EXPORT OS { 105 class OS {
107 public: 106 public:
108 // Initialize the OS class. 107 // Initialize the OS class.
109 // - random_seed: Used for the GetRandomMmapAddress() if non-zero. 108 // - random_seed: Used for the GetRandomMmapAddress() if non-zero.
110 // - hard_abort: If true, OS::Abort() will crash instead of aborting. 109 // - hard_abort: If true, OS::Abort() will crash instead of aborting.
111 // - gc_fake_mmap: Name of the file for fake gc mmap used in ll_prof. 110 // - gc_fake_mmap: Name of the file for fake gc mmap used in ll_prof.
112 static void Initialize(int64_t random_seed, 111 static void Initialize(int64_t random_seed,
113 bool hard_abort, 112 bool hard_abort,
114 const char* const gc_fake_mmap); 113 const char* const gc_fake_mmap);
115 114
116 // Returns the accumulated user time for thread. This routine 115 // Returns the accumulated user time for thread. This routine
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 204
206 // Walk the stack. 205 // Walk the stack.
207 static const int kStackWalkError = -1; 206 static const int kStackWalkError = -1;
208 static const int kStackWalkMaxNameLen = 256; 207 static const int kStackWalkMaxNameLen = 256;
209 static const int kStackWalkMaxTextLen = 256; 208 static const int kStackWalkMaxTextLen = 256;
210 struct StackFrame { 209 struct StackFrame {
211 void* address; 210 void* address;
212 char text[kStackWalkMaxTextLen]; 211 char text[kStackWalkMaxTextLen];
213 }; 212 };
214 213
215 class V8_BASE_EXPORT MemoryMappedFile { 214 class MemoryMappedFile {
216 public: 215 public:
217 virtual ~MemoryMappedFile() {} 216 virtual ~MemoryMappedFile() {}
218 virtual void* memory() const = 0; 217 virtual void* memory() const = 0;
219 virtual size_t size() const = 0; 218 virtual size_t size() const = 0;
220 219
221 static MemoryMappedFile* open(const char* name); 220 static MemoryMappedFile* open(const char* name);
222 static MemoryMappedFile* create(const char* name, size_t size, 221 static MemoryMappedFile* create(const char* name, size_t size,
223 void* initial); 222 void* initial);
224 }; 223 };
225 224
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 #endif 279 #endif
281 280
282 DISALLOW_IMPLICIT_CONSTRUCTORS(OS); 281 DISALLOW_IMPLICIT_CONSTRUCTORS(OS);
283 }; 282 };
284 283
285 284
286 // Represents and controls an area of reserved memory. 285 // Represents and controls an area of reserved memory.
287 // Control of the reserved memory can be assigned to another VirtualMemory 286 // Control of the reserved memory can be assigned to another VirtualMemory
288 // object by assignment or copy-contructing. This removes the reserved memory 287 // object by assignment or copy-contructing. This removes the reserved memory
289 // from the original object. 288 // from the original object.
290 class V8_BASE_EXPORT VirtualMemory { 289 class VirtualMemory {
291 public: 290 public:
292 // Empty VirtualMemory object, controlling no reserved memory. 291 // Empty VirtualMemory object, controlling no reserved memory.
293 VirtualMemory(); 292 VirtualMemory();
294 293
295 // Reserves virtual memory with size. 294 // Reserves virtual memory with size.
296 explicit VirtualMemory(size_t size); 295 explicit VirtualMemory(size_t size);
297 296
298 // Reserves virtual memory containing an area of the given size that 297 // Reserves virtual memory containing an area of the given size that
299 // is aligned per alignment. This may not be at the position returned 298 // is aligned per alignment. This may not be at the position returned
300 // by address(). 299 // by address().
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 411
413 412
414 // ---------------------------------------------------------------------------- 413 // ----------------------------------------------------------------------------
415 // Thread 414 // Thread
416 // 415 //
417 // Thread objects are used for creating and running threads. When the start() 416 // Thread objects are used for creating and running threads. When the start()
418 // method is called the new thread starts running the run() method in the new 417 // method is called the new thread starts running the run() method in the new
419 // thread. The Thread object should not be deallocated before the thread has 418 // thread. The Thread object should not be deallocated before the thread has
420 // terminated. 419 // terminated.
421 420
422 class V8_BASE_EXPORT Thread { 421 class Thread {
423 public: 422 public:
424 // Opaque data type for thread-local storage keys. 423 // Opaque data type for thread-local storage keys.
425 typedef int32_t LocalStorageKey; 424 typedef int32_t LocalStorageKey;
426 425
427 class Options { 426 class Options {
428 public: 427 public:
429 Options() : name_("v8:<unknown>"), stack_size_(0) {} 428 Options() : name_("v8:<unknown>"), stack_size_(0) {}
430 explicit Options(const char* name, int stack_size = 0) 429 explicit Options(const char* name, int stack_size = 0)
431 : name_(name), stack_size_(stack_size) {} 430 : name_(name), stack_size_(stack_size) {}
432 431
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 int stack_size_; 512 int stack_size_;
514 Semaphore* start_semaphore_; 513 Semaphore* start_semaphore_;
515 514
516 DISALLOW_COPY_AND_ASSIGN(Thread); 515 DISALLOW_COPY_AND_ASSIGN(Thread);
517 }; 516 };
518 517
519 } // namespace base 518 } // namespace base
520 } // namespace v8 519 } // namespace v8
521 520
522 #endif // V8_BASE_PLATFORM_PLATFORM_H_ 521 #endif // V8_BASE_PLATFORM_PLATFORM_H_
OLDNEW
« no previous file with comments | « src/base/platform/mutex.h ('k') | src/base/platform/semaphore.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698