V8 Project
perf-jit.h
Go to the documentation of this file.
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 // 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).
42 
43 #if V8_OS_LINUX
44 
45 // Linux perf tool logging support
46 class PerfJitLogger : public CodeEventLogger {
47  public:
48  PerfJitLogger();
49  virtual ~PerfJitLogger();
50 
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);
55 
56  private:
57  uint64_t GetTimestamp();
58  virtual void LogRecordedBuffer(Code* code, SharedFunctionInfo* shared,
59  const char* name, int length);
60 
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;
64 
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;
68 
69  void LogWriteBytes(const char* bytes, int size);
70  void LogWriteHeader();
71 
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;
76 
77  uint32_t GetElfMach() {
78 #if V8_TARGET_ARCH_IA32
79  return kElfMachIA32;
80 #elif V8_TARGET_ARCH_X64
81  return kElfMachX64;
82 #elif V8_TARGET_ARCH_ARM
83  return kElfMachARM;
84 #elif V8_TARGET_ARCH_MIPS
85  return kElfMachMIPS;
86 #else
87  UNIMPLEMENTED();
88  return 0;
89 #endif
90  }
91 
92  FILE* perf_output_handle_;
93  uint64_t code_index_;
94 };
95 
96 #else
97 
98 // PerfJitLogger is only implemented on Linux
100  public:
101  virtual void CodeMoveEvent(Address from, Address to) { UNIMPLEMENTED(); }
102 
103  virtual void CodeDeleteEvent(Address from) { UNIMPLEMENTED(); }
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(Code* code, SharedFunctionInfo* shared,
112  const char* name, int length) {
113  UNIMPLEMENTED();
114  }
115 };
116 
117 #endif // V8_OS_LINUX
118 }
119 } // namespace v8::internal
120 #endif
virtual void LogRecordedBuffer(Code *code, SharedFunctionInfo *shared, const char *name, int length)
Definition: perf-jit.h:111
virtual void SnapshotPositionEvent(Address addr, int pos)
Definition: perf-jit.h:109
virtual void CodeMoveEvent(Address from, Address to)
Definition: perf-jit.h:101
virtual void CodeDisableOptEvent(Code *code, SharedFunctionInfo *shared)
Definition: perf-jit.h:105
virtual void CodeDeleteEvent(Address from)
Definition: perf-jit.h:103
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in only print modified registers Trace simulator debug messages Implied by trace sim abort randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot A filename with extra code to be included in the A file to write the raw snapshot bytes to(mksnapshot only)") DEFINE_STRING(raw_context_file
enable harmony numeric enable harmony object literal extensions Optimize object size
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
#define UNIMPLEMENTED()
Definition: logging.h:28
byte * Address
Definition: globals.h:101
const int MB
Definition: globals.h:107
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20