src/share/vm/opto/idealKit.cpp

Fri, 11 Mar 2011 07:50:51 -0800

author
kvn
date
Fri, 11 Mar 2011 07:50:51 -0800
changeset 2636
83f08886981c
parent 2314
f95d63e2154a
child 2665
9dc311b8473e
permissions
-rw-r--r--

7026631: field _klass is incorrectly set for dual type of TypeAryPtr::OOPS
Summary: add missing check this->dual() != TypeAryPtr::OOPS into TypeAryPtr::klass().
Reviewed-by: never

duke@435 1 /*
stefank@2314 2 * Copyright (c) 2005, 2010, 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"
stefank@2314 26 #include "opto/addnode.hpp"
stefank@2314 27 #include "opto/callnode.hpp"
stefank@2314 28 #include "opto/cfgnode.hpp"
stefank@2314 29 #include "opto/idealKit.hpp"
stefank@2314 30 #include "opto/runtime.hpp"
duke@435 31
duke@435 32 // Static initialization
duke@435 33
duke@435 34 // This declares the position where vars are kept in the cvstate
duke@435 35 // For some degree of consistency we use the TypeFunc enum to
duke@435 36 // soak up spots in the inputs even though we only use early Control
duke@435 37 // and Memory slots. (So far.)
duke@435 38 const uint IdealKit::first_var = TypeFunc::Parms + 1;
duke@435 39
duke@435 40 //----------------------------IdealKit-----------------------------------------
kvn@1286 41 IdealKit::IdealKit(PhaseGVN &gvn, Node* control, Node* mem, bool delay_all_transforms, bool has_declarations) :
duke@435 42 _gvn(gvn), C(gvn.C) {
duke@435 43 _initial_ctrl = control;
duke@435 44 _initial_memory = mem;
duke@435 45 _delay_all_transforms = delay_all_transforms;
duke@435 46 _var_ct = 0;
duke@435 47 _cvstate = NULL;
duke@435 48 // We can go memory state free or else we need the entire memory state
duke@435 49 assert(mem == NULL || mem->Opcode() == Op_MergeMem, "memory must be pre-split");
duke@435 50 int init_size = 5;
duke@435 51 _pending_cvstates = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0);
duke@435 52 _delay_transform = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0);
duke@435 53 DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray<int>(C->node_arena(), init_size, 0, 0));
kvn@1286 54 if (!has_declarations) {
kvn@1286 55 declarations_done();
kvn@1286 56 }
duke@435 57 }
duke@435 58
duke@435 59 //-------------------------------if_then-------------------------------------
duke@435 60 // Create: if(left relop right)
duke@435 61 // / \
duke@435 62 // iffalse iftrue
duke@435 63 // Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate.
duke@435 64 void IdealKit::if_then(Node* left, BoolTest::mask relop,
duke@435 65 Node* right, float prob, float cnt, bool push_new_state) {
duke@435 66 assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new If");
duke@435 67 Node* bol;
duke@435 68 if (left->bottom_type()->isa_ptr() == NULL) {
duke@435 69 if (left->bottom_type()->isa_int() != NULL) {
duke@435 70 bol = Bool(CmpI(left, right), relop);
duke@435 71 } else {
duke@435 72 assert(left->bottom_type()->isa_long() != NULL, "what else?");
duke@435 73 bol = Bool(CmpL(left, right), relop);
duke@435 74 }
duke@435 75
duke@435 76 } else {
duke@435 77 bol = Bool(CmpP(left, right), relop);
duke@435 78 }
duke@435 79 // Delay gvn.tranform on if-nodes until construction is finished
duke@435 80 // to prevent a constant bool input from discarding a control output.
duke@435 81 IfNode* iff = delay_transform(new (C, 2) IfNode(ctrl(), bol, prob, cnt))->as_If();
duke@435 82 Node* then = IfTrue(iff);
duke@435 83 Node* elsen = IfFalse(iff);
duke@435 84 Node* else_cvstate = copy_cvstate();
duke@435 85 else_cvstate->set_req(TypeFunc::Control, elsen);
duke@435 86 _pending_cvstates->push(else_cvstate);
duke@435 87 DEBUG_ONLY(if (push_new_state) _state->push(IfThenS));
duke@435 88 set_ctrl(then);
duke@435 89 }
duke@435 90
duke@435 91 //-------------------------------else_-------------------------------------
duke@435 92 // Pop the else cvstate off the stack, and push the (current) then cvstate.
duke@435 93 // The else cvstate becomes the current cvstate.
duke@435 94 void IdealKit::else_() {
duke@435 95 assert(state() == IfThenS, "bad state for new Else");
duke@435 96 Node* else_cvstate = _pending_cvstates->pop();
duke@435 97 DEBUG_ONLY(_state->pop());
duke@435 98 // save current (then) cvstate for later use at endif
duke@435 99 _pending_cvstates->push(_cvstate);
duke@435 100 DEBUG_ONLY(_state->push(ElseS));
duke@435 101 _cvstate = else_cvstate;
duke@435 102 }
duke@435 103
duke@435 104 //-------------------------------end_if-------------------------------------
duke@435 105 // Merge the "then" and "else" cvstates.
duke@435 106 //
kvn@1286 107 // The if_then() pushed a copy of the current state for later use
duke@435 108 // as the initial state for a future "else" clause. The
duke@435 109 // current state then became the initial state for the
duke@435 110 // then clause. If an "else" clause was encountered, it will
duke@435 111 // pop the top state and use it for it's initial state.
duke@435 112 // It will also push the current state (the state at the end of
duke@435 113 // the "then" clause) for latter use at the end_if.
duke@435 114 //
duke@435 115 // At the endif, the states are:
duke@435 116 // 1) else exists a) current state is end of "else" clause
duke@435 117 // b) top stack state is end of "then" clause
duke@435 118 //
duke@435 119 // 2) no else: a) current state is end of "then" clause
duke@435 120 // b) top stack state is from the "if_then" which
duke@435 121 // would have been the initial state of the else.
duke@435 122 //
duke@435 123 // Merging the states is accomplished by:
duke@435 124 // 1) make a label for the merge
duke@435 125 // 2) terminate the current state with a goto to the label
duke@435 126 // 3) pop the top state from the stack and make it the
duke@435 127 // current state
duke@435 128 // 4) bind the label at the current state. Binding a label
duke@435 129 // terminates the current state with a goto to the
duke@435 130 // label and makes the label's state the current state.
duke@435 131 //
duke@435 132 void IdealKit::end_if() {
duke@435 133 assert(state() & (IfThenS|ElseS), "bad state for new Endif");
duke@435 134 Node* lab = make_label(1);
duke@435 135
duke@435 136 // Node* join_state = _pending_cvstates->pop();
duke@435 137 /* merging, join */
duke@435 138 goto_(lab);
duke@435 139 _cvstate = _pending_cvstates->pop();
duke@435 140
duke@435 141 bind(lab);
duke@435 142 DEBUG_ONLY(_state->pop());
duke@435 143 }
duke@435 144
duke@435 145 //-------------------------------loop-------------------------------------
duke@435 146 // Create the loop head portion (*) of:
duke@435 147 // * iv = init
duke@435 148 // * top: (region node)
duke@435 149 // * if (iv relop limit) {
duke@435 150 // loop body
duke@435 151 // i = i + 1
duke@435 152 // goto top
duke@435 153 // * } else // exits loop
duke@435 154 //
duke@435 155 // Pushes the loop top cvstate first, then the else (loop exit) cvstate
duke@435 156 // onto the stack.
duke@435 157 void IdealKit::loop(IdealVariable& iv, Node* init, BoolTest::mask relop, Node* limit, float prob, float cnt) {
duke@435 158 assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new loop");
duke@435 159 set(iv, init);
duke@435 160 Node* head = make_label(1);
duke@435 161 bind(head);
duke@435 162 _pending_cvstates->push(head); // push for use at end_loop
duke@435 163 _cvstate = copy_cvstate();
duke@435 164 if_then(value(iv), relop, limit, prob, cnt, false /* no new state */);
duke@435 165 DEBUG_ONLY(_state->push(LoopS));
duke@435 166 assert(ctrl()->is_IfTrue(), "true branch stays in loop");
duke@435 167 assert(_pending_cvstates->top()->in(TypeFunc::Control)->is_IfFalse(), "false branch exits loop");
duke@435 168 }
duke@435 169
duke@435 170 //-------------------------------end_loop-------------------------------------
duke@435 171 // Creates the goto top label.
duke@435 172 // Expects the else (loop exit) cvstate to be on top of the
duke@435 173 // stack, and the loop top cvstate to be 2nd.
duke@435 174 void IdealKit::end_loop() {
duke@435 175 assert((state() == LoopS), "bad state for new end_loop");
duke@435 176 Node* exit = _pending_cvstates->pop();
duke@435 177 Node* head = _pending_cvstates->pop();
duke@435 178 goto_(head);
duke@435 179 clear(head);
duke@435 180 DEBUG_ONLY(_state->pop());
duke@435 181 _cvstate = exit;
duke@435 182 }
duke@435 183
duke@435 184 //-------------------------------make_label-------------------------------------
duke@435 185 // Creates a label. The number of goto's
duke@435 186 // must be specified (which should be 1 less than
duke@435 187 // the number of precedessors.)
duke@435 188 Node* IdealKit::make_label(int goto_ct) {
duke@435 189 assert(_cvstate != NULL, "must declare variables before labels");
duke@435 190 Node* lab = new_cvstate();
duke@435 191 int sz = 1 + goto_ct + 1 /* fall thru */;
duke@435 192 Node* reg = delay_transform(new (C, sz) RegionNode(sz));
duke@435 193 lab->init_req(TypeFunc::Control, reg);
duke@435 194 return lab;
duke@435 195 }
duke@435 196
duke@435 197 //-------------------------------bind-------------------------------------
duke@435 198 // Bind a label at the current cvstate by simulating
duke@435 199 // a goto to the label.
duke@435 200 void IdealKit::bind(Node* lab) {
duke@435 201 goto_(lab, true /* bind */);
duke@435 202 _cvstate = lab;
duke@435 203 }
duke@435 204
duke@435 205 //-------------------------------goto_-------------------------------------
duke@435 206 // Make the current cvstate a predecessor of the label,
duke@435 207 // creating phi's to merge values. If bind is true and
duke@435 208 // this is not the last control edge, then ensure that
duke@435 209 // all live values have phis created. Used to create phis
duke@435 210 // at loop-top regions.
duke@435 211 void IdealKit::goto_(Node* lab, bool bind) {
duke@435 212 Node* reg = lab->in(TypeFunc::Control);
duke@435 213 // find next empty slot in region
duke@435 214 uint slot = 1;
duke@435 215 while (slot < reg->req() && reg->in(slot) != NULL) slot++;
duke@435 216 assert(slot < reg->req(), "too many gotos");
duke@435 217 // If this is last predecessor, then don't force phi creation
duke@435 218 if (slot == reg->req() - 1) bind = false;
duke@435 219 reg->init_req(slot, ctrl());
duke@435 220 assert(first_var + _var_ct == _cvstate->req(), "bad _cvstate size");
duke@435 221 for (uint i = first_var; i < _cvstate->req(); i++) {
duke@435 222
duke@435 223 // l is the value of var reaching the label. Could be a single value
duke@435 224 // reaching the label, or a phi that merges multiples values reaching
duke@435 225 // the label. The latter is true if the label's input: in(..) is
duke@435 226 // a phi whose control input is the region node for the label.
duke@435 227
duke@435 228 Node* l = lab->in(i);
duke@435 229 // Get the current value of the var
duke@435 230 Node* m = _cvstate->in(i);
duke@435 231 // If the var went unused no need for a phi
duke@435 232 if (m == NULL) {
duke@435 233 continue;
duke@435 234 } else if (l == NULL || m == l) {
duke@435 235 // Only one unique value "m" is known to reach this label so a phi
duke@435 236 // is not yet necessary unless:
duke@435 237 // the label is being bound and all predecessors have not been seen,
duke@435 238 // in which case "bind" will be true.
duke@435 239 if (bind) {
duke@435 240 m = promote_to_phi(m, reg);
duke@435 241 }
duke@435 242 // Record the phi/value used for this var in the label's cvstate
duke@435 243 lab->set_req(i, m);
duke@435 244 } else {
duke@435 245 // More than one value for the variable reaches this label so
duke@435 246 // a create a phi if one does not already exist.
duke@435 247 if (!was_promoted_to_phi(l, reg)) {
duke@435 248 l = promote_to_phi(l, reg);
duke@435 249 lab->set_req(i, l);
duke@435 250 }
duke@435 251 // Record in the phi, the var's value from the current state
duke@435 252 l->set_req(slot, m);
duke@435 253 }
duke@435 254 }
duke@435 255 do_memory_merge(_cvstate, lab);
duke@435 256 stop();
duke@435 257 }
duke@435 258
duke@435 259 //-----------------------------promote_to_phi-----------------------------------
duke@435 260 Node* IdealKit::promote_to_phi(Node* n, Node* reg) {
duke@435 261 assert(!was_promoted_to_phi(n, reg), "n already promoted to phi on this region");
duke@435 262 // Get a conservative type for the phi
duke@435 263 const BasicType bt = n->bottom_type()->basic_type();
duke@435 264 const Type* ct = Type::get_const_basic_type(bt);
duke@435 265 return delay_transform(PhiNode::make(reg, n, ct));
duke@435 266 }
duke@435 267
kvn@1286 268 //-----------------------------declarations_done-------------------------------
kvn@1286 269 void IdealKit::declarations_done() {
duke@435 270 _cvstate = new_cvstate(); // initialize current cvstate
duke@435 271 set_ctrl(_initial_ctrl); // initialize control in current cvstate
duke@435 272 set_all_memory(_initial_memory);// initialize memory in current cvstate
duke@435 273 DEBUG_ONLY(_state->push(BlockS));
duke@435 274 }
duke@435 275
duke@435 276 //-----------------------------transform-----------------------------------
duke@435 277 Node* IdealKit::transform(Node* n) {
duke@435 278 if (_delay_all_transforms) {
duke@435 279 return delay_transform(n);
duke@435 280 } else {
duke@435 281 return gvn().transform(n);
duke@435 282 }
duke@435 283 }
duke@435 284
duke@435 285 //-----------------------------delay_transform-----------------------------------
duke@435 286 Node* IdealKit::delay_transform(Node* n) {
kvn@1286 287 if (!gvn().is_IterGVN() || !gvn().is_IterGVN()->delay_transform()) {
kvn@1286 288 gvn().set_type(n, n->bottom_type());
kvn@1286 289 }
duke@435 290 _delay_transform->push(n);
duke@435 291 return n;
duke@435 292 }
duke@435 293
duke@435 294 //-----------------------------new_cvstate-----------------------------------
duke@435 295 Node* IdealKit::new_cvstate() {
duke@435 296 uint sz = _var_ct + first_var;
duke@435 297 return new (C, sz) Node(sz);
duke@435 298 }
duke@435 299
duke@435 300 //-----------------------------copy_cvstate-----------------------------------
duke@435 301 Node* IdealKit::copy_cvstate() {
duke@435 302 Node* ns = new_cvstate();
duke@435 303 for (uint i = 0; i < ns->req(); i++) ns->init_req(i, _cvstate->in(i));
duke@435 304 // We must clone memory since it will be updated as we do stores.
duke@435 305 ns->set_req(TypeFunc::Memory, MergeMemNode::make(C, ns->in(TypeFunc::Memory)));
duke@435 306 return ns;
duke@435 307 }
duke@435 308
duke@435 309 //-----------------------------clear-----------------------------------
duke@435 310 void IdealKit::clear(Node* m) {
duke@435 311 for (uint i = 0; i < m->req(); i++) m->set_req(i, NULL);
duke@435 312 }
duke@435 313
duke@435 314 //-----------------------------drain_delay_transform----------------------------
duke@435 315 void IdealKit::drain_delay_transform() {
duke@435 316 while (_delay_transform->length() > 0) {
duke@435 317 Node* n = _delay_transform->pop();
duke@435 318 gvn().transform(n);
duke@435 319 if (!gvn().is_IterGVN()) {
duke@435 320 C->record_for_igvn(n);
duke@435 321 }
duke@435 322 }
duke@435 323 }
duke@435 324
duke@435 325 //-----------------------------IdealVariable----------------------------
duke@435 326 IdealVariable::IdealVariable(IdealKit &k) {
duke@435 327 k.declare(this);
duke@435 328 }
duke@435 329
duke@435 330 Node* IdealKit::memory(uint alias_idx) {
duke@435 331 MergeMemNode* mem = merged_memory();
duke@435 332 Node* p = mem->memory_at(alias_idx);
kvn@1286 333 if (!gvn().is_IterGVN() || !gvn().is_IterGVN()->delay_transform()) {
kvn@1286 334 _gvn.set_type(p, Type::MEMORY); // must be mapped
kvn@1286 335 }
duke@435 336 return p;
duke@435 337 }
duke@435 338
duke@435 339 void IdealKit::set_memory(Node* mem, uint alias_idx) {
duke@435 340 merged_memory()->set_memory_at(alias_idx, mem);
duke@435 341 }
duke@435 342
duke@435 343 //----------------------------- make_load ----------------------------
duke@435 344 Node* IdealKit::load(Node* ctl,
duke@435 345 Node* adr,
duke@435 346 const Type* t,
duke@435 347 BasicType bt,
duke@435 348 int adr_idx,
duke@435 349 bool require_atomic_access) {
duke@435 350
duke@435 351 assert(adr_idx != Compile::AliasIdxTop, "use other make_load factory" );
duke@435 352 const TypePtr* adr_type = NULL; // debug-mode-only argument
duke@435 353 debug_only(adr_type = C->get_adr_type(adr_idx));
duke@435 354 Node* mem = memory(adr_idx);
duke@435 355 Node* ld;
duke@435 356 if (require_atomic_access && bt == T_LONG) {
duke@435 357 ld = LoadLNode::make_atomic(C, ctl, mem, adr, adr_type, t);
duke@435 358 } else {
coleenp@548 359 ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt);
duke@435 360 }
duke@435 361 return transform(ld);
duke@435 362 }
duke@435 363
duke@435 364 Node* IdealKit::store(Node* ctl, Node* adr, Node *val, BasicType bt,
duke@435 365 int adr_idx,
duke@435 366 bool require_atomic_access) {
duke@435 367 assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" );
duke@435 368 const TypePtr* adr_type = NULL;
duke@435 369 debug_only(adr_type = C->get_adr_type(adr_idx));
duke@435 370 Node *mem = memory(adr_idx);
duke@435 371 Node* st;
duke@435 372 if (require_atomic_access && bt == T_LONG) {
duke@435 373 st = StoreLNode::make_atomic(C, ctl, mem, adr, adr_type, val);
duke@435 374 } else {
coleenp@548 375 st = StoreNode::make(_gvn, ctl, mem, adr, adr_type, val, bt);
duke@435 376 }
duke@435 377 st = transform(st);
duke@435 378 set_memory(st, adr_idx);
duke@435 379
duke@435 380 return st;
duke@435 381 }
duke@435 382
duke@435 383 // Card mark store. Must be ordered so that it will come after the store of
duke@435 384 // the oop.
cfang@1420 385 Node* IdealKit::storeCM(Node* ctl, Node* adr, Node *val, Node* oop_store, int oop_adr_idx,
duke@435 386 BasicType bt,
duke@435 387 int adr_idx) {
duke@435 388 assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" );
duke@435 389 const TypePtr* adr_type = NULL;
duke@435 390 debug_only(adr_type = C->get_adr_type(adr_idx));
duke@435 391 Node *mem = memory(adr_idx);
duke@435 392
duke@435 393 // Add required edge to oop_store, optimizer does not support precedence edges.
duke@435 394 // Convert required edge to precedence edge before allocation.
cfang@1420 395 Node* st = new (C, 5) StoreCMNode(ctl, mem, adr, adr_type, val, oop_store, oop_adr_idx);
duke@435 396
duke@435 397 st = transform(st);
duke@435 398 set_memory(st, adr_idx);
duke@435 399
duke@435 400 return st;
duke@435 401 }
duke@435 402
duke@435 403 //---------------------------- do_memory_merge --------------------------------
duke@435 404 // The memory from one merging cvstate needs to be merged with the memory for another
duke@435 405 // join cvstate. If the join cvstate doesn't have a merged memory yet then we
duke@435 406 // can just copy the state from the merging cvstate
duke@435 407
duke@435 408 // Merge one slow path into the rest of memory.
duke@435 409 void IdealKit::do_memory_merge(Node* merging, Node* join) {
duke@435 410
duke@435 411 // Get the region for the join state
duke@435 412 Node* join_region = join->in(TypeFunc::Control);
duke@435 413 assert(join_region != NULL, "join region must exist");
duke@435 414 if (join->in(TypeFunc::Memory) == NULL ) {
duke@435 415 join->set_req(TypeFunc::Memory, merging->in(TypeFunc::Memory));
duke@435 416 return;
duke@435 417 }
duke@435 418
duke@435 419 // The control flow for merging must have already been attached to the join region
duke@435 420 // we need its index for the phis.
duke@435 421 uint slot;
duke@435 422 for (slot = 1; slot < join_region->req() ; slot ++ ) {
duke@435 423 if (join_region->in(slot) == merging->in(TypeFunc::Control)) break;
duke@435 424 }
duke@435 425 assert(slot != join_region->req(), "edge must already exist");
duke@435 426
duke@435 427 MergeMemNode* join_m = join->in(TypeFunc::Memory)->as_MergeMem();
duke@435 428 MergeMemNode* merging_m = merging->in(TypeFunc::Memory)->as_MergeMem();
duke@435 429
duke@435 430 // join_m should be an ancestor mergemem of merging
duke@435 431 // Slow path memory comes from the current map (which is from a slow call)
duke@435 432 // Fast path/null path memory comes from the call's input
duke@435 433
duke@435 434 // Merge the other fast-memory inputs with the new slow-default memory.
duke@435 435 // for (MergeMemStream mms(merged_memory(), fast_mem->as_MergeMem()); mms.next_non_empty2(); ) {
duke@435 436 for (MergeMemStream mms(join_m, merging_m); mms.next_non_empty2(); ) {
duke@435 437 Node* join_slice = mms.force_memory();
duke@435 438 Node* merging_slice = mms.memory2();
duke@435 439 if (join_slice != merging_slice) {
duke@435 440 PhiNode* phi;
duke@435 441 // bool new_phi = false;
duke@435 442 // Is the phi for this slice one that we created for this join region or simply
duke@435 443 // one we copied? If it is ours then add
duke@435 444 if (join_slice->is_Phi() && join_slice->as_Phi()->region() == join_region) {
duke@435 445 phi = join_slice->as_Phi();
duke@435 446 } else {
duke@435 447 // create the phi with join_slice filling supplying memory for all of the
duke@435 448 // control edges to the join region
duke@435 449 phi = PhiNode::make(join_region, join_slice, Type::MEMORY, mms.adr_type(C));
duke@435 450 phi = (PhiNode*) delay_transform(phi);
duke@435 451 // gvn().set_type(phi, Type::MEMORY);
duke@435 452 // new_phi = true;
duke@435 453 }
duke@435 454 // Now update the phi with the slice for the merging slice
duke@435 455 phi->set_req(slot, merging_slice/* slow_path, slow_slice */);
duke@435 456 // this updates join_m with the phi
duke@435 457 mms.set_memory(phi);
duke@435 458 }
duke@435 459 }
duke@435 460 }
duke@435 461
duke@435 462
duke@435 463 //----------------------------- make_call ----------------------------
duke@435 464 // Trivial runtime call
duke@435 465 void IdealKit::make_leaf_call(const TypeFunc *slow_call_type,
duke@435 466 address slow_call,
duke@435 467 const char *leaf_name,
duke@435 468 Node* parm0,
duke@435 469 Node* parm1,
duke@435 470 Node* parm2) {
duke@435 471
duke@435 472 // We only handle taking in RawMem and modifying RawMem
duke@435 473 const TypePtr* adr_type = TypeRawPtr::BOTTOM;
duke@435 474 uint adr_idx = C->get_alias_index(adr_type);
duke@435 475
duke@435 476 // Slow-path leaf call
duke@435 477 int size = slow_call_type->domain()->cnt();
duke@435 478 CallNode *call = (CallNode*)new (C, size) CallLeafNode( slow_call_type, slow_call, leaf_name, adr_type);
duke@435 479
duke@435 480 // Set fixed predefined input arguments
duke@435 481 call->init_req( TypeFunc::Control, ctrl() );
duke@435 482 call->init_req( TypeFunc::I_O , top() ) ; // does no i/o
duke@435 483 // Narrow memory as only memory input
duke@435 484 call->init_req( TypeFunc::Memory , memory(adr_idx));
duke@435 485 call->init_req( TypeFunc::FramePtr, top() /* frameptr() */ );
duke@435 486 call->init_req( TypeFunc::ReturnAdr, top() );
duke@435 487
duke@435 488 if (parm0 != NULL) call->init_req(TypeFunc::Parms+0, parm0);
duke@435 489 if (parm1 != NULL) call->init_req(TypeFunc::Parms+1, parm1);
duke@435 490 if (parm2 != NULL) call->init_req(TypeFunc::Parms+2, parm2);
duke@435 491
duke@435 492 // Node *c = _gvn.transform(call);
duke@435 493 call = (CallNode *) _gvn.transform(call);
duke@435 494 Node *c = call; // dbx gets confused with call call->dump()
duke@435 495
duke@435 496 // Slow leaf call has no side-effects, sets few values
duke@435 497
duke@435 498 set_ctrl(transform( new (C, 1) ProjNode(call,TypeFunc::Control) ));
duke@435 499
duke@435 500 // Make memory for the call
duke@435 501 Node* mem = _gvn.transform( new (C, 1) ProjNode(call, TypeFunc::Memory) );
duke@435 502
duke@435 503 // Set the RawPtr memory state only.
duke@435 504 set_memory(mem, adr_idx);
duke@435 505
duke@435 506 assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type),
duke@435 507 "call node must be constructed correctly");
duke@435 508 }

mercurial