Thu, 21 Mar 2013 09:27:54 +0100
7153771: array bound check elimination for c1
Summary: when possible optimize out array bound checks, inserting predicates when needed.
Reviewed-by: never, kvn, twisti
Contributed-by: thomaswue <thomas.wuerthinger@oracle.com>
duke@435 | 1 | /* |
mikael@4153 | 2 | * Copyright (c) 1999, 2012, Oracle and/or its affiliates. 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 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_C1_C1_INSTRUCTIONPRINTER_HPP |
stefank@2314 | 26 | #define SHARE_VM_C1_C1_INSTRUCTIONPRINTER_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "c1/c1_IR.hpp" |
stefank@2314 | 29 | #include "c1/c1_Instruction.hpp" |
stefank@2314 | 30 | #include "c1/c1_Runtime1.hpp" |
stefank@2314 | 31 | |
duke@435 | 32 | #ifndef PRODUCT |
duke@435 | 33 | class InstructionPrinter: public InstructionVisitor { |
duke@435 | 34 | private: |
duke@435 | 35 | outputStream* _output; |
duke@435 | 36 | bool _print_phis; |
duke@435 | 37 | |
duke@435 | 38 | enum LayoutConstants { |
duke@435 | 39 | bci_pos = 2, |
duke@435 | 40 | use_pos = 7, |
duke@435 | 41 | temp_pos = 12, |
duke@435 | 42 | instr_pos = 19, |
duke@435 | 43 | end_pos = 60 |
duke@435 | 44 | }; |
duke@435 | 45 | |
duke@435 | 46 | bool is_illegal_phi(Value v); |
duke@435 | 47 | |
duke@435 | 48 | public: |
duke@435 | 49 | InstructionPrinter(bool print_phis = true, outputStream* output = tty) |
duke@435 | 50 | : _print_phis(print_phis) |
duke@435 | 51 | , _output(output) |
duke@435 | 52 | {} |
duke@435 | 53 | |
duke@435 | 54 | outputStream* output() { return _output; } |
duke@435 | 55 | |
duke@435 | 56 | // helpers |
duke@435 | 57 | static const char* basic_type_name(BasicType type); |
duke@435 | 58 | static const char* cond_name(If::Condition cond); |
duke@435 | 59 | static const char* op_name(Bytecodes::Code op); |
duke@435 | 60 | bool is_phi_of_block(Value v, BlockBegin* b); |
duke@435 | 61 | |
duke@435 | 62 | // type-specific print functions |
duke@435 | 63 | void print_klass(ciKlass* klass); |
duke@435 | 64 | void print_object(Value obj); |
duke@435 | 65 | |
duke@435 | 66 | // generic print functions |
duke@435 | 67 | void print_temp(Value value); |
duke@435 | 68 | void print_field(AccessField* field); |
duke@435 | 69 | void print_indexed(AccessIndexed* indexed); |
duke@435 | 70 | void print_monitor(AccessMonitor* monitor); |
duke@435 | 71 | void print_op2(Op2* instr); |
duke@435 | 72 | void print_value(Value value); |
duke@435 | 73 | void print_instr(Instruction* instr); |
duke@435 | 74 | void print_stack(ValueStack* stack); |
duke@435 | 75 | void print_inline_level(BlockBegin* block); |
duke@435 | 76 | void print_unsafe_op(UnsafeOp* op, const char* name); |
duke@435 | 77 | void print_unsafe_raw_op(UnsafeRawOp* op, const char* name); |
duke@435 | 78 | void print_unsafe_object_op(UnsafeObjectOp* op, const char* name); |
duke@435 | 79 | void print_phi(int i, Value v, BlockBegin* b); |
duke@435 | 80 | void print_alias(Value v); |
duke@435 | 81 | |
duke@435 | 82 | // line printing of instructions |
duke@435 | 83 | void fill_to(int pos, char filler = ' '); |
duke@435 | 84 | void print_head(); |
duke@435 | 85 | void print_line(Instruction* instr); |
duke@435 | 86 | |
duke@435 | 87 | // visitor functionality |
duke@435 | 88 | virtual void do_Phi (Phi* x); |
duke@435 | 89 | virtual void do_Local (Local* x); |
duke@435 | 90 | virtual void do_Constant (Constant* x); |
duke@435 | 91 | virtual void do_LoadField (LoadField* x); |
duke@435 | 92 | virtual void do_StoreField (StoreField* x); |
duke@435 | 93 | virtual void do_ArrayLength (ArrayLength* x); |
duke@435 | 94 | virtual void do_LoadIndexed (LoadIndexed* x); |
duke@435 | 95 | virtual void do_StoreIndexed (StoreIndexed* x); |
duke@435 | 96 | virtual void do_NegateOp (NegateOp* x); |
duke@435 | 97 | virtual void do_ArithmeticOp (ArithmeticOp* x); |
duke@435 | 98 | virtual void do_ShiftOp (ShiftOp* x); |
duke@435 | 99 | virtual void do_LogicOp (LogicOp* x); |
duke@435 | 100 | virtual void do_CompareOp (CompareOp* x); |
duke@435 | 101 | virtual void do_IfOp (IfOp* x); |
duke@435 | 102 | virtual void do_Convert (Convert* x); |
duke@435 | 103 | virtual void do_NullCheck (NullCheck* x); |
twisti@3969 | 104 | virtual void do_TypeCast (TypeCast* x); |
duke@435 | 105 | virtual void do_Invoke (Invoke* x); |
duke@435 | 106 | virtual void do_NewInstance (NewInstance* x); |
duke@435 | 107 | virtual void do_NewTypeArray (NewTypeArray* x); |
duke@435 | 108 | virtual void do_NewObjectArray (NewObjectArray* x); |
duke@435 | 109 | virtual void do_NewMultiArray (NewMultiArray* x); |
duke@435 | 110 | virtual void do_CheckCast (CheckCast* x); |
duke@435 | 111 | virtual void do_InstanceOf (InstanceOf* x); |
duke@435 | 112 | virtual void do_MonitorEnter (MonitorEnter* x); |
duke@435 | 113 | virtual void do_MonitorExit (MonitorExit* x); |
duke@435 | 114 | virtual void do_Intrinsic (Intrinsic* x); |
duke@435 | 115 | virtual void do_BlockBegin (BlockBegin* x); |
duke@435 | 116 | virtual void do_Goto (Goto* x); |
duke@435 | 117 | virtual void do_If (If* x); |
duke@435 | 118 | virtual void do_IfInstanceOf (IfInstanceOf* x); |
duke@435 | 119 | virtual void do_TableSwitch (TableSwitch* x); |
duke@435 | 120 | virtual void do_LookupSwitch (LookupSwitch* x); |
duke@435 | 121 | virtual void do_Return (Return* x); |
duke@435 | 122 | virtual void do_Throw (Throw* x); |
duke@435 | 123 | virtual void do_Base (Base* x); |
duke@435 | 124 | virtual void do_OsrEntry (OsrEntry* x); |
duke@435 | 125 | virtual void do_ExceptionObject(ExceptionObject* x); |
duke@435 | 126 | virtual void do_RoundFP (RoundFP* x); |
duke@435 | 127 | virtual void do_UnsafeGetRaw (UnsafeGetRaw* x); |
duke@435 | 128 | virtual void do_UnsafePutRaw (UnsafePutRaw* x); |
duke@435 | 129 | virtual void do_UnsafeGetObject(UnsafeGetObject* x); |
duke@435 | 130 | virtual void do_UnsafePutObject(UnsafePutObject* x); |
roland@4106 | 131 | virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x); |
duke@435 | 132 | virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x); |
duke@435 | 133 | virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x); |
duke@435 | 134 | virtual void do_ProfileCall (ProfileCall* x); |
iveresov@2138 | 135 | virtual void do_ProfileInvoke (ProfileInvoke* x); |
never@2486 | 136 | virtual void do_RuntimeCall (RuntimeCall* x); |
jiangli@3592 | 137 | virtual void do_MemBar (MemBar* x); |
roland@4860 | 138 | virtual void do_RangeCheckPredicate(RangeCheckPredicate* x); |
roland@4860 | 139 | virtual void do_Assert (Assert* x); |
duke@435 | 140 | }; |
duke@435 | 141 | #endif // PRODUCT |
stefank@2314 | 142 | |
stefank@2314 | 143 | #endif // SHARE_VM_C1_C1_INSTRUCTIONPRINTER_HPP |