OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are |
| 4 // met: |
| 5 // |
| 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. |
| 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
| 28 #ifndef V8_PERF_JIT_H_ |
| 29 #define V8_PERF_JIT_H_ |
| 30 |
| 31 #include "src/log.h" |
| 32 |
| 33 namespace v8 { |
| 34 namespace internal { |
| 35 |
| 36 #if V8_OS_LINUX |
| 37 |
| 38 // Linux perf tool logging support |
| 39 class PerfJitLogger : public CodeEventLogger { |
| 40 public: |
| 41 PerfJitLogger(); |
| 42 virtual ~PerfJitLogger(); |
| 43 |
| 44 void CodeMoveEvent(AbstractCode* from, Address to) override; |
| 45 void CodeDisableOptEvent(AbstractCode* code, |
| 46 SharedFunctionInfo* shared) override {} |
| 47 virtual void SnapshotPositionEvent(Address addr, int pos); |
| 48 |
| 49 private: |
| 50 void OpenJitDumpFile(); |
| 51 void CloseJitDumpFile(); |
| 52 void* OpenMarkerFile(int fd); |
| 53 void CloseMarkerFile(void* marker_address); |
| 54 |
| 55 uint64_t GetTimestamp(); |
| 56 void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared, |
| 57 const char* name, int length) override; |
| 58 |
| 59 // Extension added to V8 log file name to get the low-level log name. |
| 60 static const char kFilenameFormatString[]; |
| 61 static const int kFilenameBufferPadding; |
| 62 |
| 63 // File buffer size of the low-level log. We don't use the default to |
| 64 // minimize the associated overhead. |
| 65 static const int kLogBufferSize = 2 * MB; |
| 66 |
| 67 void LogWriteBytes(const char* bytes, int size); |
| 68 void LogWriteHeader(); |
| 69 void LogWriteDebugInfo(Code* code, SharedFunctionInfo* shared); |
| 70 |
| 71 static const uint32_t kElfMachIA32 = 3; |
| 72 static const uint32_t kElfMachX64 = 62; |
| 73 static const uint32_t kElfMachARM = 40; |
| 74 static const uint32_t kElfMachMIPS = 10; |
| 75 |
| 76 uint32_t GetElfMach() { |
| 77 #if V8_TARGET_ARCH_IA32 |
| 78 return kElfMachIA32; |
| 79 #elif V8_TARGET_ARCH_X64 |
| 80 return kElfMachX64; |
| 81 #elif V8_TARGET_ARCH_ARM |
| 82 return kElfMachARM; |
| 83 #elif V8_TARGET_ARCH_MIPS |
| 84 return kElfMachMIPS; |
| 85 #else |
| 86 UNIMPLEMENTED(); |
| 87 return 0; |
| 88 #endif |
| 89 } |
| 90 |
| 91 FILE* perf_output_handle_; |
| 92 uint64_t code_index_; |
| 93 void* marker_address_; |
| 94 }; |
| 95 |
| 96 #else |
| 97 |
| 98 // PerfJitLogger is only implemented on Linux |
| 99 class PerfJitLogger : public CodeEventLogger { |
| 100 public: |
| 101 void CodeMoveEvent(AbstractCode* from, Address to) override { |
| 102 UNIMPLEMENTED(); |
| 103 } |
| 104 |
| 105 virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) { |
| 106 UNIMPLEMENTED(); |
| 107 } |
| 108 |
| 109 virtual void SnapshotPositionEvent(Address addr, int pos) { UNIMPLEMENTED(); } |
| 110 |
| 111 virtual void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared, |
| 112 const char* name, int length) { |
| 113 UNIMPLEMENTED(); |
| 114 } |
| 115 }; |
| 116 |
| 117 #endif // V8_OS_LINUX |
| 118 } // namespace internal |
| 119 } // namespace v8 |
| 120 #endif |
OLD | NEW |