1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/c1/c1_InstructionPrinter.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,128 @@ 1.4 +/* 1.5 + * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef PRODUCT 1.29 +class InstructionPrinter: public InstructionVisitor { 1.30 + private: 1.31 + outputStream* _output; 1.32 + bool _print_phis; 1.33 + 1.34 + enum LayoutConstants { 1.35 + bci_pos = 2, 1.36 + use_pos = 7, 1.37 + temp_pos = 12, 1.38 + instr_pos = 19, 1.39 + end_pos = 60 1.40 + }; 1.41 + 1.42 + bool is_illegal_phi(Value v); 1.43 + 1.44 + public: 1.45 + InstructionPrinter(bool print_phis = true, outputStream* output = tty) 1.46 + : _print_phis(print_phis) 1.47 + , _output(output) 1.48 + {} 1.49 + 1.50 + outputStream* output() { return _output; } 1.51 + 1.52 + // helpers 1.53 + static const char* basic_type_name(BasicType type); 1.54 + static const char* cond_name(If::Condition cond); 1.55 + static const char* op_name(Bytecodes::Code op); 1.56 + bool is_phi_of_block(Value v, BlockBegin* b); 1.57 + 1.58 + // type-specific print functions 1.59 + void print_klass(ciKlass* klass); 1.60 + void print_object(Value obj); 1.61 + 1.62 + // generic print functions 1.63 + void print_temp(Value value); 1.64 + void print_field(AccessField* field); 1.65 + void print_indexed(AccessIndexed* indexed); 1.66 + void print_monitor(AccessMonitor* monitor); 1.67 + void print_op2(Op2* instr); 1.68 + void print_value(Value value); 1.69 + void print_instr(Instruction* instr); 1.70 + void print_stack(ValueStack* stack); 1.71 + void print_inline_level(BlockBegin* block); 1.72 + void print_unsafe_op(UnsafeOp* op, const char* name); 1.73 + void print_unsafe_raw_op(UnsafeRawOp* op, const char* name); 1.74 + void print_unsafe_object_op(UnsafeObjectOp* op, const char* name); 1.75 + void print_phi(int i, Value v, BlockBegin* b); 1.76 + void print_alias(Value v); 1.77 + 1.78 + // line printing of instructions 1.79 + void fill_to(int pos, char filler = ' '); 1.80 + void print_head(); 1.81 + void print_line(Instruction* instr); 1.82 + 1.83 + // visitor functionality 1.84 + virtual void do_Phi (Phi* x); 1.85 + virtual void do_Local (Local* x); 1.86 + virtual void do_Constant (Constant* x); 1.87 + virtual void do_LoadField (LoadField* x); 1.88 + virtual void do_StoreField (StoreField* x); 1.89 + virtual void do_ArrayLength (ArrayLength* x); 1.90 + virtual void do_LoadIndexed (LoadIndexed* x); 1.91 + virtual void do_StoreIndexed (StoreIndexed* x); 1.92 + virtual void do_NegateOp (NegateOp* x); 1.93 + virtual void do_ArithmeticOp (ArithmeticOp* x); 1.94 + virtual void do_ShiftOp (ShiftOp* x); 1.95 + virtual void do_LogicOp (LogicOp* x); 1.96 + virtual void do_CompareOp (CompareOp* x); 1.97 + virtual void do_IfOp (IfOp* x); 1.98 + virtual void do_Convert (Convert* x); 1.99 + virtual void do_NullCheck (NullCheck* x); 1.100 + virtual void do_Invoke (Invoke* x); 1.101 + virtual void do_NewInstance (NewInstance* x); 1.102 + virtual void do_NewTypeArray (NewTypeArray* x); 1.103 + virtual void do_NewObjectArray (NewObjectArray* x); 1.104 + virtual void do_NewMultiArray (NewMultiArray* x); 1.105 + virtual void do_CheckCast (CheckCast* x); 1.106 + virtual void do_InstanceOf (InstanceOf* x); 1.107 + virtual void do_MonitorEnter (MonitorEnter* x); 1.108 + virtual void do_MonitorExit (MonitorExit* x); 1.109 + virtual void do_Intrinsic (Intrinsic* x); 1.110 + virtual void do_BlockBegin (BlockBegin* x); 1.111 + virtual void do_Goto (Goto* x); 1.112 + virtual void do_If (If* x); 1.113 + virtual void do_IfInstanceOf (IfInstanceOf* x); 1.114 + virtual void do_TableSwitch (TableSwitch* x); 1.115 + virtual void do_LookupSwitch (LookupSwitch* x); 1.116 + virtual void do_Return (Return* x); 1.117 + virtual void do_Throw (Throw* x); 1.118 + virtual void do_Base (Base* x); 1.119 + virtual void do_OsrEntry (OsrEntry* x); 1.120 + virtual void do_ExceptionObject(ExceptionObject* x); 1.121 + virtual void do_RoundFP (RoundFP* x); 1.122 + virtual void do_UnsafeGetRaw (UnsafeGetRaw* x); 1.123 + virtual void do_UnsafePutRaw (UnsafePutRaw* x); 1.124 + virtual void do_UnsafeGetObject(UnsafeGetObject* x); 1.125 + virtual void do_UnsafePutObject(UnsafePutObject* x); 1.126 + virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x); 1.127 + virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x); 1.128 + virtual void do_ProfileCall (ProfileCall* x); 1.129 + virtual void do_ProfileCounter (ProfileCounter* x); 1.130 +}; 1.131 +#endif // PRODUCT