Mon, 25 May 2020 14:24:27 +0800
8244407: JVM crashes after transformation in C2 IdealLoopTree::split_fall_in
Reviewed-by: thartmann, kvn, andrew
Contributed-by: zhouyong44@huawei.com
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 1997, 2010, 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_OPTO_DIVNODE_HPP |
stefank@2314 | 26 | #define SHARE_VM_OPTO_DIVNODE_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "opto/multnode.hpp" |
stefank@2314 | 29 | #include "opto/node.hpp" |
stefank@2314 | 30 | #include "opto/opcodes.hpp" |
stefank@2314 | 31 | #include "opto/type.hpp" |
stefank@2314 | 32 | |
duke@435 | 33 | // Portions of code courtesy of Clifford Click |
duke@435 | 34 | |
duke@435 | 35 | // Optimization - Graph Style |
duke@435 | 36 | |
duke@435 | 37 | |
duke@435 | 38 | //------------------------------DivINode--------------------------------------- |
duke@435 | 39 | // Integer division |
duke@435 | 40 | // Note: this is division as defined by JVMS, i.e., MinInt/-1 == MinInt. |
duke@435 | 41 | // On processors which don't naturally support this special case (e.g., x86), |
duke@435 | 42 | // the matcher or runtime system must take care of this. |
duke@435 | 43 | class DivINode : public Node { |
duke@435 | 44 | public: |
duke@435 | 45 | DivINode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {} |
duke@435 | 46 | virtual int Opcode() const; |
duke@435 | 47 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 48 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 49 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 50 | virtual const Type *bottom_type() const { return TypeInt::INT; } |
duke@435 | 51 | virtual uint ideal_reg() const { return Op_RegI; } |
duke@435 | 52 | }; |
duke@435 | 53 | |
duke@435 | 54 | //------------------------------DivLNode--------------------------------------- |
duke@435 | 55 | // Long division |
duke@435 | 56 | class DivLNode : public Node { |
duke@435 | 57 | public: |
duke@435 | 58 | DivLNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor ) {} |
duke@435 | 59 | virtual int Opcode() const; |
duke@435 | 60 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 61 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 62 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 63 | virtual const Type *bottom_type() const { return TypeLong::LONG; } |
duke@435 | 64 | virtual uint ideal_reg() const { return Op_RegL; } |
duke@435 | 65 | }; |
duke@435 | 66 | |
duke@435 | 67 | //------------------------------DivFNode--------------------------------------- |
duke@435 | 68 | // Float division |
duke@435 | 69 | class DivFNode : public Node { |
duke@435 | 70 | public: |
duke@435 | 71 | DivFNode( Node *c, Node *dividend, Node *divisor ) : Node(c, dividend, divisor) {} |
duke@435 | 72 | virtual int Opcode() const; |
duke@435 | 73 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 74 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 75 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 76 | virtual const Type *bottom_type() const { return Type::FLOAT; } |
duke@435 | 77 | virtual uint ideal_reg() const { return Op_RegF; } |
duke@435 | 78 | }; |
duke@435 | 79 | |
duke@435 | 80 | //------------------------------DivDNode--------------------------------------- |
duke@435 | 81 | // Double division |
duke@435 | 82 | class DivDNode : public Node { |
duke@435 | 83 | public: |
duke@435 | 84 | DivDNode( Node *c, Node *dividend, Node *divisor ) : Node(c,dividend, divisor) {} |
duke@435 | 85 | virtual int Opcode() const; |
duke@435 | 86 | virtual Node *Identity( PhaseTransform *phase ); |
duke@435 | 87 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 88 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 89 | virtual const Type *bottom_type() const { return Type::DOUBLE; } |
duke@435 | 90 | virtual uint ideal_reg() const { return Op_RegD; } |
duke@435 | 91 | }; |
duke@435 | 92 | |
duke@435 | 93 | //------------------------------ModINode--------------------------------------- |
duke@435 | 94 | // Integer modulus |
duke@435 | 95 | class ModINode : public Node { |
duke@435 | 96 | public: |
duke@435 | 97 | ModINode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {} |
duke@435 | 98 | virtual int Opcode() const; |
duke@435 | 99 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 100 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 101 | virtual const Type *bottom_type() const { return TypeInt::INT; } |
duke@435 | 102 | virtual uint ideal_reg() const { return Op_RegI; } |
duke@435 | 103 | }; |
duke@435 | 104 | |
duke@435 | 105 | //------------------------------ModLNode--------------------------------------- |
duke@435 | 106 | // Long modulus |
duke@435 | 107 | class ModLNode : public Node { |
duke@435 | 108 | public: |
duke@435 | 109 | ModLNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {} |
duke@435 | 110 | virtual int Opcode() const; |
duke@435 | 111 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 112 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); |
duke@435 | 113 | virtual const Type *bottom_type() const { return TypeLong::LONG; } |
duke@435 | 114 | virtual uint ideal_reg() const { return Op_RegL; } |
duke@435 | 115 | }; |
duke@435 | 116 | |
duke@435 | 117 | //------------------------------ModFNode--------------------------------------- |
duke@435 | 118 | // Float Modulus |
duke@435 | 119 | class ModFNode : public Node { |
duke@435 | 120 | public: |
duke@435 | 121 | ModFNode( Node *c, Node *in1, Node *in2 ) : Node(c,in1, in2) {} |
duke@435 | 122 | virtual int Opcode() const; |
duke@435 | 123 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 124 | virtual const Type *bottom_type() const { return Type::FLOAT; } |
duke@435 | 125 | virtual uint ideal_reg() const { return Op_RegF; } |
duke@435 | 126 | }; |
duke@435 | 127 | |
duke@435 | 128 | //------------------------------ModDNode--------------------------------------- |
duke@435 | 129 | // Double Modulus |
duke@435 | 130 | class ModDNode : public Node { |
duke@435 | 131 | public: |
duke@435 | 132 | ModDNode( Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) {} |
duke@435 | 133 | virtual int Opcode() const; |
duke@435 | 134 | virtual const Type *Value( PhaseTransform *phase ) const; |
duke@435 | 135 | virtual const Type *bottom_type() const { return Type::DOUBLE; } |
duke@435 | 136 | virtual uint ideal_reg() const { return Op_RegD; } |
duke@435 | 137 | }; |
duke@435 | 138 | |
duke@435 | 139 | //------------------------------DivModNode--------------------------------------- |
duke@435 | 140 | // Division with remainder result. |
duke@435 | 141 | class DivModNode : public MultiNode { |
duke@435 | 142 | protected: |
duke@435 | 143 | DivModNode( Node *c, Node *dividend, Node *divisor ); |
duke@435 | 144 | public: |
duke@435 | 145 | enum { |
duke@435 | 146 | div_proj_num = 0, // quotient |
duke@435 | 147 | mod_proj_num = 1 // remainder |
duke@435 | 148 | }; |
duke@435 | 149 | virtual int Opcode() const; |
duke@435 | 150 | virtual Node *Identity( PhaseTransform *phase ) { return this; } |
duke@435 | 151 | virtual Node *Ideal(PhaseGVN *phase, bool can_reshape) { return NULL; } |
duke@435 | 152 | virtual const Type *Value( PhaseTransform *phase ) const { return bottom_type(); } |
duke@435 | 153 | virtual uint hash() const { return Node::hash(); } |
duke@435 | 154 | virtual bool is_CFG() const { return false; } |
duke@435 | 155 | virtual uint ideal_reg() const { return NotAMachineReg; } |
duke@435 | 156 | |
duke@435 | 157 | ProjNode* div_proj() { return proj_out(div_proj_num); } |
duke@435 | 158 | ProjNode* mod_proj() { return proj_out(mod_proj_num); } |
duke@435 | 159 | }; |
duke@435 | 160 | |
duke@435 | 161 | //------------------------------DivModINode--------------------------------------- |
duke@435 | 162 | // Integer division with remainder result. |
duke@435 | 163 | class DivModINode : public DivModNode { |
duke@435 | 164 | public: |
duke@435 | 165 | DivModINode( Node *c, Node *dividend, Node *divisor ) : DivModNode(c, dividend, divisor) {} |
duke@435 | 166 | virtual int Opcode() const; |
duke@435 | 167 | virtual const Type *bottom_type() const { return TypeTuple::INT_PAIR; } |
duke@435 | 168 | virtual Node *match( const ProjNode *proj, const Matcher *m ); |
duke@435 | 169 | |
duke@435 | 170 | // Make a divmod and associated projections from a div or mod. |
duke@435 | 171 | static DivModINode* make(Compile* C, Node* div_or_mod); |
duke@435 | 172 | }; |
duke@435 | 173 | |
duke@435 | 174 | //------------------------------DivModLNode--------------------------------------- |
duke@435 | 175 | // Long division with remainder result. |
duke@435 | 176 | class DivModLNode : public DivModNode { |
duke@435 | 177 | public: |
duke@435 | 178 | DivModLNode( Node *c, Node *dividend, Node *divisor ) : DivModNode(c, dividend, divisor) {} |
duke@435 | 179 | virtual int Opcode() const; |
duke@435 | 180 | virtual const Type *bottom_type() const { return TypeTuple::LONG_PAIR; } |
duke@435 | 181 | virtual Node *match( const ProjNode *proj, const Matcher *m ); |
duke@435 | 182 | |
duke@435 | 183 | // Make a divmod and associated projections from a div or mod. |
duke@435 | 184 | static DivModLNode* make(Compile* C, Node* div_or_mod); |
duke@435 | 185 | }; |
stefank@2314 | 186 | |
stefank@2314 | 187 | #endif // SHARE_VM_OPTO_DIVNODE_HPP |