OLD | NEW |
| (Empty) |
1 // Copyright 2014 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/v8.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 virtual void CodeMoveEvent(Address from, Address to); | |
45 virtual void CodeDeleteEvent(Address from); | |
46 virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) {} | |
47 virtual void SnapshotPositionEvent(Address addr, int pos); | |
48 | |
49 private: | |
50 uint64_t GetTimestamp(); | |
51 virtual void LogRecordedBuffer(Code* code, SharedFunctionInfo* shared, | |
52 const char* name, int length); | |
53 | |
54 // Extension added to V8 log file name to get the low-level log name. | |
55 static const char kFilenameFormatString[]; | |
56 static const int kFilenameBufferPadding; | |
57 | |
58 // File buffer size of the low-level log. We don't use the default to | |
59 // minimize the associated overhead. | |
60 static const int kLogBufferSize = 2 * MB; | |
61 | |
62 void LogWriteBytes(const char* bytes, int size); | |
63 void LogWriteHeader(); | |
64 | |
65 static const uint32_t kElfMachIA32 = 3; | |
66 static const uint32_t kElfMachX64 = 62; | |
67 static const uint32_t kElfMachARM = 40; | |
68 static const uint32_t kElfMachMIPS = 10; | |
69 | |
70 uint32_t GetElfMach() { | |
71 #if V8_TARGET_ARCH_IA32 | |
72 return kElfMachIA32; | |
73 #elif V8_TARGET_ARCH_X64 | |
74 return kElfMachX64; | |
75 #elif V8_TARGET_ARCH_ARM | |
76 return kElfMachARM; | |
77 #elif V8_TARGET_ARCH_MIPS | |
78 return kElfMachMIPS; | |
79 #else | |
80 UNIMPLEMENTED(); | |
81 return 0; | |
82 #endif | |
83 } | |
84 | |
85 FILE* perf_output_handle_; | |
86 uint64_t code_index_; | |
87 }; | |
88 | |
89 #else | |
90 | |
91 // PerfJitLogger is only implemented on Linux | |
92 class PerfJitLogger : public CodeEventLogger { | |
93 public: | |
94 virtual void CodeMoveEvent(Address from, Address to) { UNIMPLEMENTED(); } | |
95 | |
96 virtual void CodeDeleteEvent(Address from) { UNIMPLEMENTED(); } | |
97 | |
98 virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) { | |
99 UNIMPLEMENTED(); | |
100 } | |
101 | |
102 virtual void SnapshotPositionEvent(Address addr, int pos) { UNIMPLEMENTED(); } | |
103 | |
104 virtual void LogRecordedBuffer(Code* code, SharedFunctionInfo* shared, | |
105 const char* name, int length) { | |
106 UNIMPLEMENTED(); | |
107 } | |
108 }; | |
109 | |
110 #endif // V8_OS_LINUX | |
111 } | |
112 } // namespace v8::internal | |
113 #endif | |
OLD | NEW |