v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
perf-jit.h
Go to the documentation of this file.
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_DIAGNOSTICS_PERF_JIT_H_
29#define V8_DIAGNOSTICS_PERF_JIT_H_
30
31#include "include/v8config.h"
32
33// {LinuxPerfJitLogger} is only implemented on Linux.
34#if V8_OS_LINUX
35
36#include "src/logging/log.h"
37
38namespace v8 {
39namespace internal {
40
41// Linux perf tool logging support.
42class LinuxPerfJitLogger : public CodeEventLogger {
43 public:
44 explicit LinuxPerfJitLogger(Isolate* isolate);
45 ~LinuxPerfJitLogger() override;
46
47 void CodeMoveEvent(Tagged<InstructionStream> from,
48 Tagged<InstructionStream> to) override {
49 UNREACHABLE(); // Unsupported.
50 }
51 void BytecodeMoveEvent(Tagged<BytecodeArray> from,
52 Tagged<BytecodeArray> to) override {}
53 void CodeDisableOptEvent(DirectHandle<AbstractCode> code,
54 DirectHandle<SharedFunctionInfo> shared) override {}
55
56 private:
57 void OpenJitDumpFile();
58 void CloseJitDumpFile();
59 void* OpenMarkerFile(int fd);
60 void CloseMarkerFile(void* marker_address);
61
62 uint64_t GetTimestamp();
63 void LogRecordedBuffer(Tagged<AbstractCode> code,
64 MaybeDirectHandle<SharedFunctionInfo> maybe_shared,
65 const char* name, size_t length) override;
66#if V8_ENABLE_WEBASSEMBLY
67 void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
68 size_t length) override;
69#endif // V8_ENABLE_WEBASSEMBLY
70
71 // Extension added to V8 log file name to get the low-level log name.
72 static const char kFilenameFormatString[];
73 static const int kFilenameBufferPadding;
74
75 // File buffer size of the low-level log. We don't use the default to
76 // minimize the associated overhead.
77 static const int kLogBufferSize = 2 * MB;
78
79 void WriteJitCodeLoadEntry(const uint8_t* code_pointer, uint32_t code_size,
80 const char* name, size_t name_length);
81
82 void LogWriteBytes(const char* bytes, size_t size);
83 void LogWriteHeader();
84 void LogWriteDebugInfo(Tagged<Code> code,
85 DirectHandle<SharedFunctionInfo> shared);
86#if V8_ENABLE_WEBASSEMBLY
87 void LogWriteDebugInfo(const wasm::WasmCode* code);
88#endif // V8_ENABLE_WEBASSEMBLY
89 void LogWriteUnwindingInfo(Tagged<Code> code);
90
91 static const uint32_t kElfMachIA32 = 3;
92 static const uint32_t kElfMachX64 = 62;
93 static const uint32_t kElfMachARM = 40;
94 static const uint32_t kElfMachMIPS64 = 8;
95 static const uint32_t kElfMachLOONG64 = 258;
96 static const uint32_t kElfMachARM64 = 183;
97 static const uint32_t kElfMachS390x = 22;
98 static const uint32_t kElfMachPPC64 = 21;
99 static const uint32_t kElfMachRISCV = 243;
100
101 uint32_t GetElfMach() {
102#if V8_TARGET_ARCH_IA32
103 return kElfMachIA32;
104#elif V8_TARGET_ARCH_X64
105 return kElfMachX64;
106#elif V8_TARGET_ARCH_ARM
107 return kElfMachARM;
108#elif V8_TARGET_ARCH_MIPS64
109 return kElfMachMIPS64;
110#elif V8_TARGET_ARCH_LOONG64
111 return kElfMachLOONG64;
112#elif V8_TARGET_ARCH_ARM64
113 return kElfMachARM64;
114#elif V8_TARGET_ARCH_S390X
115 return kElfMachS390x;
116#elif V8_TARGET_ARCH_PPC64
117 return kElfMachPPC64;
118#elif V8_TARGET_ARCH_RISCV32 || V8_TARGET_ARCH_RISCV64
119 return kElfMachRISCV;
120#else
122 return 0;
123#endif
124 }
125
126#if V8_TARGET_ARCH_32_BIT
127 static const int kElfHeaderSize = 0x34;
128#elif V8_TARGET_ARCH_64_BIT
129 static const int kElfHeaderSize = 0x40;
130#else
131#error Unknown target architecture pointer size
132#endif
133
134 // Per-process singleton file. We assume that there is one main isolate;
135 // to determine when it goes away, we keep reference count.
136 static FILE* perf_output_handle_;
137 static uint64_t reference_count_;
138 static void* marker_address_;
139 static uint64_t code_index_;
140 static int process_id_;
141};
142
143} // namespace internal
144} // namespace v8
145
146#endif // V8_OS_LINUX
147
148#endif // V8_DIAGNOSTICS_PERF_JIT_H_
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in allocation gc speed threshold for starting incremental marking via a task in percent of available threshold for starting incremental marking immediately in percent of available Use a single schedule for determining a marking schedule between JS and C objects schedules the minor GC task with kUserVisible priority max worker number of concurrent for NumberOfWorkerThreads start background threads that allocate memory concurrent_array_buffer_sweeping use parallel threads to clear weak refs in the atomic pause trace progress of the incremental marking trace object counts and memory usage * MB
#define UNREACHABLE()
Definition logging.h:67
#define UNIMPLEMENTED()
Definition logging.h:66