1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
26 #include "opto/callnode.hpp"
27 #include "opto/cfgnode.hpp"
28 #include "opto/matcher.hpp"
29 #include "opto/mathexactnode.hpp"
30 #include "opto/multnode.hpp"
31 #include "opto/opcodes.hpp"
32 #include "opto/phaseX.hpp"
33 #include "opto/regmask.hpp"
34 #include "opto/type.hpp"
35 #include "utilities/vmError.hpp"
36
37 //=============================================================================
38 //------------------------------MultiNode--------------------------------------
39 const RegMask &MultiNode::out_RegMask() const {
40 return RegMask::Empty;
41 }
42
43 Node *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); }
44
45 //------------------------------proj_out---------------------------------------
46 // Get a named projection
47 ProjNode* MultiNode::proj_out(uint which_proj) const {
48 assert((Opcode() != Op_If && Opcode() != Op_RangeCheck) || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0");
49 assert((Opcode() != Op_If && Opcode() != Op_RangeCheck) || outcnt() == 2, "bad if #1");
50 for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
51 Node *p = fast_out(i);
52 if (p->is_Proj()) {
53 ProjNode *proj = p->as_Proj();
54 if (proj->_con == which_proj) {
55 assert((Opcode() != Op_If && Opcode() != Op_RangeCheck) || proj->Opcode() == (which_proj ? Op_IfTrue : Op_IfFalse), "bad if #2");
56 return proj;
57 }
58 } else {
59 assert(p == this && this->is_Start(), "else must be proj");
60 continue;
61 }
62 }
63 return NULL;
64 }
65
66 //=============================================================================
67 //------------------------------ProjNode---------------------------------------
68 uint ProjNode::hash() const {
69 // only one input
70 return (uintptr_t)in(TypeFunc::Control) + (_con << 1) + (_is_io_use ? 1 : 0);
71 }
72 uint ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; }
73 uint ProjNode::size_of() const { return sizeof(ProjNode); }
74
75 // Test if we propagate interesting control along this projection
76 bool ProjNode::is_CFG() const {
77 Node *def = in(0);
78 return (_con == TypeFunc::Control && def->is_CFG());
79 }
80
81 const Type* ProjNode::proj_type(const Type* t) const {
82 if (t == Type::TOP) {
83 return Type::TOP;
84 }
85 if (t == Type::BOTTOM) {
197 // V
198 // other_proj->[region->..]call_uct"
199 // NULL otherwise
200 // "must_reason_predicate" means the uct reason must be Reason_predicate
201 CallStaticJavaNode* ProjNode::is_uncommon_trap_if_pattern(Deoptimization::DeoptReason reason) {
202 Node *in0 = in(0);
203 if (!in0->is_If()) return NULL;
204 // Variation of a dead If node.
205 if (in0->outcnt() < 2) return NULL;
206 IfNode* iff = in0->as_If();
207
208 // we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate
209 if (reason != Deoptimization::Reason_none) {
210 if (iff->in(1)->Opcode() != Op_Conv2B ||
211 iff->in(1)->in(1)->Opcode() != Op_Opaque1) {
212 return NULL;
213 }
214 }
215
216 ProjNode* other_proj = iff->proj_out(1-_con);
217 if (other_proj == NULL) // Should never happen, but make Parfait happy.
218 return NULL;
219 CallStaticJavaNode* call = other_proj->is_uncommon_trap_proj(reason);
220 if (call != NULL) {
221 assert(reason == Deoptimization::Reason_none ||
222 Compile::current()->is_predicate_opaq(iff->in(1)->in(1)), "should be on the list");
223 return call;
224 }
225 return NULL;
226 }
227
228 ProjNode* ProjNode::other_if_proj() const {
229 assert(_con == 0 || _con == 1, "not an if?");
230 return in(0)->as_If()->proj_out(1-_con);
231 }
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
26 #include "opto/callnode.hpp"
27 #include "opto/cfgnode.hpp"
28 #include "opto/matcher.hpp"
29 #include "opto/mathexactnode.hpp"
30 #include "opto/multnode.hpp"
31 #include "opto/opcodes.hpp"
32 #include "opto/phaseX.hpp"
33 #include "opto/regmask.hpp"
34 #include "opto/type.hpp"
35 #include "utilities/vmError.hpp"
36
37 //=============================================================================
38 //------------------------------MultiNode--------------------------------------
39 const RegMask &MultiNode::out_RegMask() const {
40 return RegMask::Empty;
41 }
42
43 Node *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); }
44
45 //------------------------------proj_out---------------------------------------
46 // Get a named projection or null if not found
47 ProjNode* MultiNode::proj_out_or_null(uint which_proj) const {
48 assert((Opcode() != Op_If && Opcode() != Op_RangeCheck) || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0");
49 assert((Opcode() != Op_If && Opcode() != Op_RangeCheck) || outcnt() == 2, "bad if #1");
50 for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
51 Node *p = fast_out(i);
52 if (p->is_Proj()) {
53 ProjNode *proj = p->as_Proj();
54 if (proj->_con == which_proj) {
55 assert((Opcode() != Op_If && Opcode() != Op_RangeCheck) || proj->Opcode() == (which_proj ? Op_IfTrue : Op_IfFalse), "bad if #2");
56 return proj;
57 }
58 } else {
59 assert(p == this && this->is_Start(), "else must be proj");
60 continue;
61 }
62 }
63 return NULL;
64 }
65
66 // Get a named projection
67 ProjNode* MultiNode::proj_out(uint which_proj) const {
68 ProjNode* p = proj_out_or_null(which_proj);
69 assert(p != NULL, "named projection %u not found", which_proj);
70 return p;
71 }
72
73 //=============================================================================
74 //------------------------------ProjNode---------------------------------------
75 uint ProjNode::hash() const {
76 // only one input
77 return (uintptr_t)in(TypeFunc::Control) + (_con << 1) + (_is_io_use ? 1 : 0);
78 }
79 uint ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; }
80 uint ProjNode::size_of() const { return sizeof(ProjNode); }
81
82 // Test if we propagate interesting control along this projection
83 bool ProjNode::is_CFG() const {
84 Node *def = in(0);
85 return (_con == TypeFunc::Control && def->is_CFG());
86 }
87
88 const Type* ProjNode::proj_type(const Type* t) const {
89 if (t == Type::TOP) {
90 return Type::TOP;
91 }
92 if (t == Type::BOTTOM) {
204 // V
205 // other_proj->[region->..]call_uct"
206 // NULL otherwise
207 // "must_reason_predicate" means the uct reason must be Reason_predicate
208 CallStaticJavaNode* ProjNode::is_uncommon_trap_if_pattern(Deoptimization::DeoptReason reason) {
209 Node *in0 = in(0);
210 if (!in0->is_If()) return NULL;
211 // Variation of a dead If node.
212 if (in0->outcnt() < 2) return NULL;
213 IfNode* iff = in0->as_If();
214
215 // we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate
216 if (reason != Deoptimization::Reason_none) {
217 if (iff->in(1)->Opcode() != Op_Conv2B ||
218 iff->in(1)->in(1)->Opcode() != Op_Opaque1) {
219 return NULL;
220 }
221 }
222
223 ProjNode* other_proj = iff->proj_out(1-_con);
224 CallStaticJavaNode* call = other_proj->is_uncommon_trap_proj(reason);
225 if (call != NULL) {
226 assert(reason == Deoptimization::Reason_none ||
227 Compile::current()->is_predicate_opaq(iff->in(1)->in(1)), "should be on the list");
228 return call;
229 }
230 return NULL;
231 }
232
233 ProjNode* ProjNode::other_if_proj() const {
234 assert(_con == 0 || _con == 1, "not an if?");
235 return in(0)->as_If()->proj_out(1-_con);
236 }
|