js/src/jit/PerfSpewer.h

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:19f2de66a95c
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sts=4 et sw=4 tw=99:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef jit_PerfSpewer_h
8 #define jit_PerfSpewer_h
9
10 #ifdef JS_ION_PERF
11 # include <stdio.h>
12 # include "jit/IonMacroAssembler.h"
13 #endif
14
15 namespace js {
16 namespace jit {
17
18 class MBasicBlock;
19 class MacroAssembler;
20
21 #ifdef JS_ION_PERF
22 void CheckPerf();
23 bool PerfBlockEnabled();
24 bool PerfFuncEnabled();
25 static inline bool PerfEnabled() {
26 return PerfBlockEnabled() || PerfFuncEnabled();
27 }
28 #else
29 static inline void CheckPerf() {}
30 static inline bool PerfBlockEnabled() { return false; }
31 static inline bool PerfFuncEnabled() { return false; }
32 static inline bool PerfEnabled() { return false; }
33 #endif
34
35 #ifdef JS_ION_PERF
36
37 struct Record {
38 const char *filename;
39 unsigned lineNumber;
40 unsigned columnNumber;
41 uint32_t id;
42 Label start, end;
43 size_t startOffset, endOffset;
44
45 Record(const char *filename,
46 unsigned lineNumber,
47 unsigned columnNumber,
48 uint32_t id)
49 : filename(filename), lineNumber(lineNumber),
50 columnNumber(columnNumber), id(id),
51 startOffset(0u), endOffset(0u)
52 {}
53 };
54
55 typedef Vector<Record, 1, SystemAllocPolicy> BasicBlocksVector;
56
57 class PerfSpewer
58 {
59 protected:
60 static uint32_t nextFunctionIndex;
61
62 public:
63 Label endInlineCode;
64
65 protected:
66 BasicBlocksVector basicBlocks_;
67
68 public:
69 virtual bool startBasicBlock(MBasicBlock *blk, MacroAssembler &masm);
70 bool endBasicBlock(MacroAssembler &masm);
71 bool noteEndInlineCode(MacroAssembler &masm);
72
73 void writeProfile(JSScript *script, JitCode *code, MacroAssembler &masm);
74 };
75
76 void writePerfSpewerBaselineProfile(JSScript *script, JitCode *code);
77 void writePerfSpewerJitCodeProfile(JitCode *code, const char *msg);
78
79 class AsmJSPerfSpewer : public PerfSpewer
80 {
81 public:
82 bool startBasicBlock(MBasicBlock *blk, MacroAssembler &masm);
83
84 void noteBlocksOffsets();
85 BasicBlocksVector &basicBlocks() { return basicBlocks_; }
86 };
87
88 void writePerfSpewerAsmJSFunctionMap(uintptr_t base, uintptr_t size, const char *filename,
89 unsigned lineno, unsigned colIndex, const char *funcName);
90
91 void writePerfSpewerAsmJSBlocksMap(uintptr_t baseAddress, size_t funcStartOffset,
92 size_t funcStartOOLOffset, size_t funcSize,
93 const char *filename, const char *funcName,
94 const BasicBlocksVector &basicBlocks);
95
96 void writePerfSpewerAsmJSEntriesAndExits(uintptr_t base, size_t size);
97
98 #endif // JS_ION_PERF
99
100 } // namespace jit
101 } // namespace js
102
103 #endif /* jit_PerfSpewer_h */

mercurial