src/share/vm/c1/c1_Canonicalizer.hpp

Thu, 21 Mar 2013 09:27:54 +0100

author
roland
date
Thu, 21 Mar 2013 09:27:54 +0100
changeset 4860
46f6f063b272
parent 4153
b9a9ed0f8eeb
child 4947
acadb114c818
permissions
-rw-r--r--

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_CANONICALIZER_HPP
stefank@2314 26 #define SHARE_VM_C1_C1_CANONICALIZER_HPP
stefank@2314 27
stefank@2314 28 #include "c1/c1_Instruction.hpp"
stefank@2314 29
duke@435 30 class Canonicalizer: InstructionVisitor {
duke@435 31 private:
iveresov@2138 32 Compilation *_compilation;
duke@435 33 Instruction* _canonical;
duke@435 34 int _bci;
duke@435 35
iveresov@2138 36 Compilation *compilation() { return _compilation; }
duke@435 37 void set_canonical(Value x);
duke@435 38 void set_bci(int bci) { _bci = bci; }
duke@435 39 void set_constant(jint x) { set_canonical(new Constant(new IntConstant(x))); }
duke@435 40 void set_constant(jlong x) { set_canonical(new Constant(new LongConstant(x))); }
duke@435 41 void set_constant(jfloat x) { set_canonical(new Constant(new FloatConstant(x))); }
duke@435 42 void set_constant(jdouble x) { set_canonical(new Constant(new DoubleConstant(x))); }
duke@435 43 void move_const_to_right(Op2* x);
duke@435 44 void do_Op2(Op2* x);
duke@435 45 void do_UnsafeRawOp(UnsafeRawOp* x);
duke@435 46
duke@435 47 void unsafe_raw_match(UnsafeRawOp* x,
duke@435 48 Instruction** base,
duke@435 49 Instruction** index,
duke@435 50 int* scale);
duke@435 51
duke@435 52 public:
iveresov@2138 53 Canonicalizer(Compilation* c, Value x, int bci) : _compilation(c), _canonical(x), _bci(bci) {
iveresov@3246 54 NOT_PRODUCT(x->set_printable_bci(bci));
iveresov@2138 55 if (CanonicalizeNodes) x->visit(this);
iveresov@2138 56 }
duke@435 57 Value canonical() const { return _canonical; }
duke@435 58 int bci() const { return _bci; }
duke@435 59
duke@435 60 virtual void do_Phi (Phi* x);
duke@435 61 virtual void do_Constant (Constant* x);
duke@435 62 virtual void do_Local (Local* x);
duke@435 63 virtual void do_LoadField (LoadField* x);
duke@435 64 virtual void do_StoreField (StoreField* x);
duke@435 65 virtual void do_ArrayLength (ArrayLength* x);
duke@435 66 virtual void do_LoadIndexed (LoadIndexed* x);
duke@435 67 virtual void do_StoreIndexed (StoreIndexed* x);
duke@435 68 virtual void do_NegateOp (NegateOp* x);
duke@435 69 virtual void do_ArithmeticOp (ArithmeticOp* x);
duke@435 70 virtual void do_ShiftOp (ShiftOp* x);
duke@435 71 virtual void do_LogicOp (LogicOp* x);
duke@435 72 virtual void do_CompareOp (CompareOp* x);
duke@435 73 virtual void do_IfOp (IfOp* x);
duke@435 74 virtual void do_IfInstanceOf (IfInstanceOf* x);
duke@435 75 virtual void do_Convert (Convert* x);
duke@435 76 virtual void do_NullCheck (NullCheck* x);
twisti@3969 77 virtual void do_TypeCast (TypeCast* x);
duke@435 78 virtual void do_Invoke (Invoke* x);
duke@435 79 virtual void do_NewInstance (NewInstance* x);
duke@435 80 virtual void do_NewTypeArray (NewTypeArray* x);
duke@435 81 virtual void do_NewObjectArray (NewObjectArray* x);
duke@435 82 virtual void do_NewMultiArray (NewMultiArray* x);
duke@435 83 virtual void do_CheckCast (CheckCast* x);
duke@435 84 virtual void do_InstanceOf (InstanceOf* x);
duke@435 85 virtual void do_MonitorEnter (MonitorEnter* x);
duke@435 86 virtual void do_MonitorExit (MonitorExit* x);
duke@435 87 virtual void do_Intrinsic (Intrinsic* x);
duke@435 88 virtual void do_BlockBegin (BlockBegin* x);
duke@435 89 virtual void do_Goto (Goto* x);
duke@435 90 virtual void do_If (If* x);
duke@435 91 virtual void do_TableSwitch (TableSwitch* x);
duke@435 92 virtual void do_LookupSwitch (LookupSwitch* x);
duke@435 93 virtual void do_Return (Return* x);
duke@435 94 virtual void do_Throw (Throw* x);
duke@435 95 virtual void do_Base (Base* x);
duke@435 96 virtual void do_OsrEntry (OsrEntry* x);
duke@435 97 virtual void do_ExceptionObject(ExceptionObject* x);
duke@435 98 virtual void do_RoundFP (RoundFP* x);
duke@435 99 virtual void do_UnsafeGetRaw (UnsafeGetRaw* x);
duke@435 100 virtual void do_UnsafePutRaw (UnsafePutRaw* x);
duke@435 101 virtual void do_UnsafeGetObject(UnsafeGetObject* x);
duke@435 102 virtual void do_UnsafePutObject(UnsafePutObject* x);
roland@4106 103 virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x);
duke@435 104 virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x);
duke@435 105 virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x);
duke@435 106 virtual void do_ProfileCall (ProfileCall* x);
iveresov@2138 107 virtual void do_ProfileInvoke (ProfileInvoke* x);
never@2486 108 virtual void do_RuntimeCall (RuntimeCall* x);
jiangli@3592 109 virtual void do_MemBar (MemBar* x);
roland@4860 110 virtual void do_RangeCheckPredicate(RangeCheckPredicate* x);
roland@4860 111 virtual void do_Assert (Assert* x);
duke@435 112 };
stefank@2314 113
stefank@2314 114 #endif // SHARE_VM_C1_C1_CANONICALIZER_HPP

mercurial