michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef jit_PerfSpewer_h michael@0: #define jit_PerfSpewer_h michael@0: michael@0: #ifdef JS_ION_PERF michael@0: # include michael@0: # include "jit/IonMacroAssembler.h" michael@0: #endif michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: class MBasicBlock; michael@0: class MacroAssembler; michael@0: michael@0: #ifdef JS_ION_PERF michael@0: void CheckPerf(); michael@0: bool PerfBlockEnabled(); michael@0: bool PerfFuncEnabled(); michael@0: static inline bool PerfEnabled() { michael@0: return PerfBlockEnabled() || PerfFuncEnabled(); michael@0: } michael@0: #else michael@0: static inline void CheckPerf() {} michael@0: static inline bool PerfBlockEnabled() { return false; } michael@0: static inline bool PerfFuncEnabled() { return false; } michael@0: static inline bool PerfEnabled() { return false; } michael@0: #endif michael@0: michael@0: #ifdef JS_ION_PERF michael@0: michael@0: struct Record { michael@0: const char *filename; michael@0: unsigned lineNumber; michael@0: unsigned columnNumber; michael@0: uint32_t id; michael@0: Label start, end; michael@0: size_t startOffset, endOffset; michael@0: michael@0: Record(const char *filename, michael@0: unsigned lineNumber, michael@0: unsigned columnNumber, michael@0: uint32_t id) michael@0: : filename(filename), lineNumber(lineNumber), michael@0: columnNumber(columnNumber), id(id), michael@0: startOffset(0u), endOffset(0u) michael@0: {} michael@0: }; michael@0: michael@0: typedef Vector BasicBlocksVector; michael@0: michael@0: class PerfSpewer michael@0: { michael@0: protected: michael@0: static uint32_t nextFunctionIndex; michael@0: michael@0: public: michael@0: Label endInlineCode; michael@0: michael@0: protected: michael@0: BasicBlocksVector basicBlocks_; michael@0: michael@0: public: michael@0: virtual bool startBasicBlock(MBasicBlock *blk, MacroAssembler &masm); michael@0: bool endBasicBlock(MacroAssembler &masm); michael@0: bool noteEndInlineCode(MacroAssembler &masm); michael@0: michael@0: void writeProfile(JSScript *script, JitCode *code, MacroAssembler &masm); michael@0: }; michael@0: michael@0: void writePerfSpewerBaselineProfile(JSScript *script, JitCode *code); michael@0: void writePerfSpewerJitCodeProfile(JitCode *code, const char *msg); michael@0: michael@0: class AsmJSPerfSpewer : public PerfSpewer michael@0: { michael@0: public: michael@0: bool startBasicBlock(MBasicBlock *blk, MacroAssembler &masm); michael@0: michael@0: void noteBlocksOffsets(); michael@0: BasicBlocksVector &basicBlocks() { return basicBlocks_; } michael@0: }; michael@0: michael@0: void writePerfSpewerAsmJSFunctionMap(uintptr_t base, uintptr_t size, const char *filename, michael@0: unsigned lineno, unsigned colIndex, const char *funcName); michael@0: michael@0: void writePerfSpewerAsmJSBlocksMap(uintptr_t baseAddress, size_t funcStartOffset, michael@0: size_t funcStartOOLOffset, size_t funcSize, michael@0: const char *filename, const char *funcName, michael@0: const BasicBlocksVector &basicBlocks); michael@0: michael@0: void writePerfSpewerAsmJSEntriesAndExits(uintptr_t base, size_t size); michael@0: michael@0: #endif // JS_ION_PERF michael@0: michael@0: } // namespace jit michael@0: } // namespace js michael@0: michael@0: #endif /* jit_PerfSpewer_h */