annotate src/share/vm/opto/multnode.cpp @ 196:d1605aabd0a1 jdk7-b30

6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
author xdono
date Wed, 02 Jul 2008 12:55:16 -0700
parents a61af66fc99e
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_multnode.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
29 //------------------------------MultiNode--------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
30 const RegMask &MultiNode::out_RegMask() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 return RegMask::Empty;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 }
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 Node *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 //------------------------------proj_out---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // Get a named projection
a61af66fc99e Initial load
duke
parents:
diff changeset
38 ProjNode* MultiNode::proj_out(uint which_proj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
39 assert(Opcode() != Op_If || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0");
a61af66fc99e Initial load
duke
parents:
diff changeset
40 assert(Opcode() != Op_If || outcnt() == 2, "bad if #1");
a61af66fc99e Initial load
duke
parents:
diff changeset
41 for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 Node *p = fast_out(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
43 if( !p->is_Proj() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 assert(p == this && this->is_Start(), "else must be proj");
a61af66fc99e Initial load
duke
parents:
diff changeset
45 continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47 ProjNode *proj = p->as_Proj();
a61af66fc99e Initial load
duke
parents:
diff changeset
48 if( proj->_con == which_proj ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 assert(Opcode() != Op_If || proj->Opcode() == (which_proj?Op_IfTrue:Op_IfFalse), "bad if #2");
a61af66fc99e Initial load
duke
parents:
diff changeset
50 return proj;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
57 //------------------------------ProjNode---------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
58 uint ProjNode::hash() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // only one input
a61af66fc99e Initial load
duke
parents:
diff changeset
60 return (uintptr_t)in(TypeFunc::Control) + (_con << 1) + (_is_io_use ? 1 : 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 uint ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 uint ProjNode::size_of() const { return sizeof(ProjNode); }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // Test if we propagate interesting control along this projection
a61af66fc99e Initial load
duke
parents:
diff changeset
66 bool ProjNode::is_CFG() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 Node *def = in(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 return (_con == TypeFunc::Control && def->is_CFG());
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 const Type *ProjNode::bottom_type() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 if (in(0) == NULL) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 const Type *tb = in(0)->bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
74 if( tb == Type::TOP ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 if( tb == Type::BOTTOM ) return Type::BOTTOM;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 const TypeTuple *t = tb->is_tuple();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 return t->field_at(_con);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 const TypePtr *ProjNode::adr_type() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 if (bottom_type() == Type::MEMORY) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // in(0) might be a narrow MemBar; otherwise we will report TypePtr::BOTTOM
a61af66fc99e Initial load
duke
parents:
diff changeset
83 const TypePtr* adr_type = in(0)->adr_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
84 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if (!is_error_reported() && !Node::in_dump())
a61af66fc99e Initial load
duke
parents:
diff changeset
86 assert(adr_type != NULL, "source must have adr_type");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
88 return adr_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90 assert(bottom_type()->base() != Type::Memory, "no other memories?");
a61af66fc99e Initial load
duke
parents:
diff changeset
91 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 bool ProjNode::pinned() const { return in(0)->pinned(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
96 void ProjNode::dump_spec(outputStream *st) const { st->print("#%d",_con); if(_is_io_use) st->print(" (i_o_use)");}
a61af66fc99e Initial load
duke
parents:
diff changeset
97 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 //----------------------------check_con----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void ProjNode::check_con() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 Node* n = in(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if (n == NULL) return; // should be assert, but NodeHash makes bogons
a61af66fc99e Initial load
duke
parents:
diff changeset
103 if (n->is_Mach()) return; // mach. projs. are not type-safe
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (n->is_Start()) return; // alas, starts can have mach. projs. also
a61af66fc99e Initial load
duke
parents:
diff changeset
105 if (_con == SCMemProjNode::SCMEMPROJCON ) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 const Type* t = n->bottom_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 if (t == Type::TOP) return; // multi is dead
a61af66fc99e Initial load
duke
parents:
diff changeset
108 assert(_con < t->is_tuple()->cnt(), "ProjNode::_con must be in range");
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 //------------------------------Value------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
112 const Type *ProjNode::Value( PhaseTransform *phase ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 if( !in(0) ) return Type::TOP;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 const Type *t = phase->type(in(0));
a61af66fc99e Initial load
duke
parents:
diff changeset
115 if( t == Type::TOP ) return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 if( t == Type::BOTTOM ) return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 return t->is_tuple()->field_at(_con);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 //------------------------------out_RegMask------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // Pass the buck uphill
a61af66fc99e Initial load
duke
parents:
diff changeset
122 const RegMask &ProjNode::out_RegMask() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return RegMask::Empty;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 //------------------------------ideal_reg--------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
127 uint ProjNode::ideal_reg() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 return Matcher::base2reg[bottom_type()->base()];
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }