| 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); |
| 209 |
| 210 // Assign memory as a guard page so that access will cause an exception. |
| 211 static void Guard(void* address, const size_t size); |
| 212 |
| 206 // Get the Alignment guaranteed by Allocate(). | 213 // Get the Alignment guaranteed by Allocate(). |
| 207 static size_t AllocateAlignment(); | 214 static size_t AllocateAlignment(); |
| 208 | 215 |
| 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 | 216 // Returns an indication of whether a pointer is in a space that |
| 216 // has been allocated by Allocate(). This method may conservatively | 217 // has been allocated by Allocate(). This method may conservatively |
| 217 // always return false, but giving more accurate information may | 218 // always return false, but giving more accurate information may |
| 218 // improve the robustness of the stack dump code in the presence of | 219 // improve the robustness of the stack dump code in the presence of |
| 219 // heap corruption. | 220 // heap corruption. |
| 220 static bool IsOutsideAllocatedSpace(void* pointer); | 221 static bool IsOutsideAllocatedSpace(void* pointer); |
| 221 | 222 |
| 222 // Sleep for a number of milliseconds. | 223 // Sleep for a number of milliseconds. |
| 223 static void Sleep(const int milliseconds); | 224 static void Sleep(const int milliseconds); |
| 224 | 225 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 union { | 606 union { |
| 606 Address tos; // Top stack value (*sp). | 607 Address tos; // Top stack value (*sp). |
| 607 Address external_callback; | 608 Address external_callback; |
| 608 }; | 609 }; |
| 609 static const int kMaxFramesCount = 64; | 610 static const int kMaxFramesCount = 64; |
| 610 Address stack[kMaxFramesCount]; // Call stack. | 611 Address stack[kMaxFramesCount]; // Call stack. |
| 611 int frames_count : 8; // Number of captured frames. | 612 int frames_count : 8; // Number of captured frames. |
| 612 bool has_external_callback : 1; | 613 bool has_external_callback : 1; |
| 613 }; | 614 }; |
| 614 | 615 |
| 615 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 616 class Sampler { | 616 class Sampler { |
| 617 public: | 617 public: |
| 618 // Initialize sampler. | 618 // Initialize sampler. |
| 619 Sampler(Isolate* isolate, int interval); | 619 Sampler(Isolate* isolate, int interval); |
| 620 virtual ~Sampler(); | 620 virtual ~Sampler(); |
| 621 | 621 |
| 622 int interval() const { return interval_; } | 622 int interval() const { return interval_; } |
| 623 | 623 |
| 624 // Performs stack sampling. | 624 // Performs stack sampling. |
| 625 void SampleStack(TickSample* sample) { | 625 void SampleStack(TickSample* sample) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 Isolate* isolate_; | 664 Isolate* isolate_; |
| 665 const int interval_; | 665 const int interval_; |
| 666 Atomic32 profiling_; | 666 Atomic32 profiling_; |
| 667 Atomic32 active_; | 667 Atomic32 active_; |
| 668 PlatformData* data_; // Platform specific data. | 668 PlatformData* data_; // Platform specific data. |
| 669 int samples_taken_; // Counts stack samples taken. | 669 int samples_taken_; // Counts stack samples taken. |
| 670 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 670 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
| 671 }; | 671 }; |
| 672 | 672 |
| 673 | 673 |
| 674 #endif // ENABLE_LOGGING_AND_PROFILING | |
| 675 | |
| 676 } } // namespace v8::internal | 674 } } // namespace v8::internal |
| 677 | 675 |
| 678 #endif // V8_PLATFORM_H_ | 676 #endif // V8_PLATFORM_H_ |
| OLD | NEW |