GraphSpewer.h (1674B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * vim: set ts=8 sts=2 et sw=2 tw=80: 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_GraphSpewer_h 8 #define jit_GraphSpewer_h 9 10 #ifdef JS_JITSPEW 11 12 # include "js/TypeDecls.h" 13 # include "vm/JSONPrinter.h" 14 # include "wasm/WasmTypeDef.h" 15 16 namespace js { 17 namespace jit { 18 19 class BacktrackingAllocator; 20 class MDefinition; 21 class MIRGraph; 22 class MResumePoint; 23 class LNode; 24 25 class GraphSpewer : JSONPrinter { 26 private: 27 // Optional; wasm type information to be used when dumping MIR nodes. 28 const wasm::CodeMetadata* wasmCodeMeta_; 29 30 void beginPass(const char* pass); 31 void spewMDef(MDefinition* def); 32 void spewMResumePoint(MResumePoint* rp); 33 void spewMIR(MIRGraph* mir); 34 void spewLIns(LNode* ins); 35 void spewLIR(MIRGraph* mir); 36 void spewRanges(BacktrackingAllocator* regalloc); 37 void endPass(); 38 39 public: 40 explicit GraphSpewer(GenericPrinter& out, 41 const wasm::CodeMetadata* wasmCodeMeta = nullptr) 42 : JSONPrinter(out, /*indent*/ false), wasmCodeMeta_(wasmCodeMeta) {} 43 44 void begin(); 45 void beginFunction(JSScript* script); 46 void beginWasmFunction(unsigned funcIndex); 47 void beginAnonFunction(); 48 void spewPass(const char* pass, MIRGraph* graph, 49 BacktrackingAllocator* ra = nullptr); 50 void endFunction(); 51 void end(); 52 }; 53 54 using UniqueGraphSpewer = UniquePtr<GraphSpewer>; 55 56 } // namespace jit 57 } // namespace js 58 59 #endif /* JS_JITSPEW */ 60 61 #endif /* jit_GraphSpewer_h */