src/share/vm/opto/multnode.cpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #include "precompiled.hpp"
aoqi@0 26 #include "opto/callnode.hpp"
aoqi@0 27 #include "opto/cfgnode.hpp"
aoqi@0 28 #include "opto/matcher.hpp"
aoqi@0 29 #include "opto/mathexactnode.hpp"
aoqi@0 30 #include "opto/multnode.hpp"
aoqi@0 31 #include "opto/opcodes.hpp"
aoqi@0 32 #include "opto/phaseX.hpp"
aoqi@0 33 #include "opto/regmask.hpp"
aoqi@0 34 #include "opto/type.hpp"
aoqi@0 35
aoqi@0 36 //=============================================================================
aoqi@0 37 //------------------------------MultiNode--------------------------------------
aoqi@0 38 const RegMask &MultiNode::out_RegMask() const {
aoqi@0 39 return RegMask::Empty;
aoqi@0 40 }
aoqi@0 41
aoqi@0 42 Node *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); }
aoqi@0 43
aoqi@0 44 //------------------------------proj_out---------------------------------------
aoqi@0 45 // Get a named projection
aoqi@0 46 ProjNode* MultiNode::proj_out(uint which_proj) const {
aoqi@0 47 assert(Opcode() != Op_If || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0");
aoqi@0 48 assert(Opcode() != Op_If || outcnt() == 2, "bad if #1");
aoqi@0 49 for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
aoqi@0 50 Node *p = fast_out(i);
aoqi@0 51 if (p->is_Proj()) {
aoqi@0 52 ProjNode *proj = p->as_Proj();
aoqi@0 53 if (proj->_con == which_proj) {
aoqi@0 54 assert(Opcode() != Op_If || proj->Opcode() == (which_proj?Op_IfTrue:Op_IfFalse), "bad if #2");
aoqi@0 55 return proj;
aoqi@0 56 }
aoqi@0 57 } else {
aoqi@0 58 assert(p == this && this->is_Start(), "else must be proj");
aoqi@0 59 continue;
aoqi@0 60 }
aoqi@0 61 }
aoqi@0 62 return NULL;
aoqi@0 63 }
aoqi@0 64
aoqi@0 65 //=============================================================================
aoqi@0 66 //------------------------------ProjNode---------------------------------------
aoqi@0 67 uint ProjNode::hash() const {
aoqi@0 68 // only one input
aoqi@0 69 return (uintptr_t)in(TypeFunc::Control) + (_con << 1) + (_is_io_use ? 1 : 0);
aoqi@0 70 }
aoqi@0 71 uint ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; }
aoqi@0 72 uint ProjNode::size_of() const { return sizeof(ProjNode); }
aoqi@0 73
aoqi@0 74 // Test if we propagate interesting control along this projection
aoqi@0 75 bool ProjNode::is_CFG() const {
aoqi@0 76 Node *def = in(0);
aoqi@0 77 return (_con == TypeFunc::Control && def->is_CFG());
aoqi@0 78 }
aoqi@0 79
aoqi@0 80 const Type* ProjNode::proj_type(const Type* t) const {
aoqi@0 81 if (t == Type::TOP) {
aoqi@0 82 return Type::TOP;
aoqi@0 83 }
aoqi@0 84 if (t == Type::BOTTOM) {
aoqi@0 85 return Type::BOTTOM;
aoqi@0 86 }
aoqi@0 87 t = t->is_tuple()->field_at(_con);
aoqi@0 88 Node* n = in(0);
aoqi@0 89 if ((_con == TypeFunc::Parms) &&
aoqi@0 90 n->is_CallStaticJava() && n->as_CallStaticJava()->is_boxing_method()) {
aoqi@0 91 // The result of autoboxing is always non-null on normal path.
aoqi@0 92 t = t->join_speculative(TypePtr::NOTNULL);
aoqi@0 93 }
aoqi@0 94 return t;
aoqi@0 95 }
aoqi@0 96
aoqi@0 97 const Type *ProjNode::bottom_type() const {
aoqi@0 98 if (in(0) == NULL) return Type::TOP;
aoqi@0 99 return proj_type(in(0)->bottom_type());
aoqi@0 100 }
aoqi@0 101
aoqi@0 102 const TypePtr *ProjNode::adr_type() const {
aoqi@0 103 if (bottom_type() == Type::MEMORY) {
aoqi@0 104 // in(0) might be a narrow MemBar; otherwise we will report TypePtr::BOTTOM
aoqi@0 105 const TypePtr* adr_type = in(0)->adr_type();
aoqi@0 106 #ifdef ASSERT
aoqi@0 107 if (!is_error_reported() && !Node::in_dump())
aoqi@0 108 assert(adr_type != NULL, "source must have adr_type");
aoqi@0 109 #endif
aoqi@0 110 return adr_type;
aoqi@0 111 }
aoqi@0 112 assert(bottom_type()->base() != Type::Memory, "no other memories?");
aoqi@0 113 return NULL;
aoqi@0 114 }
aoqi@0 115
aoqi@0 116 bool ProjNode::pinned() const { return in(0)->pinned(); }
aoqi@0 117 #ifndef PRODUCT
aoqi@0 118 void ProjNode::dump_spec(outputStream *st) const { st->print("#%d",_con); if(_is_io_use) st->print(" (i_o_use)");}
aoqi@0 119 #endif
aoqi@0 120
aoqi@0 121 //----------------------------check_con----------------------------------------
aoqi@0 122 void ProjNode::check_con() const {
aoqi@0 123 Node* n = in(0);
aoqi@0 124 if (n == NULL) return; // should be assert, but NodeHash makes bogons
aoqi@0 125 if (n->is_Mach()) return; // mach. projs. are not type-safe
aoqi@0 126 if (n->is_Start()) return; // alas, starts can have mach. projs. also
aoqi@0 127 if (_con == SCMemProjNode::SCMEMPROJCON ) return;
aoqi@0 128 const Type* t = n->bottom_type();
aoqi@0 129 if (t == Type::TOP) return; // multi is dead
aoqi@0 130 assert(_con < t->is_tuple()->cnt(), "ProjNode::_con must be in range");
aoqi@0 131 }
aoqi@0 132
aoqi@0 133 //------------------------------Value------------------------------------------
aoqi@0 134 const Type *ProjNode::Value( PhaseTransform *phase ) const {
aoqi@0 135 if (in(0) == NULL) return Type::TOP;
aoqi@0 136 return proj_type(phase->type(in(0)));
aoqi@0 137 }
aoqi@0 138
aoqi@0 139 //------------------------------out_RegMask------------------------------------
aoqi@0 140 // Pass the buck uphill
aoqi@0 141 const RegMask &ProjNode::out_RegMask() const {
aoqi@0 142 return RegMask::Empty;
aoqi@0 143 }
aoqi@0 144
aoqi@0 145 //------------------------------ideal_reg--------------------------------------
aoqi@0 146 uint ProjNode::ideal_reg() const {
aoqi@0 147 return bottom_type()->ideal_reg();
aoqi@0 148 }
aoqi@0 149
aoqi@0 150 //-------------------------------is_uncommon_trap_proj----------------------------
aoqi@0 151 // Return true if proj is the form of "proj->[region->..]call_uct"
aoqi@0 152 bool ProjNode::is_uncommon_trap_proj(Deoptimization::DeoptReason reason) {
aoqi@0 153 int path_limit = 10;
aoqi@0 154 Node* out = this;
aoqi@0 155 for (int ct = 0; ct < path_limit; ct++) {
aoqi@0 156 out = out->unique_ctrl_out();
aoqi@0 157 if (out == NULL)
aoqi@0 158 return false;
aoqi@0 159 if (out->is_CallStaticJava()) {
aoqi@0 160 int req = out->as_CallStaticJava()->uncommon_trap_request();
aoqi@0 161 if (req != 0) {
aoqi@0 162 Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req);
aoqi@0 163 if (trap_reason == reason || reason == Deoptimization::Reason_none) {
aoqi@0 164 return true;
aoqi@0 165 }
aoqi@0 166 }
aoqi@0 167 return false; // don't do further after call
aoqi@0 168 }
aoqi@0 169 if (out->Opcode() != Op_Region)
aoqi@0 170 return false;
aoqi@0 171 }
aoqi@0 172 return false;
aoqi@0 173 }
aoqi@0 174
aoqi@0 175 //-------------------------------is_uncommon_trap_if_pattern-------------------------
aoqi@0 176 // Return true for "if(test)-> proj -> ...
aoqi@0 177 // |
aoqi@0 178 // V
aoqi@0 179 // other_proj->[region->..]call_uct"
aoqi@0 180 //
aoqi@0 181 // "must_reason_predicate" means the uct reason must be Reason_predicate
aoqi@0 182 bool ProjNode::is_uncommon_trap_if_pattern(Deoptimization::DeoptReason reason) {
aoqi@0 183 Node *in0 = in(0);
aoqi@0 184 if (!in0->is_If()) return false;
aoqi@0 185 // Variation of a dead If node.
aoqi@0 186 if (in0->outcnt() < 2) return false;
aoqi@0 187 IfNode* iff = in0->as_If();
aoqi@0 188
aoqi@0 189 // we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate
aoqi@0 190 if (reason != Deoptimization::Reason_none) {
aoqi@0 191 if (iff->in(1)->Opcode() != Op_Conv2B ||
aoqi@0 192 iff->in(1)->in(1)->Opcode() != Op_Opaque1) {
aoqi@0 193 return false;
aoqi@0 194 }
aoqi@0 195 }
aoqi@0 196
aoqi@0 197 ProjNode* other_proj = iff->proj_out(1-_con)->as_Proj();
aoqi@0 198 if (other_proj->is_uncommon_trap_proj(reason)) {
aoqi@0 199 assert(reason == Deoptimization::Reason_none ||
aoqi@0 200 Compile::current()->is_predicate_opaq(iff->in(1)->in(1)), "should be on the list");
aoqi@0 201 return true;
aoqi@0 202 }
aoqi@0 203 return false;
aoqi@0 204 }

mercurial