aoqi@0: /* aoqi@0: * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #include "precompiled.hpp" aoqi@0: #include "opto/addnode.hpp" aoqi@0: #include "opto/callnode.hpp" aoqi@0: #include "opto/cfgnode.hpp" aoqi@0: #include "opto/idealKit.hpp" aoqi@0: #include "opto/runtime.hpp" aoqi@0: aoqi@0: // Static initialization aoqi@0: aoqi@0: // This declares the position where vars are kept in the cvstate aoqi@0: // For some degree of consistency we use the TypeFunc enum to aoqi@0: // soak up spots in the inputs even though we only use early Control aoqi@0: // and Memory slots. (So far.) aoqi@0: const uint IdealKit::first_var = TypeFunc::Parms + 1; aoqi@0: aoqi@0: //----------------------------IdealKit----------------------------------------- aoqi@0: IdealKit::IdealKit(GraphKit* gkit, bool delay_all_transforms, bool has_declarations) : aoqi@0: _gvn(gkit->gvn()), C(gkit->C) { aoqi@0: _initial_ctrl = gkit->control(); aoqi@0: _initial_memory = gkit->merged_memory(); aoqi@0: _initial_i_o = gkit->i_o(); aoqi@0: _delay_all_transforms = delay_all_transforms; aoqi@0: _var_ct = 0; aoqi@0: _cvstate = NULL; aoqi@0: // We can go memory state free or else we need the entire memory state aoqi@0: assert(_initial_memory == NULL || _initial_memory->Opcode() == Op_MergeMem, "memory must be pre-split"); aoqi@0: assert(!_gvn.is_IterGVN(), "IdealKit can't be used during Optimize phase"); aoqi@0: int init_size = 5; aoqi@0: _pending_cvstates = new (C->node_arena()) GrowableArray(C->node_arena(), init_size, 0, 0); aoqi@0: DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray(C->node_arena(), init_size, 0, 0)); aoqi@0: if (!has_declarations) { aoqi@0: declarations_done(); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: //----------------------------sync_kit----------------------------------------- aoqi@0: void IdealKit::sync_kit(GraphKit* gkit) { aoqi@0: set_all_memory(gkit->merged_memory()); aoqi@0: set_i_o(gkit->i_o()); aoqi@0: set_ctrl(gkit->control()); aoqi@0: } aoqi@0: aoqi@0: //-------------------------------if_then------------------------------------- aoqi@0: // Create: if(left relop right) aoqi@0: // / \ aoqi@0: // iffalse iftrue aoqi@0: // Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate. aoqi@0: void IdealKit::if_then(Node* left, BoolTest::mask relop, aoqi@0: Node* right, float prob, float cnt, bool push_new_state) { aoqi@0: assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new If"); aoqi@0: Node* bol; aoqi@0: if (left->bottom_type()->isa_ptr() == NULL) { aoqi@0: if (left->bottom_type()->isa_int() != NULL) { aoqi@0: bol = Bool(CmpI(left, right), relop); aoqi@0: } else { aoqi@0: assert(left->bottom_type()->isa_long() != NULL, "what else?"); aoqi@0: bol = Bool(CmpL(left, right), relop); aoqi@0: } aoqi@0: aoqi@0: } else { aoqi@0: bol = Bool(CmpP(left, right), relop); aoqi@0: } aoqi@0: // Delay gvn.tranform on if-nodes until construction is finished aoqi@0: // to prevent a constant bool input from discarding a control output. aoqi@0: IfNode* iff = delay_transform(new (C) IfNode(ctrl(), bol, prob, cnt))->as_If(); aoqi@0: Node* then = IfTrue(iff); aoqi@0: Node* elsen = IfFalse(iff); aoqi@0: Node* else_cvstate = copy_cvstate(); aoqi@0: else_cvstate->set_req(TypeFunc::Control, elsen); aoqi@0: _pending_cvstates->push(else_cvstate); aoqi@0: DEBUG_ONLY(if (push_new_state) _state->push(IfThenS)); aoqi@0: set_ctrl(then); aoqi@0: } aoqi@0: aoqi@0: //-------------------------------else_------------------------------------- aoqi@0: // Pop the else cvstate off the stack, and push the (current) then cvstate. aoqi@0: // The else cvstate becomes the current cvstate. aoqi@0: void IdealKit::else_() { aoqi@0: assert(state() == IfThenS, "bad state for new Else"); aoqi@0: Node* else_cvstate = _pending_cvstates->pop(); aoqi@0: DEBUG_ONLY(_state->pop()); aoqi@0: // save current (then) cvstate for later use at endif aoqi@0: _pending_cvstates->push(_cvstate); aoqi@0: DEBUG_ONLY(_state->push(ElseS)); aoqi@0: _cvstate = else_cvstate; aoqi@0: } aoqi@0: aoqi@0: //-------------------------------end_if------------------------------------- aoqi@0: // Merge the "then" and "else" cvstates. aoqi@0: // aoqi@0: // The if_then() pushed a copy of the current state for later use aoqi@0: // as the initial state for a future "else" clause. The aoqi@0: // current state then became the initial state for the aoqi@0: // then clause. If an "else" clause was encountered, it will aoqi@0: // pop the top state and use it for it's initial state. aoqi@0: // It will also push the current state (the state at the end of aoqi@0: // the "then" clause) for latter use at the end_if. aoqi@0: // aoqi@0: // At the endif, the states are: aoqi@0: // 1) else exists a) current state is end of "else" clause aoqi@0: // b) top stack state is end of "then" clause aoqi@0: // aoqi@0: // 2) no else: a) current state is end of "then" clause aoqi@0: // b) top stack state is from the "if_then" which aoqi@0: // would have been the initial state of the else. aoqi@0: // aoqi@0: // Merging the states is accomplished by: aoqi@0: // 1) make a label for the merge aoqi@0: // 2) terminate the current state with a goto to the label aoqi@0: // 3) pop the top state from the stack and make it the aoqi@0: // current state aoqi@0: // 4) bind the label at the current state. Binding a label aoqi@0: // terminates the current state with a goto to the aoqi@0: // label and makes the label's state the current state. aoqi@0: // aoqi@0: void IdealKit::end_if() { aoqi@0: assert(state() & (IfThenS|ElseS), "bad state for new Endif"); aoqi@0: Node* lab = make_label(1); aoqi@0: aoqi@0: // Node* join_state = _pending_cvstates->pop(); aoqi@0: /* merging, join */ aoqi@0: goto_(lab); aoqi@0: _cvstate = _pending_cvstates->pop(); aoqi@0: aoqi@0: bind(lab); aoqi@0: DEBUG_ONLY(_state->pop()); aoqi@0: } aoqi@0: aoqi@0: //-------------------------------loop------------------------------------- aoqi@0: // Create the loop head portion (*) of: aoqi@0: // * iv = init aoqi@0: // * top: (region node) aoqi@0: // * if (iv relop limit) { aoqi@0: // loop body aoqi@0: // i = i + 1 aoqi@0: // goto top aoqi@0: // * } else // exits loop aoqi@0: // aoqi@0: // Pushes the loop top cvstate first, then the else (loop exit) cvstate aoqi@0: // onto the stack. aoqi@0: void IdealKit::loop(GraphKit* gkit, int nargs, IdealVariable& iv, Node* init, BoolTest::mask relop, Node* limit, float prob, float cnt) { aoqi@0: assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new loop"); aoqi@0: if (UseLoopPredicate) { aoqi@0: // Sync IdealKit and graphKit. aoqi@0: gkit->sync_kit(*this); aoqi@0: // Add loop predicate. aoqi@0: gkit->add_predicate(nargs); aoqi@0: // Update IdealKit memory. aoqi@0: sync_kit(gkit); aoqi@0: } aoqi@0: set(iv, init); aoqi@0: Node* head = make_label(1); aoqi@0: bind(head); aoqi@0: _pending_cvstates->push(head); // push for use at end_loop aoqi@0: _cvstate = copy_cvstate(); aoqi@0: if_then(value(iv), relop, limit, prob, cnt, false /* no new state */); aoqi@0: DEBUG_ONLY(_state->push(LoopS)); aoqi@0: assert(ctrl()->is_IfTrue(), "true branch stays in loop"); aoqi@0: assert(_pending_cvstates->top()->in(TypeFunc::Control)->is_IfFalse(), "false branch exits loop"); aoqi@0: } aoqi@0: aoqi@0: //-------------------------------end_loop------------------------------------- aoqi@0: // Creates the goto top label. aoqi@0: // Expects the else (loop exit) cvstate to be on top of the aoqi@0: // stack, and the loop top cvstate to be 2nd. aoqi@0: void IdealKit::end_loop() { aoqi@0: assert((state() == LoopS), "bad state for new end_loop"); aoqi@0: Node* exit = _pending_cvstates->pop(); aoqi@0: Node* head = _pending_cvstates->pop(); aoqi@0: goto_(head); aoqi@0: clear(head); aoqi@0: DEBUG_ONLY(_state->pop()); aoqi@0: _cvstate = exit; aoqi@0: } aoqi@0: aoqi@0: //-------------------------------make_label------------------------------------- aoqi@0: // Creates a label. The number of goto's aoqi@0: // must be specified (which should be 1 less than aoqi@0: // the number of precedessors.) aoqi@0: Node* IdealKit::make_label(int goto_ct) { aoqi@0: assert(_cvstate != NULL, "must declare variables before labels"); aoqi@0: Node* lab = new_cvstate(); aoqi@0: int sz = 1 + goto_ct + 1 /* fall thru */; aoqi@0: Node* reg = delay_transform(new (C) RegionNode(sz)); aoqi@0: lab->init_req(TypeFunc::Control, reg); aoqi@0: return lab; aoqi@0: } aoqi@0: aoqi@0: //-------------------------------bind------------------------------------- aoqi@0: // Bind a label at the current cvstate by simulating aoqi@0: // a goto to the label. aoqi@0: void IdealKit::bind(Node* lab) { aoqi@0: goto_(lab, true /* bind */); aoqi@0: _cvstate = lab; aoqi@0: } aoqi@0: aoqi@0: //-------------------------------goto_------------------------------------- aoqi@0: // Make the current cvstate a predecessor of the label, aoqi@0: // creating phi's to merge values. If bind is true and aoqi@0: // this is not the last control edge, then ensure that aoqi@0: // all live values have phis created. Used to create phis aoqi@0: // at loop-top regions. aoqi@0: void IdealKit::goto_(Node* lab, bool bind) { aoqi@0: Node* reg = lab->in(TypeFunc::Control); aoqi@0: // find next empty slot in region aoqi@0: uint slot = 1; aoqi@0: while (slot < reg->req() && reg->in(slot) != NULL) slot++; aoqi@0: assert(slot < reg->req(), "too many gotos"); aoqi@0: // If this is last predecessor, then don't force phi creation aoqi@0: if (slot == reg->req() - 1) bind = false; aoqi@0: reg->init_req(slot, ctrl()); aoqi@0: assert(first_var + _var_ct == _cvstate->req(), "bad _cvstate size"); aoqi@0: for (uint i = first_var; i < _cvstate->req(); i++) { aoqi@0: aoqi@0: // l is the value of var reaching the label. Could be a single value aoqi@0: // reaching the label, or a phi that merges multiples values reaching aoqi@0: // the label. The latter is true if the label's input: in(..) is aoqi@0: // a phi whose control input is the region node for the label. aoqi@0: aoqi@0: Node* l = lab->in(i); aoqi@0: // Get the current value of the var aoqi@0: Node* m = _cvstate->in(i); aoqi@0: // If the var went unused no need for a phi aoqi@0: if (m == NULL) { aoqi@0: continue; aoqi@0: } else if (l == NULL || m == l) { aoqi@0: // Only one unique value "m" is known to reach this label so a phi aoqi@0: // is not yet necessary unless: aoqi@0: // the label is being bound and all predecessors have not been seen, aoqi@0: // in which case "bind" will be true. aoqi@0: if (bind) { aoqi@0: m = promote_to_phi(m, reg); aoqi@0: } aoqi@0: // Record the phi/value used for this var in the label's cvstate aoqi@0: lab->set_req(i, m); aoqi@0: } else { aoqi@0: // More than one value for the variable reaches this label so aoqi@0: // a create a phi if one does not already exist. aoqi@0: if (!was_promoted_to_phi(l, reg)) { aoqi@0: l = promote_to_phi(l, reg); aoqi@0: lab->set_req(i, l); aoqi@0: } aoqi@0: // Record in the phi, the var's value from the current state aoqi@0: l->set_req(slot, m); aoqi@0: } aoqi@0: } aoqi@0: do_memory_merge(_cvstate, lab); aoqi@0: stop(); aoqi@0: } aoqi@0: aoqi@0: //-----------------------------promote_to_phi----------------------------------- aoqi@0: Node* IdealKit::promote_to_phi(Node* n, Node* reg) { aoqi@0: assert(!was_promoted_to_phi(n, reg), "n already promoted to phi on this region"); aoqi@0: // Get a conservative type for the phi aoqi@0: const BasicType bt = n->bottom_type()->basic_type(); aoqi@0: const Type* ct = Type::get_const_basic_type(bt); aoqi@0: return delay_transform(PhiNode::make(reg, n, ct)); aoqi@0: } aoqi@0: aoqi@0: //-----------------------------declarations_done------------------------------- aoqi@0: void IdealKit::declarations_done() { aoqi@0: _cvstate = new_cvstate(); // initialize current cvstate aoqi@0: set_ctrl(_initial_ctrl); // initialize control in current cvstate aoqi@0: set_all_memory(_initial_memory);// initialize memory in current cvstate aoqi@0: set_i_o(_initial_i_o); // initialize i_o in current cvstate aoqi@0: DEBUG_ONLY(_state->push(BlockS)); aoqi@0: } aoqi@0: aoqi@0: //-----------------------------transform----------------------------------- aoqi@0: Node* IdealKit::transform(Node* n) { aoqi@0: if (_delay_all_transforms) { aoqi@0: return delay_transform(n); aoqi@0: } else { aoqi@0: n = gvn().transform(n); aoqi@0: C->record_for_igvn(n); aoqi@0: return n; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: //-----------------------------delay_transform----------------------------------- aoqi@0: Node* IdealKit::delay_transform(Node* n) { aoqi@0: // Delay transform until IterativeGVN aoqi@0: gvn().set_type(n, n->bottom_type()); aoqi@0: C->record_for_igvn(n); aoqi@0: return n; aoqi@0: } aoqi@0: aoqi@0: //-----------------------------new_cvstate----------------------------------- aoqi@0: Node* IdealKit::new_cvstate() { aoqi@0: uint sz = _var_ct + first_var; aoqi@0: return new (C) Node(sz); aoqi@0: } aoqi@0: aoqi@0: //-----------------------------copy_cvstate----------------------------------- aoqi@0: Node* IdealKit::copy_cvstate() { aoqi@0: Node* ns = new_cvstate(); aoqi@0: for (uint i = 0; i < ns->req(); i++) ns->init_req(i, _cvstate->in(i)); aoqi@0: // We must clone memory since it will be updated as we do stores. aoqi@0: ns->set_req(TypeFunc::Memory, MergeMemNode::make(C, ns->in(TypeFunc::Memory))); aoqi@0: return ns; aoqi@0: } aoqi@0: aoqi@0: //-----------------------------clear----------------------------------- aoqi@0: void IdealKit::clear(Node* m) { aoqi@0: for (uint i = 0; i < m->req(); i++) m->set_req(i, NULL); aoqi@0: } aoqi@0: aoqi@0: //-----------------------------IdealVariable---------------------------- aoqi@0: IdealVariable::IdealVariable(IdealKit &k) { aoqi@0: k.declare(this); aoqi@0: } aoqi@0: aoqi@0: Node* IdealKit::memory(uint alias_idx) { aoqi@0: MergeMemNode* mem = merged_memory(); aoqi@0: Node* p = mem->memory_at(alias_idx); aoqi@0: _gvn.set_type(p, Type::MEMORY); // must be mapped aoqi@0: return p; aoqi@0: } aoqi@0: aoqi@0: void IdealKit::set_memory(Node* mem, uint alias_idx) { aoqi@0: merged_memory()->set_memory_at(alias_idx, mem); aoqi@0: } aoqi@0: aoqi@0: //----------------------------- make_load ---------------------------- aoqi@0: Node* IdealKit::load(Node* ctl, aoqi@0: Node* adr, aoqi@0: const Type* t, aoqi@0: BasicType bt, aoqi@0: int adr_idx, aoqi@0: bool require_atomic_access) { aoqi@0: aoqi@0: assert(adr_idx != Compile::AliasIdxTop, "use other make_load factory" ); aoqi@0: const TypePtr* adr_type = NULL; // debug-mode-only argument aoqi@0: debug_only(adr_type = C->get_adr_type(adr_idx)); aoqi@0: Node* mem = memory(adr_idx); aoqi@0: Node* ld; aoqi@0: if (require_atomic_access && bt == T_LONG) { aoqi@0: ld = LoadLNode::make_atomic(C, ctl, mem, adr, adr_type, t, MemNode::unordered); aoqi@0: } else { aoqi@0: ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt, MemNode::unordered); aoqi@0: } aoqi@0: return transform(ld); aoqi@0: } aoqi@0: aoqi@0: Node* IdealKit::store(Node* ctl, Node* adr, Node *val, BasicType bt, aoqi@0: int adr_idx, aoqi@0: MemNode::MemOrd mo, bool require_atomic_access) { aoqi@0: assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory"); aoqi@0: const TypePtr* adr_type = NULL; aoqi@0: debug_only(adr_type = C->get_adr_type(adr_idx)); aoqi@0: Node *mem = memory(adr_idx); aoqi@0: Node* st; aoqi@0: if (require_atomic_access && bt == T_LONG) { aoqi@0: st = StoreLNode::make_atomic(C, ctl, mem, adr, adr_type, val, mo); aoqi@0: } else { aoqi@0: st = StoreNode::make(_gvn, ctl, mem, adr, adr_type, val, bt, mo); aoqi@0: } aoqi@0: st = transform(st); aoqi@0: set_memory(st, adr_idx); aoqi@0: aoqi@0: return st; aoqi@0: } aoqi@0: aoqi@0: // Card mark store. Must be ordered so that it will come after the store of aoqi@0: // the oop. aoqi@0: Node* IdealKit::storeCM(Node* ctl, Node* adr, Node *val, Node* oop_store, int oop_adr_idx, aoqi@0: BasicType bt, aoqi@0: int adr_idx) { aoqi@0: assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" ); aoqi@0: const TypePtr* adr_type = NULL; aoqi@0: debug_only(adr_type = C->get_adr_type(adr_idx)); aoqi@0: Node *mem = memory(adr_idx); aoqi@0: aoqi@0: // Add required edge to oop_store, optimizer does not support precedence edges. aoqi@0: // Convert required edge to precedence edge before allocation. aoqi@0: Node* st = new (C) StoreCMNode(ctl, mem, adr, adr_type, val, oop_store, oop_adr_idx); aoqi@0: aoqi@0: st = transform(st); aoqi@0: set_memory(st, adr_idx); aoqi@0: aoqi@0: return st; aoqi@0: } aoqi@0: aoqi@0: //---------------------------- do_memory_merge -------------------------------- aoqi@0: // The memory from one merging cvstate needs to be merged with the memory for another aoqi@0: // join cvstate. If the join cvstate doesn't have a merged memory yet then we aoqi@0: // can just copy the state from the merging cvstate aoqi@0: aoqi@0: // Merge one slow path into the rest of memory. aoqi@0: void IdealKit::do_memory_merge(Node* merging, Node* join) { aoqi@0: aoqi@0: // Get the region for the join state aoqi@0: Node* join_region = join->in(TypeFunc::Control); aoqi@0: assert(join_region != NULL, "join region must exist"); aoqi@0: if (join->in(TypeFunc::I_O) == NULL ) { aoqi@0: join->set_req(TypeFunc::I_O, merging->in(TypeFunc::I_O)); aoqi@0: } aoqi@0: if (join->in(TypeFunc::Memory) == NULL ) { aoqi@0: join->set_req(TypeFunc::Memory, merging->in(TypeFunc::Memory)); aoqi@0: return; aoqi@0: } aoqi@0: aoqi@0: // The control flow for merging must have already been attached to the join region aoqi@0: // we need its index for the phis. aoqi@0: uint slot; aoqi@0: for (slot = 1; slot < join_region->req() ; slot ++ ) { aoqi@0: if (join_region->in(slot) == merging->in(TypeFunc::Control)) break; aoqi@0: } aoqi@0: assert(slot != join_region->req(), "edge must already exist"); aoqi@0: aoqi@0: MergeMemNode* join_m = join->in(TypeFunc::Memory)->as_MergeMem(); aoqi@0: MergeMemNode* merging_m = merging->in(TypeFunc::Memory)->as_MergeMem(); aoqi@0: aoqi@0: // join_m should be an ancestor mergemem of merging aoqi@0: // Slow path memory comes from the current map (which is from a slow call) aoqi@0: // Fast path/null path memory comes from the call's input aoqi@0: aoqi@0: // Merge the other fast-memory inputs with the new slow-default memory. aoqi@0: // for (MergeMemStream mms(merged_memory(), fast_mem->as_MergeMem()); mms.next_non_empty2(); ) { aoqi@0: for (MergeMemStream mms(join_m, merging_m); mms.next_non_empty2(); ) { aoqi@0: Node* join_slice = mms.force_memory(); aoqi@0: Node* merging_slice = mms.memory2(); aoqi@0: if (join_slice != merging_slice) { aoqi@0: PhiNode* phi; aoqi@0: // bool new_phi = false; aoqi@0: // Is the phi for this slice one that we created for this join region or simply aoqi@0: // one we copied? If it is ours then add aoqi@0: if (join_slice->is_Phi() && join_slice->as_Phi()->region() == join_region) { aoqi@0: phi = join_slice->as_Phi(); aoqi@0: } else { aoqi@0: // create the phi with join_slice filling supplying memory for all of the aoqi@0: // control edges to the join region aoqi@0: phi = PhiNode::make(join_region, join_slice, Type::MEMORY, mms.adr_type(C)); aoqi@0: phi = (PhiNode*) delay_transform(phi); aoqi@0: // gvn().set_type(phi, Type::MEMORY); aoqi@0: // new_phi = true; aoqi@0: } aoqi@0: // Now update the phi with the slice for the merging slice aoqi@0: phi->set_req(slot, merging_slice/* slow_path, slow_slice */); aoqi@0: // this updates join_m with the phi aoqi@0: mms.set_memory(phi); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: Node* join_io = join->in(TypeFunc::I_O); aoqi@0: Node* merging_io = merging->in(TypeFunc::I_O); aoqi@0: if (join_io != merging_io) { aoqi@0: PhiNode* phi; aoqi@0: if (join_io->is_Phi() && join_io->as_Phi()->region() == join_region) { aoqi@0: phi = join_io->as_Phi(); aoqi@0: } else { aoqi@0: phi = PhiNode::make(join_region, join_io, Type::ABIO); aoqi@0: phi = (PhiNode*) delay_transform(phi); aoqi@0: join->set_req(TypeFunc::I_O, phi); aoqi@0: } aoqi@0: phi->set_req(slot, merging_io); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: aoqi@0: //----------------------------- make_call ---------------------------- aoqi@0: // Trivial runtime call aoqi@0: void IdealKit::make_leaf_call(const TypeFunc *slow_call_type, aoqi@0: address slow_call, aoqi@0: const char *leaf_name, aoqi@0: Node* parm0, aoqi@0: Node* parm1, aoqi@0: Node* parm2, aoqi@0: Node* parm3) { aoqi@0: aoqi@0: // We only handle taking in RawMem and modifying RawMem aoqi@0: const TypePtr* adr_type = TypeRawPtr::BOTTOM; aoqi@0: uint adr_idx = C->get_alias_index(adr_type); aoqi@0: aoqi@0: // Slow-path leaf call aoqi@0: CallNode *call = (CallNode*)new (C) CallLeafNode( slow_call_type, slow_call, leaf_name, adr_type); aoqi@0: aoqi@0: // Set fixed predefined input arguments aoqi@0: call->init_req( TypeFunc::Control, ctrl() ); aoqi@0: call->init_req( TypeFunc::I_O , top() ) ; // does no i/o aoqi@0: // Narrow memory as only memory input aoqi@0: call->init_req( TypeFunc::Memory , memory(adr_idx)); aoqi@0: call->init_req( TypeFunc::FramePtr, top() /* frameptr() */ ); aoqi@0: call->init_req( TypeFunc::ReturnAdr, top() ); aoqi@0: aoqi@0: if (parm0 != NULL) call->init_req(TypeFunc::Parms+0, parm0); aoqi@0: if (parm1 != NULL) call->init_req(TypeFunc::Parms+1, parm1); aoqi@0: if (parm2 != NULL) call->init_req(TypeFunc::Parms+2, parm2); aoqi@0: if (parm3 != NULL) call->init_req(TypeFunc::Parms+3, parm3); aoqi@0: aoqi@0: // Node *c = _gvn.transform(call); aoqi@0: call = (CallNode *) _gvn.transform(call); aoqi@0: Node *c = call; // dbx gets confused with call call->dump() aoqi@0: aoqi@0: // Slow leaf call has no side-effects, sets few values aoqi@0: aoqi@0: set_ctrl(transform( new (C) ProjNode(call,TypeFunc::Control) )); aoqi@0: aoqi@0: // Make memory for the call aoqi@0: Node* mem = _gvn.transform( new (C) ProjNode(call, TypeFunc::Memory) ); aoqi@0: aoqi@0: // Set the RawPtr memory state only. aoqi@0: set_memory(mem, adr_idx); aoqi@0: aoqi@0: assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type), aoqi@0: "call node must be constructed correctly"); aoqi@0: } aoqi@0: aoqi@0: aoqi@0: void IdealKit::make_leaf_call_no_fp(const TypeFunc *slow_call_type, aoqi@0: address slow_call, aoqi@0: const char *leaf_name, aoqi@0: const TypePtr* adr_type, aoqi@0: Node* parm0, aoqi@0: Node* parm1, aoqi@0: Node* parm2, aoqi@0: Node* parm3) { aoqi@0: aoqi@0: // We only handle taking in RawMem and modifying RawMem aoqi@0: uint adr_idx = C->get_alias_index(adr_type); aoqi@0: aoqi@0: // Slow-path leaf call aoqi@0: CallNode *call = (CallNode*)new (C) CallLeafNoFPNode( slow_call_type, slow_call, leaf_name, adr_type); aoqi@0: aoqi@0: // Set fixed predefined input arguments aoqi@0: call->init_req( TypeFunc::Control, ctrl() ); aoqi@0: call->init_req( TypeFunc::I_O , top() ) ; // does no i/o aoqi@0: // Narrow memory as only memory input aoqi@0: call->init_req( TypeFunc::Memory , memory(adr_idx)); aoqi@0: call->init_req( TypeFunc::FramePtr, top() /* frameptr() */ ); aoqi@0: call->init_req( TypeFunc::ReturnAdr, top() ); aoqi@0: aoqi@0: if (parm0 != NULL) call->init_req(TypeFunc::Parms+0, parm0); aoqi@0: if (parm1 != NULL) call->init_req(TypeFunc::Parms+1, parm1); aoqi@0: if (parm2 != NULL) call->init_req(TypeFunc::Parms+2, parm2); aoqi@0: if (parm3 != NULL) call->init_req(TypeFunc::Parms+3, parm3); aoqi@0: aoqi@0: // Node *c = _gvn.transform(call); aoqi@0: call = (CallNode *) _gvn.transform(call); aoqi@0: Node *c = call; // dbx gets confused with call call->dump() aoqi@0: aoqi@0: // Slow leaf call has no side-effects, sets few values aoqi@0: aoqi@0: set_ctrl(transform( new (C) ProjNode(call,TypeFunc::Control) )); aoqi@0: aoqi@0: // Make memory for the call aoqi@0: Node* mem = _gvn.transform( new (C) ProjNode(call, TypeFunc::Memory) ); aoqi@0: aoqi@0: // Set the RawPtr memory state only. aoqi@0: set_memory(mem, adr_idx); aoqi@0: aoqi@0: assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type), aoqi@0: "call node must be constructed correctly"); aoqi@0: }