| 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. |
| 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_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 | 25 |
| 26 #include "src/base/build_config.h" |
| 26 #include "src/platform/mutex.h" | 27 #include "src/platform/mutex.h" |
| 27 #include "src/platform/semaphore.h" | 28 #include "src/platform/semaphore.h" |
| 28 #include "src/globals.h" | |
| 29 #include "src/vector.h" | 29 #include "src/vector.h" |
| 30 | 30 |
| 31 #ifdef __sun | 31 #ifdef __sun |
| 32 # ifndef signbit | 32 # ifndef signbit |
| 33 namespace std { | 33 namespace std { |
| 34 int signbit(double x); | 34 int signbit(double x); |
| 35 } | 35 } |
| 36 # endif | 36 # endif |
| 37 #endif | 37 #endif |
| 38 | 38 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // Support for the profiler. Can do nothing, in which case ticks | 256 // Support for the profiler. Can do nothing, in which case ticks |
| 257 // occuring in shared libraries will not be properly accounted for. | 257 // occuring in shared libraries will not be properly accounted for. |
| 258 static void LogSharedLibraryAddresses(Isolate* isolate); | 258 static void LogSharedLibraryAddresses(Isolate* isolate); |
| 259 | 259 |
| 260 // Support for the profiler. Notifies the external profiling | 260 // Support for the profiler. Notifies the external profiling |
| 261 // process that a code moving garbage collection starts. Can do | 261 // process that a code moving garbage collection starts. Can do |
| 262 // nothing, in which case the code objects must not move (e.g., by | 262 // nothing, in which case the code objects must not move (e.g., by |
| 263 // using --never-compact) if accurate profiling is desired. | 263 // using --never-compact) if accurate profiling is desired. |
| 264 static void SignalCodeMovingGC(); | 264 static void SignalCodeMovingGC(); |
| 265 | 265 |
| 266 // The return value indicates the CPU features we are sure of because of the | |
| 267 // OS. | |
| 268 // This is a little messy because the interpretation is subject to the cross | |
| 269 // of the CPU and the OS. The bits in the answer correspond to the bit | |
| 270 // positions indicated by the members of the CpuFeature enum from globals.h | |
| 271 static unsigned CpuFeaturesImpliedByPlatform(); | |
| 272 | |
| 273 // Returns the number of processors online. | 266 // Returns the number of processors online. |
| 274 static int NumberOfProcessorsOnline(); | 267 static int NumberOfProcessorsOnline(); |
| 275 | 268 |
| 276 // The total amount of physical memory available on the current system. | 269 // The total amount of physical memory available on the current system. |
| 277 static uint64_t TotalPhysicalMemory(); | 270 static uint64_t TotalPhysicalMemory(); |
| 278 | 271 |
| 279 // Maximum size of the virtual memory. 0 means there is no artificial | 272 // Maximum size of the virtual memory. 0 means there is no artificial |
| 280 // limit. | 273 // limit. |
| 281 static intptr_t MaxVirtualMemory(); | 274 static intptr_t MaxVirtualMemory(); |
| 282 | 275 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 char name_[kMaxThreadNameLength]; | 496 char name_[kMaxThreadNameLength]; |
| 504 int stack_size_; | 497 int stack_size_; |
| 505 Semaphore* start_semaphore_; | 498 Semaphore* start_semaphore_; |
| 506 | 499 |
| 507 DISALLOW_COPY_AND_ASSIGN(Thread); | 500 DISALLOW_COPY_AND_ASSIGN(Thread); |
| 508 }; | 501 }; |
| 509 | 502 |
| 510 } } // namespace v8::internal | 503 } } // namespace v8::internal |
| 511 | 504 |
| 512 #endif // V8_PLATFORM_H_ | 505 #endif // V8_PLATFORM_H_ |
| OLD | NEW |