|
1 /* |
|
2 * Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 * have any questions. |
|
22 * |
|
23 */ |
|
24 |
|
25 #ifndef PRODUCT |
|
26 class InstructionPrinter: public InstructionVisitor { |
|
27 private: |
|
28 outputStream* _output; |
|
29 bool _print_phis; |
|
30 |
|
31 enum LayoutConstants { |
|
32 bci_pos = 2, |
|
33 use_pos = 7, |
|
34 temp_pos = 12, |
|
35 instr_pos = 19, |
|
36 end_pos = 60 |
|
37 }; |
|
38 |
|
39 bool is_illegal_phi(Value v); |
|
40 |
|
41 public: |
|
42 InstructionPrinter(bool print_phis = true, outputStream* output = tty) |
|
43 : _print_phis(print_phis) |
|
44 , _output(output) |
|
45 {} |
|
46 |
|
47 outputStream* output() { return _output; } |
|
48 |
|
49 // helpers |
|
50 static const char* basic_type_name(BasicType type); |
|
51 static const char* cond_name(If::Condition cond); |
|
52 static const char* op_name(Bytecodes::Code op); |
|
53 bool is_phi_of_block(Value v, BlockBegin* b); |
|
54 |
|
55 // type-specific print functions |
|
56 void print_klass(ciKlass* klass); |
|
57 void print_object(Value obj); |
|
58 |
|
59 // generic print functions |
|
60 void print_temp(Value value); |
|
61 void print_field(AccessField* field); |
|
62 void print_indexed(AccessIndexed* indexed); |
|
63 void print_monitor(AccessMonitor* monitor); |
|
64 void print_op2(Op2* instr); |
|
65 void print_value(Value value); |
|
66 void print_instr(Instruction* instr); |
|
67 void print_stack(ValueStack* stack); |
|
68 void print_inline_level(BlockBegin* block); |
|
69 void print_unsafe_op(UnsafeOp* op, const char* name); |
|
70 void print_unsafe_raw_op(UnsafeRawOp* op, const char* name); |
|
71 void print_unsafe_object_op(UnsafeObjectOp* op, const char* name); |
|
72 void print_phi(int i, Value v, BlockBegin* b); |
|
73 void print_alias(Value v); |
|
74 |
|
75 // line printing of instructions |
|
76 void fill_to(int pos, char filler = ' '); |
|
77 void print_head(); |
|
78 void print_line(Instruction* instr); |
|
79 |
|
80 // visitor functionality |
|
81 virtual void do_Phi (Phi* x); |
|
82 virtual void do_Local (Local* x); |
|
83 virtual void do_Constant (Constant* x); |
|
84 virtual void do_LoadField (LoadField* x); |
|
85 virtual void do_StoreField (StoreField* x); |
|
86 virtual void do_ArrayLength (ArrayLength* x); |
|
87 virtual void do_LoadIndexed (LoadIndexed* x); |
|
88 virtual void do_StoreIndexed (StoreIndexed* x); |
|
89 virtual void do_NegateOp (NegateOp* x); |
|
90 virtual void do_ArithmeticOp (ArithmeticOp* x); |
|
91 virtual void do_ShiftOp (ShiftOp* x); |
|
92 virtual void do_LogicOp (LogicOp* x); |
|
93 virtual void do_CompareOp (CompareOp* x); |
|
94 virtual void do_IfOp (IfOp* x); |
|
95 virtual void do_Convert (Convert* x); |
|
96 virtual void do_NullCheck (NullCheck* x); |
|
97 virtual void do_Invoke (Invoke* x); |
|
98 virtual void do_NewInstance (NewInstance* x); |
|
99 virtual void do_NewTypeArray (NewTypeArray* x); |
|
100 virtual void do_NewObjectArray (NewObjectArray* x); |
|
101 virtual void do_NewMultiArray (NewMultiArray* x); |
|
102 virtual void do_CheckCast (CheckCast* x); |
|
103 virtual void do_InstanceOf (InstanceOf* x); |
|
104 virtual void do_MonitorEnter (MonitorEnter* x); |
|
105 virtual void do_MonitorExit (MonitorExit* x); |
|
106 virtual void do_Intrinsic (Intrinsic* x); |
|
107 virtual void do_BlockBegin (BlockBegin* x); |
|
108 virtual void do_Goto (Goto* x); |
|
109 virtual void do_If (If* x); |
|
110 virtual void do_IfInstanceOf (IfInstanceOf* x); |
|
111 virtual void do_TableSwitch (TableSwitch* x); |
|
112 virtual void do_LookupSwitch (LookupSwitch* x); |
|
113 virtual void do_Return (Return* x); |
|
114 virtual void do_Throw (Throw* x); |
|
115 virtual void do_Base (Base* x); |
|
116 virtual void do_OsrEntry (OsrEntry* x); |
|
117 virtual void do_ExceptionObject(ExceptionObject* x); |
|
118 virtual void do_RoundFP (RoundFP* x); |
|
119 virtual void do_UnsafeGetRaw (UnsafeGetRaw* x); |
|
120 virtual void do_UnsafePutRaw (UnsafePutRaw* x); |
|
121 virtual void do_UnsafeGetObject(UnsafeGetObject* x); |
|
122 virtual void do_UnsafePutObject(UnsafePutObject* x); |
|
123 virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x); |
|
124 virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x); |
|
125 virtual void do_ProfileCall (ProfileCall* x); |
|
126 virtual void do_ProfileCounter (ProfileCounter* x); |
|
127 }; |
|
128 #endif // PRODUCT |