| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 // Returns the daylight savings offset for the given time. | 171 // Returns the daylight savings offset for the given time. |
| 172 static double DaylightSavingsOffset(double time); | 172 static double DaylightSavingsOffset(double time); |
| 173 | 173 |
| 174 // Returns last OS error. | 174 // Returns last OS error. |
| 175 static int GetLastError(); | 175 static int GetLastError(); |
| 176 | 176 |
| 177 static FILE* FOpen(const char* path, const char* mode); | 177 static FILE* FOpen(const char* path, const char* mode); |
| 178 static bool Remove(const char* path); | 178 static bool Remove(const char* path); |
| 179 | 179 |
| 180 // Opens a temporary file, the file is auto removed on close. |
| 181 static FILE* OpenTemporaryFile(); |
| 182 |
| 180 // Log file open mode is platform-dependent due to line ends issues. | 183 // Log file open mode is platform-dependent due to line ends issues. |
| 181 static const char* const LogFileOpenMode; | 184 static const char* const LogFileOpenMode; |
| 182 | 185 |
| 183 // Print output to console. This is mostly used for debugging output. | 186 // Print output to console. This is mostly used for debugging output. |
| 184 // On platforms that has standard terminal output, the output | 187 // On platforms that has standard terminal output, the output |
| 185 // should go to stdout. | 188 // should go to stdout. |
| 186 static void Print(const char* format, ...); | 189 static void Print(const char* format, ...); |
| 187 static void VPrint(const char* format, va_list args); | 190 static void VPrint(const char* format, va_list args); |
| 188 | 191 |
| 189 // Print output to a file. This is mostly used for debugging output. | 192 // Print output to a file. This is mostly used for debugging output. |
| 190 static void FPrint(FILE* out, const char* format, ...); | 193 static void FPrint(FILE* out, const char* format, ...); |
| 191 static void VFPrint(FILE* out, const char* format, va_list args); | 194 static void VFPrint(FILE* out, const char* format, va_list args); |
| 192 | 195 |
| 193 // Print error output to console. This is mostly used for error message | 196 // Print error output to console. This is mostly used for error message |
| 194 // output. On platforms that has standard terminal output, the output | 197 // output. On platforms that has standard terminal output, the output |
| 195 // should go to stderr. | 198 // should go to stderr. |
| 196 static void PrintError(const char* format, ...); | 199 static void PrintError(const char* format, ...); |
| 197 static void VPrintError(const char* format, va_list args); | 200 static void VPrintError(const char* format, va_list args); |
| 198 | 201 |
| 199 // Allocate/Free memory used by JS heap. Pages are readable/writable, but | 202 // Allocate/Free memory used by JS heap. Pages are readable/writable, but |
| 200 // they are not guaranteed to be executable unless 'executable' is true. | 203 // they are not guaranteed to be executable unless 'executable' is true. |
| 201 // Returns the address of allocated memory, or NULL if failed. | 204 // Returns the address of allocated memory, or NULL if failed. |
| 202 static void* Allocate(const size_t requested, | 205 static void* Allocate(const size_t requested, |
| 203 size_t* allocated, | 206 size_t* allocated, |
| 204 bool is_executable); | 207 bool is_executable); |
| 205 static void Free(void* address, const size_t size); | 208 static void Free(void* address, const size_t size); |
| 206 // Get the Alignment guaranteed by Allocate(). | 209 // Get the Alignment guaranteed by Allocate(). |
| 207 static size_t AllocateAlignment(); | 210 static size_t AllocateAlignment(); |
| 208 | 211 |
| 209 #ifdef ENABLE_HEAP_PROTECTION | |
| 210 // Protect/unprotect a block of memory by marking it read-only/writable. | |
| 211 static void Protect(void* address, size_t size); | |
| 212 static void Unprotect(void* address, size_t size, bool is_executable); | |
| 213 #endif | |
| 214 | |
| 215 // Returns an indication of whether a pointer is in a space that | 212 // Returns an indication of whether a pointer is in a space that |
| 216 // has been allocated by Allocate(). This method may conservatively | 213 // has been allocated by Allocate(). This method may conservatively |
| 217 // always return false, but giving more accurate information may | 214 // always return false, but giving more accurate information may |
| 218 // improve the robustness of the stack dump code in the presence of | 215 // improve the robustness of the stack dump code in the presence of |
| 219 // heap corruption. | 216 // heap corruption. |
| 220 static bool IsOutsideAllocatedSpace(void* pointer); | 217 static bool IsOutsideAllocatedSpace(void* pointer); |
| 221 | 218 |
| 222 // Sleep for a number of milliseconds. | 219 // Sleep for a number of milliseconds. |
| 223 static void Sleep(const int milliseconds); | 220 static void Sleep(const int milliseconds); |
| 224 | 221 |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 union { | 593 union { |
| 597 Address tos; // Top stack value (*sp). | 594 Address tos; // Top stack value (*sp). |
| 598 Address external_callback; | 595 Address external_callback; |
| 599 }; | 596 }; |
| 600 static const int kMaxFramesCount = 64; | 597 static const int kMaxFramesCount = 64; |
| 601 Address stack[kMaxFramesCount]; // Call stack. | 598 Address stack[kMaxFramesCount]; // Call stack. |
| 602 int frames_count : 8; // Number of captured frames. | 599 int frames_count : 8; // Number of captured frames. |
| 603 bool has_external_callback : 1; | 600 bool has_external_callback : 1; |
| 604 }; | 601 }; |
| 605 | 602 |
| 606 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 607 class Sampler { | 603 class Sampler { |
| 608 public: | 604 public: |
| 609 // Initialize sampler. | 605 // Initialize sampler. |
| 610 Sampler(Isolate* isolate, int interval); | 606 Sampler(Isolate* isolate, int interval); |
| 611 virtual ~Sampler(); | 607 virtual ~Sampler(); |
| 612 | 608 |
| 613 int interval() const { return interval_; } | 609 int interval() const { return interval_; } |
| 614 | 610 |
| 615 // Performs stack sampling. | 611 // Performs stack sampling. |
| 616 void SampleStack(TickSample* sample) { | 612 void SampleStack(TickSample* sample) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 Isolate* isolate_; | 651 Isolate* isolate_; |
| 656 const int interval_; | 652 const int interval_; |
| 657 Atomic32 profiling_; | 653 Atomic32 profiling_; |
| 658 Atomic32 active_; | 654 Atomic32 active_; |
| 659 PlatformData* data_; // Platform specific data. | 655 PlatformData* data_; // Platform specific data. |
| 660 int samples_taken_; // Counts stack samples taken. | 656 int samples_taken_; // Counts stack samples taken. |
| 661 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 657 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
| 662 }; | 658 }; |
| 663 | 659 |
| 664 | 660 |
| 665 #endif // ENABLE_LOGGING_AND_PROFILING | |
| 666 | |
| 667 } } // namespace v8::internal | 661 } } // namespace v8::internal |
| 668 | 662 |
| 669 #endif // V8_PLATFORM_H_ | 663 #endif // V8_PLATFORM_H_ |
| OLD | NEW |