duke@435: /* mikael@4153: * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_C1_C1_INSTRUCTIONPRINTER_HPP stefank@2314: #define SHARE_VM_C1_C1_INSTRUCTIONPRINTER_HPP stefank@2314: stefank@2314: #include "c1/c1_IR.hpp" stefank@2314: #include "c1/c1_Instruction.hpp" stefank@2314: #include "c1/c1_Runtime1.hpp" stefank@2314: duke@435: #ifndef PRODUCT duke@435: class InstructionPrinter: public InstructionVisitor { duke@435: private: duke@435: outputStream* _output; duke@435: bool _print_phis; duke@435: duke@435: enum LayoutConstants { duke@435: bci_pos = 2, duke@435: use_pos = 7, duke@435: temp_pos = 12, duke@435: instr_pos = 19, duke@435: end_pos = 60 duke@435: }; duke@435: duke@435: bool is_illegal_phi(Value v); duke@435: duke@435: public: duke@435: InstructionPrinter(bool print_phis = true, outputStream* output = tty) duke@435: : _print_phis(print_phis) duke@435: , _output(output) duke@435: {} duke@435: duke@435: outputStream* output() { return _output; } duke@435: duke@435: // helpers duke@435: static const char* basic_type_name(BasicType type); duke@435: static const char* cond_name(If::Condition cond); duke@435: static const char* op_name(Bytecodes::Code op); duke@435: bool is_phi_of_block(Value v, BlockBegin* b); duke@435: duke@435: // type-specific print functions duke@435: void print_klass(ciKlass* klass); duke@435: void print_object(Value obj); duke@435: duke@435: // generic print functions duke@435: void print_temp(Value value); duke@435: void print_field(AccessField* field); duke@435: void print_indexed(AccessIndexed* indexed); duke@435: void print_monitor(AccessMonitor* monitor); duke@435: void print_op2(Op2* instr); duke@435: void print_value(Value value); duke@435: void print_instr(Instruction* instr); duke@435: void print_stack(ValueStack* stack); duke@435: void print_inline_level(BlockBegin* block); duke@435: void print_unsafe_op(UnsafeOp* op, const char* name); duke@435: void print_unsafe_raw_op(UnsafeRawOp* op, const char* name); duke@435: void print_unsafe_object_op(UnsafeObjectOp* op, const char* name); duke@435: void print_phi(int i, Value v, BlockBegin* b); duke@435: void print_alias(Value v); duke@435: duke@435: // line printing of instructions duke@435: void fill_to(int pos, char filler = ' '); duke@435: void print_head(); duke@435: void print_line(Instruction* instr); duke@435: duke@435: // visitor functionality duke@435: virtual void do_Phi (Phi* x); duke@435: virtual void do_Local (Local* x); duke@435: virtual void do_Constant (Constant* x); duke@435: virtual void do_LoadField (LoadField* x); duke@435: virtual void do_StoreField (StoreField* x); duke@435: virtual void do_ArrayLength (ArrayLength* x); duke@435: virtual void do_LoadIndexed (LoadIndexed* x); duke@435: virtual void do_StoreIndexed (StoreIndexed* x); duke@435: virtual void do_NegateOp (NegateOp* x); duke@435: virtual void do_ArithmeticOp (ArithmeticOp* x); duke@435: virtual void do_ShiftOp (ShiftOp* x); duke@435: virtual void do_LogicOp (LogicOp* x); duke@435: virtual void do_CompareOp (CompareOp* x); duke@435: virtual void do_IfOp (IfOp* x); duke@435: virtual void do_Convert (Convert* x); duke@435: virtual void do_NullCheck (NullCheck* x); twisti@3969: virtual void do_TypeCast (TypeCast* x); duke@435: virtual void do_Invoke (Invoke* x); duke@435: virtual void do_NewInstance (NewInstance* x); duke@435: virtual void do_NewTypeArray (NewTypeArray* x); duke@435: virtual void do_NewObjectArray (NewObjectArray* x); duke@435: virtual void do_NewMultiArray (NewMultiArray* x); duke@435: virtual void do_CheckCast (CheckCast* x); duke@435: virtual void do_InstanceOf (InstanceOf* x); duke@435: virtual void do_MonitorEnter (MonitorEnter* x); duke@435: virtual void do_MonitorExit (MonitorExit* x); duke@435: virtual void do_Intrinsic (Intrinsic* x); duke@435: virtual void do_BlockBegin (BlockBegin* x); duke@435: virtual void do_Goto (Goto* x); duke@435: virtual void do_If (If* x); duke@435: virtual void do_IfInstanceOf (IfInstanceOf* x); duke@435: virtual void do_TableSwitch (TableSwitch* x); duke@435: virtual void do_LookupSwitch (LookupSwitch* x); duke@435: virtual void do_Return (Return* x); duke@435: virtual void do_Throw (Throw* x); duke@435: virtual void do_Base (Base* x); duke@435: virtual void do_OsrEntry (OsrEntry* x); duke@435: virtual void do_ExceptionObject(ExceptionObject* x); duke@435: virtual void do_RoundFP (RoundFP* x); duke@435: virtual void do_UnsafeGetRaw (UnsafeGetRaw* x); duke@435: virtual void do_UnsafePutRaw (UnsafePutRaw* x); duke@435: virtual void do_UnsafeGetObject(UnsafeGetObject* x); duke@435: virtual void do_UnsafePutObject(UnsafePutObject* x); roland@4106: virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x); duke@435: virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x); duke@435: virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x); duke@435: virtual void do_ProfileCall (ProfileCall* x); iveresov@2138: virtual void do_ProfileInvoke (ProfileInvoke* x); never@2486: virtual void do_RuntimeCall (RuntimeCall* x); jiangli@3592: virtual void do_MemBar (MemBar* x); roland@4860: virtual void do_RangeCheckPredicate(RangeCheckPredicate* x); roland@4860: virtual void do_Assert (Assert* x); duke@435: }; duke@435: #endif // PRODUCT stefank@2314: stefank@2314: #endif // SHARE_VM_C1_C1_INSTRUCTIONPRINTER_HPP