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
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.
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.
28 #ifndef V8_PERF_JIT_H_
29 #define V8_PERF_JIT_H_
36 // TODO(jarin) For now, we disable perf integration on Android because of a
37 // build problem - when building the snapshot with AOSP, librt is not
38 // available, so we cannot use the clock_gettime function. To fix this, we
39 // should thread through the V8_LIBRT_NOT_AVAILABLE flag here and only disable
40 // the perf integration when this flag is present (the perf integration is not
41 // needed when generating snapshot, so it is fine to ifdef it away).
45 // Linux perf tool logging support
46 class PerfJitLogger : public CodeEventLogger {
49 virtual ~PerfJitLogger();
51 virtual void CodeMoveEvent(Address from, Address to);
52 virtual void CodeDeleteEvent(Address from);
53 virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) {}
54 virtual void SnapshotPositionEvent(Address addr, int pos);
57 uint64_t GetTimestamp();
58 virtual void LogRecordedBuffer(Code* code, SharedFunctionInfo* shared,
59 const char* name, int length);
61 // Extension added to V8 log file name to get the low-level log name.
62 static const char kFilenameFormatString[];
63 static const int kFilenameBufferPadding;
65 // File buffer size of the low-level log. We don't use the default to
66 // minimize the associated overhead.
67 static const int kLogBufferSize = 2 * MB;
69 void LogWriteBytes(const char* bytes, int size);
70 void LogWriteHeader();
72 static const uint32_t kElfMachIA32 = 3;
73 static const uint32_t kElfMachX64 = 62;
74 static const uint32_t kElfMachARM = 40;
75 static const uint32_t kElfMachMIPS = 10;
77 uint32_t GetElfMach() {
78 #if V8_TARGET_ARCH_IA32
80 #elif V8_TARGET_ARCH_X64
82 #elif V8_TARGET_ARCH_ARM
84 #elif V8_TARGET_ARCH_MIPS
92 FILE* perf_output_handle_;
98 // PerfJitLogger is only implemented on Linux
99 class PerfJitLogger : public CodeEventLogger {
101 virtual void CodeMoveEvent(Address from, Address to) { UNIMPLEMENTED(); }
103 virtual void CodeDeleteEvent(Address from) { UNIMPLEMENTED(); }
105 virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared) {
109 virtual void SnapshotPositionEvent(Address addr, int pos) { UNIMPLEMENTED(); }
111 virtual void LogRecordedBuffer(Code* code, SharedFunctionInfo* shared,
112 const char* name, int length) {
117 #endif // V8_OS_LINUX
119 } // namespace v8::internal