1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit/PerfSpewer.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,103 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99: 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef jit_PerfSpewer_h 1.11 +#define jit_PerfSpewer_h 1.12 + 1.13 +#ifdef JS_ION_PERF 1.14 +# include <stdio.h> 1.15 +# include "jit/IonMacroAssembler.h" 1.16 +#endif 1.17 + 1.18 +namespace js { 1.19 +namespace jit { 1.20 + 1.21 +class MBasicBlock; 1.22 +class MacroAssembler; 1.23 + 1.24 +#ifdef JS_ION_PERF 1.25 +void CheckPerf(); 1.26 +bool PerfBlockEnabled(); 1.27 +bool PerfFuncEnabled(); 1.28 +static inline bool PerfEnabled() { 1.29 + return PerfBlockEnabled() || PerfFuncEnabled(); 1.30 +} 1.31 +#else 1.32 +static inline void CheckPerf() {} 1.33 +static inline bool PerfBlockEnabled() { return false; } 1.34 +static inline bool PerfFuncEnabled() { return false; } 1.35 +static inline bool PerfEnabled() { return false; } 1.36 +#endif 1.37 + 1.38 +#ifdef JS_ION_PERF 1.39 + 1.40 +struct Record { 1.41 + const char *filename; 1.42 + unsigned lineNumber; 1.43 + unsigned columnNumber; 1.44 + uint32_t id; 1.45 + Label start, end; 1.46 + size_t startOffset, endOffset; 1.47 + 1.48 + Record(const char *filename, 1.49 + unsigned lineNumber, 1.50 + unsigned columnNumber, 1.51 + uint32_t id) 1.52 + : filename(filename), lineNumber(lineNumber), 1.53 + columnNumber(columnNumber), id(id), 1.54 + startOffset(0u), endOffset(0u) 1.55 + {} 1.56 +}; 1.57 + 1.58 +typedef Vector<Record, 1, SystemAllocPolicy> BasicBlocksVector; 1.59 + 1.60 +class PerfSpewer 1.61 +{ 1.62 + protected: 1.63 + static uint32_t nextFunctionIndex; 1.64 + 1.65 + public: 1.66 + Label endInlineCode; 1.67 + 1.68 + protected: 1.69 + BasicBlocksVector basicBlocks_; 1.70 + 1.71 + public: 1.72 + virtual bool startBasicBlock(MBasicBlock *blk, MacroAssembler &masm); 1.73 + bool endBasicBlock(MacroAssembler &masm); 1.74 + bool noteEndInlineCode(MacroAssembler &masm); 1.75 + 1.76 + void writeProfile(JSScript *script, JitCode *code, MacroAssembler &masm); 1.77 +}; 1.78 + 1.79 +void writePerfSpewerBaselineProfile(JSScript *script, JitCode *code); 1.80 +void writePerfSpewerJitCodeProfile(JitCode *code, const char *msg); 1.81 + 1.82 +class AsmJSPerfSpewer : public PerfSpewer 1.83 +{ 1.84 + public: 1.85 + bool startBasicBlock(MBasicBlock *blk, MacroAssembler &masm); 1.86 + 1.87 + void noteBlocksOffsets(); 1.88 + BasicBlocksVector &basicBlocks() { return basicBlocks_; } 1.89 +}; 1.90 + 1.91 +void writePerfSpewerAsmJSFunctionMap(uintptr_t base, uintptr_t size, const char *filename, 1.92 + unsigned lineno, unsigned colIndex, const char *funcName); 1.93 + 1.94 +void writePerfSpewerAsmJSBlocksMap(uintptr_t baseAddress, size_t funcStartOffset, 1.95 + size_t funcStartOOLOffset, size_t funcSize, 1.96 + const char *filename, const char *funcName, 1.97 + const BasicBlocksVector &basicBlocks); 1.98 + 1.99 +void writePerfSpewerAsmJSEntriesAndExits(uintptr_t base, size_t size); 1.100 + 1.101 +#endif // JS_ION_PERF 1.102 + 1.103 +} // namespace jit 1.104 +} // namespace js 1.105 + 1.106 +#endif /* jit_PerfSpewer_h */