src/share/vm/opto/idealKit.cpp

Fri, 27 Feb 2009 13:27:09 -0800

author
twisti
date
Fri, 27 Feb 2009 13:27:09 -0800
changeset 1040
98cb887364d3
parent 631
d1605aabd0a1
child 1286
fc4be448891f
permissions
-rw-r--r--

6810672: Comment typos
Summary: I have collected some typos I have found while looking at the code.
Reviewed-by: kvn, never

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

mercurial