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