Tue, 02 Sep 2014 12:48:45 -0700
8055494: Add C2 x86 intrinsic for BigInteger::multiplyToLen() method
Summary: Add new C2 intrinsic for BigInteger::multiplyToLen() on x86 in 64-bit VM.
Reviewed-by: roland
duke@435 | 1 | /* |
drchase@6943 | 2 | * Copyright (c) 1997, 2014, 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 | #include "precompiled.hpp" |
kvn@5110 | 26 | #include "opto/callnode.hpp" |
roland@5981 | 27 | #include "opto/cfgnode.hpp" |
stefank@2314 | 28 | #include "opto/matcher.hpp" |
rbackman@5791 | 29 | #include "opto/mathexactnode.hpp" |
stefank@2314 | 30 | #include "opto/multnode.hpp" |
stefank@2314 | 31 | #include "opto/opcodes.hpp" |
stefank@2314 | 32 | #include "opto/phaseX.hpp" |
stefank@2314 | 33 | #include "opto/regmask.hpp" |
stefank@2314 | 34 | #include "opto/type.hpp" |
duke@435 | 35 | |
duke@435 | 36 | //============================================================================= |
duke@435 | 37 | //------------------------------MultiNode-------------------------------------- |
duke@435 | 38 | const RegMask &MultiNode::out_RegMask() const { |
duke@435 | 39 | return RegMask::Empty; |
duke@435 | 40 | } |
duke@435 | 41 | |
duke@435 | 42 | Node *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); } |
duke@435 | 43 | |
duke@435 | 44 | //------------------------------proj_out--------------------------------------- |
duke@435 | 45 | // Get a named projection |
duke@435 | 46 | ProjNode* MultiNode::proj_out(uint which_proj) const { |
duke@435 | 47 | assert(Opcode() != Op_If || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0"); |
duke@435 | 48 | assert(Opcode() != Op_If || outcnt() == 2, "bad if #1"); |
duke@435 | 49 | for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) { |
duke@435 | 50 | Node *p = fast_out(i); |
rbackman@5791 | 51 | if (p->is_Proj()) { |
rbackman@5791 | 52 | ProjNode *proj = p->as_Proj(); |
rbackman@5791 | 53 | if (proj->_con == which_proj) { |
rbackman@5791 | 54 | assert(Opcode() != Op_If || proj->Opcode() == (which_proj?Op_IfTrue:Op_IfFalse), "bad if #2"); |
rbackman@5791 | 55 | return proj; |
rbackman@5791 | 56 | } |
rbackman@5791 | 57 | } else { |
duke@435 | 58 | assert(p == this && this->is_Start(), "else must be proj"); |
duke@435 | 59 | continue; |
duke@435 | 60 | } |
duke@435 | 61 | } |
duke@435 | 62 | return NULL; |
duke@435 | 63 | } |
duke@435 | 64 | |
duke@435 | 65 | //============================================================================= |
duke@435 | 66 | //------------------------------ProjNode--------------------------------------- |
duke@435 | 67 | uint ProjNode::hash() const { |
duke@435 | 68 | // only one input |
duke@435 | 69 | return (uintptr_t)in(TypeFunc::Control) + (_con << 1) + (_is_io_use ? 1 : 0); |
duke@435 | 70 | } |
duke@435 | 71 | uint ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; } |
duke@435 | 72 | uint ProjNode::size_of() const { return sizeof(ProjNode); } |
duke@435 | 73 | |
duke@435 | 74 | // Test if we propagate interesting control along this projection |
duke@435 | 75 | bool ProjNode::is_CFG() const { |
duke@435 | 76 | Node *def = in(0); |
duke@435 | 77 | return (_con == TypeFunc::Control && def->is_CFG()); |
duke@435 | 78 | } |
duke@435 | 79 | |
kvn@5110 | 80 | const Type* ProjNode::proj_type(const Type* t) const { |
kvn@5110 | 81 | if (t == Type::TOP) { |
kvn@5110 | 82 | return Type::TOP; |
kvn@5110 | 83 | } |
kvn@5110 | 84 | if (t == Type::BOTTOM) { |
kvn@5110 | 85 | return Type::BOTTOM; |
kvn@5110 | 86 | } |
kvn@5110 | 87 | t = t->is_tuple()->field_at(_con); |
kvn@5110 | 88 | Node* n = in(0); |
kvn@5110 | 89 | if ((_con == TypeFunc::Parms) && |
kvn@5110 | 90 | n->is_CallStaticJava() && n->as_CallStaticJava()->is_boxing_method()) { |
kvn@5110 | 91 | // The result of autoboxing is always non-null on normal path. |
roland@6313 | 92 | t = t->join_speculative(TypePtr::NOTNULL); |
kvn@5110 | 93 | } |
kvn@5110 | 94 | return t; |
kvn@5110 | 95 | } |
kvn@5110 | 96 | |
duke@435 | 97 | const Type *ProjNode::bottom_type() const { |
kvn@5110 | 98 | if (in(0) == NULL) return Type::TOP; |
kvn@5110 | 99 | return proj_type(in(0)->bottom_type()); |
duke@435 | 100 | } |
duke@435 | 101 | |
duke@435 | 102 | const TypePtr *ProjNode::adr_type() const { |
duke@435 | 103 | if (bottom_type() == Type::MEMORY) { |
duke@435 | 104 | // in(0) might be a narrow MemBar; otherwise we will report TypePtr::BOTTOM |
duke@435 | 105 | const TypePtr* adr_type = in(0)->adr_type(); |
duke@435 | 106 | #ifdef ASSERT |
duke@435 | 107 | if (!is_error_reported() && !Node::in_dump()) |
duke@435 | 108 | assert(adr_type != NULL, "source must have adr_type"); |
duke@435 | 109 | #endif |
duke@435 | 110 | return adr_type; |
duke@435 | 111 | } |
duke@435 | 112 | assert(bottom_type()->base() != Type::Memory, "no other memories?"); |
duke@435 | 113 | return NULL; |
duke@435 | 114 | } |
duke@435 | 115 | |
duke@435 | 116 | bool ProjNode::pinned() const { return in(0)->pinned(); } |
duke@435 | 117 | #ifndef PRODUCT |
duke@435 | 118 | void ProjNode::dump_spec(outputStream *st) const { st->print("#%d",_con); if(_is_io_use) st->print(" (i_o_use)");} |
duke@435 | 119 | #endif |
duke@435 | 120 | |
duke@435 | 121 | //----------------------------check_con---------------------------------------- |
duke@435 | 122 | void ProjNode::check_con() const { |
duke@435 | 123 | Node* n = in(0); |
duke@435 | 124 | if (n == NULL) return; // should be assert, but NodeHash makes bogons |
duke@435 | 125 | if (n->is_Mach()) return; // mach. projs. are not type-safe |
duke@435 | 126 | if (n->is_Start()) return; // alas, starts can have mach. projs. also |
duke@435 | 127 | if (_con == SCMemProjNode::SCMEMPROJCON ) return; |
duke@435 | 128 | const Type* t = n->bottom_type(); |
duke@435 | 129 | if (t == Type::TOP) return; // multi is dead |
duke@435 | 130 | assert(_con < t->is_tuple()->cnt(), "ProjNode::_con must be in range"); |
duke@435 | 131 | } |
duke@435 | 132 | |
duke@435 | 133 | //------------------------------Value------------------------------------------ |
duke@435 | 134 | const Type *ProjNode::Value( PhaseTransform *phase ) const { |
kvn@5110 | 135 | if (in(0) == NULL) return Type::TOP; |
kvn@5110 | 136 | return proj_type(phase->type(in(0))); |
duke@435 | 137 | } |
duke@435 | 138 | |
duke@435 | 139 | //------------------------------out_RegMask------------------------------------ |
duke@435 | 140 | // Pass the buck uphill |
duke@435 | 141 | const RegMask &ProjNode::out_RegMask() const { |
duke@435 | 142 | return RegMask::Empty; |
duke@435 | 143 | } |
duke@435 | 144 | |
duke@435 | 145 | //------------------------------ideal_reg-------------------------------------- |
duke@435 | 146 | uint ProjNode::ideal_reg() const { |
coleenp@4037 | 147 | return bottom_type()->ideal_reg(); |
duke@435 | 148 | } |
roland@5981 | 149 | |
roland@5981 | 150 | //-------------------------------is_uncommon_trap_proj---------------------------- |
roland@5981 | 151 | // Return true if proj is the form of "proj->[region->..]call_uct" |
roland@5981 | 152 | bool ProjNode::is_uncommon_trap_proj(Deoptimization::DeoptReason reason) { |
roland@5981 | 153 | int path_limit = 10; |
roland@5981 | 154 | Node* out = this; |
roland@5981 | 155 | for (int ct = 0; ct < path_limit; ct++) { |
roland@5981 | 156 | out = out->unique_ctrl_out(); |
roland@5981 | 157 | if (out == NULL) |
roland@5981 | 158 | return false; |
roland@5981 | 159 | if (out->is_CallStaticJava()) { |
roland@5981 | 160 | int req = out->as_CallStaticJava()->uncommon_trap_request(); |
roland@5981 | 161 | if (req != 0) { |
roland@5981 | 162 | Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req); |
roland@5981 | 163 | if (trap_reason == reason || reason == Deoptimization::Reason_none) { |
roland@5981 | 164 | return true; |
roland@5981 | 165 | } |
roland@5981 | 166 | } |
roland@5981 | 167 | return false; // don't do further after call |
roland@5981 | 168 | } |
roland@5981 | 169 | if (out->Opcode() != Op_Region) |
roland@5981 | 170 | return false; |
roland@5981 | 171 | } |
roland@5981 | 172 | return false; |
roland@5981 | 173 | } |
roland@5981 | 174 | |
roland@5981 | 175 | //-------------------------------is_uncommon_trap_if_pattern------------------------- |
roland@5981 | 176 | // Return true for "if(test)-> proj -> ... |
roland@5981 | 177 | // | |
roland@5981 | 178 | // V |
roland@5981 | 179 | // other_proj->[region->..]call_uct" |
roland@5981 | 180 | // |
roland@5981 | 181 | // "must_reason_predicate" means the uct reason must be Reason_predicate |
roland@5981 | 182 | bool ProjNode::is_uncommon_trap_if_pattern(Deoptimization::DeoptReason reason) { |
roland@5981 | 183 | Node *in0 = in(0); |
roland@5981 | 184 | if (!in0->is_If()) return false; |
roland@5981 | 185 | // Variation of a dead If node. |
roland@5981 | 186 | if (in0->outcnt() < 2) return false; |
roland@5981 | 187 | IfNode* iff = in0->as_If(); |
roland@5981 | 188 | |
roland@5981 | 189 | // we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate |
roland@5981 | 190 | if (reason != Deoptimization::Reason_none) { |
roland@5981 | 191 | if (iff->in(1)->Opcode() != Op_Conv2B || |
roland@5981 | 192 | iff->in(1)->in(1)->Opcode() != Op_Opaque1) { |
roland@5981 | 193 | return false; |
roland@5981 | 194 | } |
roland@5981 | 195 | } |
roland@5981 | 196 | |
drchase@6943 | 197 | ProjNode* other_proj = iff->proj_out(1-_con); |
drchase@6943 | 198 | if (other_proj == NULL) // Should never happen, but make Parfait happy. |
drchase@6943 | 199 | return false; |
roland@5981 | 200 | if (other_proj->is_uncommon_trap_proj(reason)) { |
roland@5981 | 201 | assert(reason == Deoptimization::Reason_none || |
roland@5981 | 202 | Compile::current()->is_predicate_opaq(iff->in(1)->in(1)), "should be on the list"); |
roland@5981 | 203 | return true; |
roland@5981 | 204 | } |
roland@5981 | 205 | return false; |
roland@5981 | 206 | } |