| 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 15 matching lines...) Expand all Loading... |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // This module contains the platform-specific code. This make the rest of the | 28 // This module contains the platform-specific code. This make the rest of the |
| 29 // code less dependent on operating system, compilers and runtime libraries. | 29 // code less dependent on operating system, compilers and runtime libraries. |
| 30 // This module does specifically not deal with differences between different | 30 // This module does specifically not deal with differences between different |
| 31 // processor architecture. | 31 // processor architecture. |
| 32 // The platform classes have the same definition for all platforms. The | 32 // The platform classes have the same definition for all platforms. The |
| 33 // implementation for a particular platform is put in platform_<os>.cc. | 33 // implementation for a particular platform is put in platform_<os>.cc. |
| 34 // The build system then uses the implementation for the target platform. | 34 // The build system then uses the implementation for the target platform. |
| 35 // | 35 // |
| 36 // This design has been choosen because it is simple and fast. Alternatively, | 36 // This design has been chosen because it is simple and fast. Alternatively, |
| 37 // the platform dependent classes could have been implemented using abstract | 37 // the platform dependent classes could have been implemented using abstract |
| 38 // superclasses with virtual methods and having specializations for each | 38 // superclasses with virtual methods and having specializations for each |
| 39 // platform. This design was rejected because it was more complicated and | 39 // platform. This design was rejected because it was more complicated and |
| 40 // slower. It would require factory methods for selecting the right | 40 // slower. It would require factory methods for selecting the right |
| 41 // implementation and the overhead of virtual methods for performance | 41 // implementation and the overhead of virtual methods for performance |
| 42 // sensitive like mutex locking/unlocking. | 42 // sensitive like mutex locking/unlocking. |
| 43 | 43 |
| 44 #ifndef V8_PLATFORM_H_ | 44 #ifndef V8_PLATFORM_H_ |
| 45 #define V8_PLATFORM_H_ | 45 #define V8_PLATFORM_H_ |
| 46 | 46 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // should go to stdout. | 138 // should go to stdout. |
| 139 static void Print(const char* format, ...); | 139 static void Print(const char* format, ...); |
| 140 static void VPrint(const char* format, va_list args); | 140 static void VPrint(const char* format, va_list args); |
| 141 | 141 |
| 142 // Print error output to console. This is mostly used for error message | 142 // Print error output to console. This is mostly used for error message |
| 143 // output. On platforms that has standard terminal output, the output | 143 // output. On platforms that has standard terminal output, the output |
| 144 // should go to stderr. | 144 // should go to stderr. |
| 145 static void PrintError(const char* format, ...); | 145 static void PrintError(const char* format, ...); |
| 146 static void VPrintError(const char* format, va_list args); | 146 static void VPrintError(const char* format, va_list args); |
| 147 | 147 |
| 148 // Allocate/Free memory used by JS heap. Pages are readable/writeable, but | 148 // Allocate/Free memory used by JS heap. Pages are readable/writable, but |
| 149 // they are not guaranteed to be executable unless 'executable' is true. | 149 // they are not guaranteed to be executable unless 'executable' is true. |
| 150 // Returns the address of allocated memory, or NULL if failed. | 150 // Returns the address of allocated memory, or NULL if failed. |
| 151 static void* Allocate(const size_t requested, | 151 static void* Allocate(const size_t requested, |
| 152 size_t* allocated, | 152 size_t* allocated, |
| 153 bool executable); | 153 bool executable); |
| 154 static void Free(void* buf, const size_t length); | 154 static void Free(void* buf, const size_t length); |
| 155 // Get the Alignment guaranteed by Allocate(). | 155 // Get the Alignment guaranteed by Allocate(). |
| 156 static size_t AllocateAlignment(); | 156 static size_t AllocateAlignment(); |
| 157 | 157 |
| 158 // Returns an indication of whether a pointer is in a space that | 158 // Returns an indication of whether a pointer is in a space that |
| 159 // has been allocated by Allocate(). This method may conservatively | 159 // has been allocated by Allocate(). This method may conservatively |
| 160 // always return false, but giving more accurate information may | 160 // always return false, but giving more accurate information may |
| 161 // improve the robustness of the stack dump code in the presence of | 161 // improve the robustness of the stack dump code in the presence of |
| 162 // heap corruption. | 162 // heap corruption. |
| 163 static bool IsOutsideAllocatedSpace(void* pointer); | 163 static bool IsOutsideAllocatedSpace(void* pointer); |
| 164 | 164 |
| 165 // Sleep for a number of miliseconds. | 165 // Sleep for a number of milliseconds. |
| 166 static void Sleep(const int miliseconds); | 166 static void Sleep(const int milliseconds); |
| 167 | 167 |
| 168 // Abort the current process. | 168 // Abort the current process. |
| 169 static void Abort(); | 169 static void Abort(); |
| 170 | 170 |
| 171 // Debug break. | 171 // Debug break. |
| 172 static void DebugBreak(); | 172 static void DebugBreak(); |
| 173 | 173 |
| 174 // Walk the stack. | 174 // Walk the stack. |
| 175 static const int kStackWalkError = -1; | 175 static const int kStackWalkError = -1; |
| 176 static const int kStackWalkMaxNameLen = 256; | 176 static const int kStackWalkMaxNameLen = 256; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 bool active_; | 440 bool active_; |
| 441 PlatformData* data_; // Platform specific data. | 441 PlatformData* data_; // Platform specific data. |
| 442 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 442 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
| 443 }; | 443 }; |
| 444 | 444 |
| 445 #endif // ENABLE_LOGGING_AND_PROFILING | 445 #endif // ENABLE_LOGGING_AND_PROFILING |
| 446 | 446 |
| 447 } } // namespace v8::internal | 447 } } // namespace v8::internal |
| 448 | 448 |
| 449 #endif // V8_PLATFORM_H_ | 449 #endif // V8_PLATFORM_H_ |
| OLD | NEW |