2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2015-03-18 16:16:30 +01:00
|
|
|
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
2013-05-08 15:08:01 -07:00
|
|
|
#include "opto/callnode.hpp"
|
2013-10-19 12:16:43 +02:00
|
|
|
#include "opto/cfgnode.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "opto/matcher.hpp"
|
2013-09-27 08:39:19 +02:00
|
|
|
#include "opto/mathexactnode.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "opto/multnode.hpp"
|
|
|
|
#include "opto/opcodes.hpp"
|
|
|
|
#include "opto/phaseX.hpp"
|
|
|
|
#include "opto/regmask.hpp"
|
|
|
|
#include "opto/type.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//------------------------------MultiNode--------------------------------------
|
|
|
|
const RegMask &MultiNode::out_RegMask() const {
|
|
|
|
return RegMask::Empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
Node *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); }
|
|
|
|
|
|
|
|
//------------------------------proj_out---------------------------------------
|
|
|
|
// Get a named projection
|
|
|
|
ProjNode* MultiNode::proj_out(uint which_proj) const {
|
2015-11-09 11:28:31 +01:00
|
|
|
assert((Opcode() != Op_If && Opcode() != Op_RangeCheck) || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0");
|
|
|
|
assert((Opcode() != Op_If && Opcode() != Op_RangeCheck) || outcnt() == 2, "bad if #1");
|
2007-12-01 00:00:00 +00:00
|
|
|
for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
|
|
|
|
Node *p = fast_out(i);
|
2013-09-27 08:39:19 +02:00
|
|
|
if (p->is_Proj()) {
|
|
|
|
ProjNode *proj = p->as_Proj();
|
|
|
|
if (proj->_con == which_proj) {
|
2015-11-09 11:28:31 +01:00
|
|
|
assert((Opcode() != Op_If && Opcode() != Op_RangeCheck) || proj->Opcode() == (which_proj ? Op_IfTrue : Op_IfFalse), "bad if #2");
|
2013-09-27 08:39:19 +02:00
|
|
|
return proj;
|
|
|
|
}
|
|
|
|
} else {
|
2007-12-01 00:00:00 +00:00
|
|
|
assert(p == this && this->is_Start(), "else must be proj");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
//------------------------------ProjNode---------------------------------------
|
|
|
|
uint ProjNode::hash() const {
|
|
|
|
// only one input
|
|
|
|
return (uintptr_t)in(TypeFunc::Control) + (_con << 1) + (_is_io_use ? 1 : 0);
|
|
|
|
}
|
|
|
|
uint ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; }
|
|
|
|
uint ProjNode::size_of() const { return sizeof(ProjNode); }
|
|
|
|
|
|
|
|
// Test if we propagate interesting control along this projection
|
|
|
|
bool ProjNode::is_CFG() const {
|
|
|
|
Node *def = in(0);
|
|
|
|
return (_con == TypeFunc::Control && def->is_CFG());
|
|
|
|
}
|
|
|
|
|
2013-05-08 15:08:01 -07:00
|
|
|
const Type* ProjNode::proj_type(const Type* t) const {
|
|
|
|
if (t == Type::TOP) {
|
|
|
|
return Type::TOP;
|
|
|
|
}
|
|
|
|
if (t == Type::BOTTOM) {
|
|
|
|
return Type::BOTTOM;
|
|
|
|
}
|
|
|
|
t = t->is_tuple()->field_at(_con);
|
|
|
|
Node* n = in(0);
|
|
|
|
if ((_con == TypeFunc::Parms) &&
|
|
|
|
n->is_CallStaticJava() && n->as_CallStaticJava()->is_boxing_method()) {
|
|
|
|
// The result of autoboxing is always non-null on normal path.
|
2014-01-24 09:31:53 +01:00
|
|
|
t = t->join_speculative(TypePtr::NOTNULL);
|
2013-05-08 15:08:01 -07:00
|
|
|
}
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
const Type *ProjNode::bottom_type() const {
|
2013-05-08 15:08:01 -07:00
|
|
|
if (in(0) == NULL) return Type::TOP;
|
|
|
|
return proj_type(in(0)->bottom_type());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const TypePtr *ProjNode::adr_type() const {
|
|
|
|
if (bottom_type() == Type::MEMORY) {
|
|
|
|
// in(0) might be a narrow MemBar; otherwise we will report TypePtr::BOTTOM
|
2014-11-17 14:02:45 -08:00
|
|
|
Node* ctrl = in(0);
|
|
|
|
if (ctrl == NULL) return NULL; // node is dead
|
|
|
|
const TypePtr* adr_type = ctrl->adr_type();
|
2007-12-01 00:00:00 +00:00
|
|
|
#ifdef ASSERT
|
|
|
|
if (!is_error_reported() && !Node::in_dump())
|
|
|
|
assert(adr_type != NULL, "source must have adr_type");
|
|
|
|
#endif
|
|
|
|
return adr_type;
|
|
|
|
}
|
|
|
|
assert(bottom_type()->base() != Type::Memory, "no other memories?");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ProjNode::pinned() const { return in(0)->pinned(); }
|
|
|
|
#ifndef PRODUCT
|
|
|
|
void ProjNode::dump_spec(outputStream *st) const { st->print("#%d",_con); if(_is_io_use) st->print(" (i_o_use)");}
|
2015-03-18 16:16:30 +01:00
|
|
|
|
|
|
|
void ProjNode::dump_compact_spec(outputStream *st) const {
|
|
|
|
for (DUIterator i = this->outs(); this->has_out(i); i++) {
|
|
|
|
Node* o = this->out(i);
|
|
|
|
if (NotANode(o)) {
|
|
|
|
st->print("[?]");
|
|
|
|
} else if (o == NULL) {
|
|
|
|
st->print("[_]");
|
|
|
|
} else {
|
|
|
|
st->print("[%d]", o->_idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
st->print("#%d", _con);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//----------------------------check_con----------------------------------------
|
|
|
|
void ProjNode::check_con() const {
|
|
|
|
Node* n = in(0);
|
|
|
|
if (n == NULL) return; // should be assert, but NodeHash makes bogons
|
|
|
|
if (n->is_Mach()) return; // mach. projs. are not type-safe
|
|
|
|
if (n->is_Start()) return; // alas, starts can have mach. projs. also
|
|
|
|
if (_con == SCMemProjNode::SCMEMPROJCON ) return;
|
|
|
|
const Type* t = n->bottom_type();
|
|
|
|
if (t == Type::TOP) return; // multi is dead
|
|
|
|
assert(_con < t->is_tuple()->cnt(), "ProjNode::_con must be in range");
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------Value------------------------------------------
|
2016-01-12 12:55:09 +01:00
|
|
|
const Type* ProjNode::Value(PhaseGVN* phase) const {
|
2013-05-08 15:08:01 -07:00
|
|
|
if (in(0) == NULL) return Type::TOP;
|
|
|
|
return proj_type(phase->type(in(0)));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------out_RegMask------------------------------------
|
|
|
|
// Pass the buck uphill
|
|
|
|
const RegMask &ProjNode::out_RegMask() const {
|
|
|
|
return RegMask::Empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------ideal_reg--------------------------------------
|
|
|
|
uint ProjNode::ideal_reg() const {
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
return bottom_type()->ideal_reg();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2013-10-19 12:16:43 +02:00
|
|
|
|
|
|
|
//-------------------------------is_uncommon_trap_proj----------------------------
|
2015-03-17 10:06:31 +01:00
|
|
|
// Return uncommon trap call node if proj is for "proj->[region->..]call_uct"
|
|
|
|
// NULL otherwise
|
|
|
|
CallStaticJavaNode* ProjNode::is_uncommon_trap_proj(Deoptimization::DeoptReason reason) {
|
2013-10-19 12:16:43 +02:00
|
|
|
int path_limit = 10;
|
|
|
|
Node* out = this;
|
|
|
|
for (int ct = 0; ct < path_limit; ct++) {
|
|
|
|
out = out->unique_ctrl_out();
|
|
|
|
if (out == NULL)
|
2015-03-17 10:06:31 +01:00
|
|
|
return NULL;
|
2013-10-19 12:16:43 +02:00
|
|
|
if (out->is_CallStaticJava()) {
|
2015-03-17 10:06:31 +01:00
|
|
|
CallStaticJavaNode* call = out->as_CallStaticJava();
|
|
|
|
int req = call->uncommon_trap_request();
|
2013-10-19 12:16:43 +02:00
|
|
|
if (req != 0) {
|
|
|
|
Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req);
|
|
|
|
if (trap_reason == reason || reason == Deoptimization::Reason_none) {
|
2015-03-17 10:06:31 +01:00
|
|
|
return call;
|
2013-10-19 12:16:43 +02:00
|
|
|
}
|
|
|
|
}
|
2015-03-17 10:06:31 +01:00
|
|
|
return NULL; // don't do further after call
|
2013-10-19 12:16:43 +02:00
|
|
|
}
|
|
|
|
if (out->Opcode() != Op_Region)
|
2015-03-17 10:06:31 +01:00
|
|
|
return NULL;
|
2013-10-19 12:16:43 +02:00
|
|
|
}
|
2015-03-17 10:06:31 +01:00
|
|
|
return NULL;
|
2013-10-19 12:16:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------is_uncommon_trap_if_pattern-------------------------
|
2015-03-17 10:06:31 +01:00
|
|
|
// Return uncommon trap call node for "if(test)-> proj -> ...
|
|
|
|
// |
|
|
|
|
// V
|
|
|
|
// other_proj->[region->..]call_uct"
|
|
|
|
// NULL otherwise
|
2013-10-19 12:16:43 +02:00
|
|
|
// "must_reason_predicate" means the uct reason must be Reason_predicate
|
2015-03-17 10:06:31 +01:00
|
|
|
CallStaticJavaNode* ProjNode::is_uncommon_trap_if_pattern(Deoptimization::DeoptReason reason) {
|
2013-10-19 12:16:43 +02:00
|
|
|
Node *in0 = in(0);
|
2015-03-17 10:06:31 +01:00
|
|
|
if (!in0->is_If()) return NULL;
|
2013-10-19 12:16:43 +02:00
|
|
|
// Variation of a dead If node.
|
2015-03-17 10:06:31 +01:00
|
|
|
if (in0->outcnt() < 2) return NULL;
|
2013-10-19 12:16:43 +02:00
|
|
|
IfNode* iff = in0->as_If();
|
|
|
|
|
|
|
|
// we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate
|
|
|
|
if (reason != Deoptimization::Reason_none) {
|
|
|
|
if (iff->in(1)->Opcode() != Op_Conv2B ||
|
|
|
|
iff->in(1)->in(1)->Opcode() != Op_Opaque1) {
|
2015-03-17 10:06:31 +01:00
|
|
|
return NULL;
|
2013-10-19 12:16:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-11 13:38:32 -04:00
|
|
|
ProjNode* other_proj = iff->proj_out(1-_con);
|
|
|
|
if (other_proj == NULL) // Should never happen, but make Parfait happy.
|
2015-03-17 10:06:31 +01:00
|
|
|
return NULL;
|
|
|
|
CallStaticJavaNode* call = other_proj->is_uncommon_trap_proj(reason);
|
|
|
|
if (call != NULL) {
|
2013-10-19 12:16:43 +02:00
|
|
|
assert(reason == Deoptimization::Reason_none ||
|
|
|
|
Compile::current()->is_predicate_opaq(iff->in(1)->in(1)), "should be on the list");
|
2015-03-17 10:06:31 +01:00
|
|
|
return call;
|
2013-10-19 12:16:43 +02:00
|
|
|
}
|
2015-03-17 10:06:31 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProjNode* ProjNode::other_if_proj() const {
|
|
|
|
assert(_con == 0 || _con == 1, "not an if?");
|
|
|
|
return in(0)->as_If()->proj_out(1-_con);
|
2013-10-19 12:16:43 +02:00
|
|
|
}
|