src/share/vm/opto/idealKit.cpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/opto/idealKit.cpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,578 @@
     1.4 +/*
     1.5 + * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "precompiled.hpp"
    1.29 +#include "opto/addnode.hpp"
    1.30 +#include "opto/callnode.hpp"
    1.31 +#include "opto/cfgnode.hpp"
    1.32 +#include "opto/idealKit.hpp"
    1.33 +#include "opto/runtime.hpp"
    1.34 +
    1.35 +// Static initialization
    1.36 +
    1.37 +// This declares the position where vars are kept in the cvstate
    1.38 +// For some degree of consistency we use the TypeFunc enum to
    1.39 +// soak up spots in the inputs even though we only use early Control
    1.40 +// and Memory slots. (So far.)
    1.41 +const uint IdealKit::first_var = TypeFunc::Parms + 1;
    1.42 +
    1.43 +//----------------------------IdealKit-----------------------------------------
    1.44 +IdealKit::IdealKit(GraphKit* gkit, bool delay_all_transforms, bool has_declarations) :
    1.45 +  _gvn(gkit->gvn()), C(gkit->C) {
    1.46 +  _initial_ctrl = gkit->control();
    1.47 +  _initial_memory = gkit->merged_memory();
    1.48 +  _initial_i_o = gkit->i_o();
    1.49 +  _delay_all_transforms = delay_all_transforms;
    1.50 +  _var_ct = 0;
    1.51 +  _cvstate = NULL;
    1.52 +  // We can go memory state free or else we need the entire memory state
    1.53 +  assert(_initial_memory == NULL || _initial_memory->Opcode() == Op_MergeMem, "memory must be pre-split");
    1.54 +  assert(!_gvn.is_IterGVN(), "IdealKit can't be used during Optimize phase");
    1.55 +  int init_size = 5;
    1.56 +  _pending_cvstates = new (C->node_arena()) GrowableArray<Node*>(C->node_arena(), init_size, 0, 0);
    1.57 +  DEBUG_ONLY(_state = new (C->node_arena()) GrowableArray<int>(C->node_arena(), init_size, 0, 0));
    1.58 +  if (!has_declarations) {
    1.59 +     declarations_done();
    1.60 +  }
    1.61 +}
    1.62 +
    1.63 +//----------------------------sync_kit-----------------------------------------
    1.64 +void IdealKit::sync_kit(GraphKit* gkit) {
    1.65 +  set_all_memory(gkit->merged_memory());
    1.66 +  set_i_o(gkit->i_o());
    1.67 +  set_ctrl(gkit->control());
    1.68 +}
    1.69 +
    1.70 +//-------------------------------if_then-------------------------------------
    1.71 +// Create:  if(left relop right)
    1.72 +//          /  \
    1.73 +//   iffalse    iftrue
    1.74 +// Push the iffalse cvstate onto the stack. The iftrue becomes the current cvstate.
    1.75 +void IdealKit::if_then(Node* left, BoolTest::mask relop,
    1.76 +                       Node* right, float prob, float cnt, bool push_new_state) {
    1.77 +  assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new If");
    1.78 +  Node* bol;
    1.79 +  if (left->bottom_type()->isa_ptr() == NULL) {
    1.80 +    if (left->bottom_type()->isa_int() != NULL) {
    1.81 +      bol = Bool(CmpI(left, right), relop);
    1.82 +    } else {
    1.83 +      assert(left->bottom_type()->isa_long() != NULL, "what else?");
    1.84 +      bol = Bool(CmpL(left, right), relop);
    1.85 +    }
    1.86 +
    1.87 +  } else {
    1.88 +    bol = Bool(CmpP(left, right), relop);
    1.89 +  }
    1.90 +  // Delay gvn.tranform on if-nodes until construction is finished
    1.91 +  // to prevent a constant bool input from discarding a control output.
    1.92 +  IfNode* iff = delay_transform(new (C) IfNode(ctrl(), bol, prob, cnt))->as_If();
    1.93 +  Node* then  = IfTrue(iff);
    1.94 +  Node* elsen = IfFalse(iff);
    1.95 +  Node* else_cvstate = copy_cvstate();
    1.96 +  else_cvstate->set_req(TypeFunc::Control, elsen);
    1.97 +  _pending_cvstates->push(else_cvstate);
    1.98 +  DEBUG_ONLY(if (push_new_state) _state->push(IfThenS));
    1.99 +  set_ctrl(then);
   1.100 +}
   1.101 +
   1.102 +//-------------------------------else_-------------------------------------
   1.103 +// Pop the else cvstate off the stack, and push the (current) then cvstate.
   1.104 +// The else cvstate becomes the current cvstate.
   1.105 +void IdealKit::else_() {
   1.106 +  assert(state() == IfThenS, "bad state for new Else");
   1.107 +  Node* else_cvstate = _pending_cvstates->pop();
   1.108 +  DEBUG_ONLY(_state->pop());
   1.109 +  // save current (then) cvstate for later use at endif
   1.110 +  _pending_cvstates->push(_cvstate);
   1.111 +  DEBUG_ONLY(_state->push(ElseS));
   1.112 +  _cvstate = else_cvstate;
   1.113 +}
   1.114 +
   1.115 +//-------------------------------end_if-------------------------------------
   1.116 +// Merge the "then" and "else" cvstates.
   1.117 +//
   1.118 +// The if_then() pushed a copy of the current state for later use
   1.119 +// as the initial state for a future "else" clause.  The
   1.120 +// current state then became the initial state for the
   1.121 +// then clause.  If an "else" clause was encountered, it will
   1.122 +// pop the top state and use it for it's initial state.
   1.123 +// It will also push the current state (the state at the end of
   1.124 +// the "then" clause) for latter use at the end_if.
   1.125 +//
   1.126 +// At the endif, the states are:
   1.127 +// 1) else exists a) current state is end of "else" clause
   1.128 +//                b) top stack state is end of "then" clause
   1.129 +//
   1.130 +// 2) no else:    a) current state is end of "then" clause
   1.131 +//                b) top stack state is from the "if_then" which
   1.132 +//                   would have been the initial state of the else.
   1.133 +//
   1.134 +// Merging the states is accomplished by:
   1.135 +//   1) make a label for the merge
   1.136 +//   2) terminate the current state with a goto to the label
   1.137 +//   3) pop the top state from the stack and make it the
   1.138 +//        current state
   1.139 +//   4) bind the label at the current state.  Binding a label
   1.140 +//        terminates the current state with a goto to the
   1.141 +//        label and makes the label's state the current state.
   1.142 +//
   1.143 +void IdealKit::end_if() {
   1.144 +  assert(state() & (IfThenS|ElseS), "bad state for new Endif");
   1.145 +  Node* lab = make_label(1);
   1.146 +
   1.147 +  // Node* join_state = _pending_cvstates->pop();
   1.148 +                  /* merging, join */
   1.149 +  goto_(lab);
   1.150 +  _cvstate = _pending_cvstates->pop();
   1.151 +
   1.152 +  bind(lab);
   1.153 +  DEBUG_ONLY(_state->pop());
   1.154 +}
   1.155 +
   1.156 +//-------------------------------loop-------------------------------------
   1.157 +// Create the loop head portion (*) of:
   1.158 +//  *     iv = init
   1.159 +//  *  top: (region node)
   1.160 +//  *     if (iv relop limit) {
   1.161 +//           loop body
   1.162 +//           i = i + 1
   1.163 +//           goto top
   1.164 +//  *     } else // exits loop
   1.165 +//
   1.166 +// Pushes the loop top cvstate first, then the else (loop exit) cvstate
   1.167 +// onto the stack.
   1.168 +void IdealKit::loop(GraphKit* gkit, int nargs, IdealVariable& iv, Node* init, BoolTest::mask relop, Node* limit, float prob, float cnt) {
   1.169 +  assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new loop");
   1.170 +  if (UseLoopPredicate) {
   1.171 +    // Sync IdealKit and graphKit.
   1.172 +    gkit->sync_kit(*this);
   1.173 +    // Add loop predicate.
   1.174 +    gkit->add_predicate(nargs);
   1.175 +    // Update IdealKit memory.
   1.176 +    sync_kit(gkit);
   1.177 +  }
   1.178 +  set(iv, init);
   1.179 +  Node* head = make_label(1);
   1.180 +  bind(head);
   1.181 +  _pending_cvstates->push(head); // push for use at end_loop
   1.182 +  _cvstate = copy_cvstate();
   1.183 +  if_then(value(iv), relop, limit, prob, cnt, false /* no new state */);
   1.184 +  DEBUG_ONLY(_state->push(LoopS));
   1.185 +  assert(ctrl()->is_IfTrue(), "true branch stays in loop");
   1.186 +  assert(_pending_cvstates->top()->in(TypeFunc::Control)->is_IfFalse(), "false branch exits loop");
   1.187 +}
   1.188 +
   1.189 +//-------------------------------end_loop-------------------------------------
   1.190 +// Creates the goto top label.
   1.191 +// Expects the else (loop exit) cvstate to be on top of the
   1.192 +// stack, and the loop top cvstate to be 2nd.
   1.193 +void IdealKit::end_loop() {
   1.194 +  assert((state() == LoopS), "bad state for new end_loop");
   1.195 +  Node* exit = _pending_cvstates->pop();
   1.196 +  Node* head = _pending_cvstates->pop();
   1.197 +  goto_(head);
   1.198 +  clear(head);
   1.199 +  DEBUG_ONLY(_state->pop());
   1.200 +  _cvstate = exit;
   1.201 +}
   1.202 +
   1.203 +//-------------------------------make_label-------------------------------------
   1.204 +// Creates a label.  The number of goto's
   1.205 +// must be specified (which should be 1 less than
   1.206 +// the number of precedessors.)
   1.207 +Node* IdealKit::make_label(int goto_ct) {
   1.208 +  assert(_cvstate != NULL, "must declare variables before labels");
   1.209 +  Node* lab = new_cvstate();
   1.210 +  int sz = 1 + goto_ct + 1 /* fall thru */;
   1.211 +  Node* reg = delay_transform(new (C) RegionNode(sz));
   1.212 +  lab->init_req(TypeFunc::Control, reg);
   1.213 +  return lab;
   1.214 +}
   1.215 +
   1.216 +//-------------------------------bind-------------------------------------
   1.217 +// Bind a label at the current cvstate by simulating
   1.218 +// a goto to the label.
   1.219 +void IdealKit::bind(Node* lab) {
   1.220 +  goto_(lab, true /* bind */);
   1.221 +  _cvstate = lab;
   1.222 +}
   1.223 +
   1.224 +//-------------------------------goto_-------------------------------------
   1.225 +// Make the current cvstate a predecessor of the label,
   1.226 +// creating phi's to merge values.  If bind is true and
   1.227 +// this is not the last control edge, then ensure that
   1.228 +// all live values have phis created. Used to create phis
   1.229 +// at loop-top regions.
   1.230 +void IdealKit::goto_(Node* lab, bool bind) {
   1.231 +  Node* reg = lab->in(TypeFunc::Control);
   1.232 +  // find next empty slot in region
   1.233 +  uint slot = 1;
   1.234 +  while (slot < reg->req() && reg->in(slot) != NULL) slot++;
   1.235 +  assert(slot < reg->req(), "too many gotos");
   1.236 +  // If this is last predecessor, then don't force phi creation
   1.237 +  if (slot == reg->req() - 1) bind = false;
   1.238 +  reg->init_req(slot, ctrl());
   1.239 +  assert(first_var + _var_ct == _cvstate->req(), "bad _cvstate size");
   1.240 +  for (uint i = first_var; i < _cvstate->req(); i++) {
   1.241 +
   1.242 +    // l is the value of var reaching the label. Could be a single value
   1.243 +    // reaching the label, or a phi that merges multiples values reaching
   1.244 +    // the label.  The latter is true if the label's input: in(..) is
   1.245 +    // a phi whose control input is the region node for the label.
   1.246 +
   1.247 +    Node* l = lab->in(i);
   1.248 +    // Get the current value of the var
   1.249 +    Node* m = _cvstate->in(i);
   1.250 +    // If the var went unused no need for a phi
   1.251 +    if (m == NULL) {
   1.252 +      continue;
   1.253 +    } else if (l == NULL || m == l) {
   1.254 +      // Only one unique value "m" is known to reach this label so a phi
   1.255 +      // is not yet necessary unless:
   1.256 +      //    the label is being bound and all predecessors have not been seen,
   1.257 +      //    in which case "bind" will be true.
   1.258 +      if (bind) {
   1.259 +        m = promote_to_phi(m, reg);
   1.260 +      }
   1.261 +      // Record the phi/value used for this var in the label's cvstate
   1.262 +      lab->set_req(i, m);
   1.263 +    } else {
   1.264 +      // More than one value for the variable reaches this label so
   1.265 +      // a create a phi if one does not already exist.
   1.266 +      if (!was_promoted_to_phi(l, reg)) {
   1.267 +        l = promote_to_phi(l, reg);
   1.268 +        lab->set_req(i, l);
   1.269 +      }
   1.270 +      // Record in the phi, the var's value from the current state
   1.271 +      l->set_req(slot, m);
   1.272 +    }
   1.273 +  }
   1.274 +  do_memory_merge(_cvstate, lab);
   1.275 +  stop();
   1.276 +}
   1.277 +
   1.278 +//-----------------------------promote_to_phi-----------------------------------
   1.279 +Node* IdealKit::promote_to_phi(Node* n, Node* reg) {
   1.280 +  assert(!was_promoted_to_phi(n, reg), "n already promoted to phi on this region");
   1.281 +  // Get a conservative type for the phi
   1.282 +  const BasicType bt = n->bottom_type()->basic_type();
   1.283 +  const Type* ct = Type::get_const_basic_type(bt);
   1.284 +  return delay_transform(PhiNode::make(reg, n, ct));
   1.285 +}
   1.286 +
   1.287 +//-----------------------------declarations_done-------------------------------
   1.288 +void IdealKit::declarations_done() {
   1.289 +  _cvstate = new_cvstate();   // initialize current cvstate
   1.290 +  set_ctrl(_initial_ctrl);    // initialize control in current cvstate
   1.291 +  set_all_memory(_initial_memory);// initialize memory in current cvstate
   1.292 +  set_i_o(_initial_i_o);      // initialize i_o in current cvstate
   1.293 +  DEBUG_ONLY(_state->push(BlockS));
   1.294 +}
   1.295 +
   1.296 +//-----------------------------transform-----------------------------------
   1.297 +Node* IdealKit::transform(Node* n) {
   1.298 +  if (_delay_all_transforms) {
   1.299 +    return delay_transform(n);
   1.300 +  } else {
   1.301 +    n = gvn().transform(n);
   1.302 +    C->record_for_igvn(n);
   1.303 +    return n;
   1.304 +  }
   1.305 +}
   1.306 +
   1.307 +//-----------------------------delay_transform-----------------------------------
   1.308 +Node* IdealKit::delay_transform(Node* n) {
   1.309 +  // Delay transform until IterativeGVN
   1.310 +  gvn().set_type(n, n->bottom_type());
   1.311 +  C->record_for_igvn(n);
   1.312 +  return n;
   1.313 +}
   1.314 +
   1.315 +//-----------------------------new_cvstate-----------------------------------
   1.316 +Node* IdealKit::new_cvstate() {
   1.317 +  uint sz = _var_ct + first_var;
   1.318 +  return new (C) Node(sz);
   1.319 +}
   1.320 +
   1.321 +//-----------------------------copy_cvstate-----------------------------------
   1.322 +Node* IdealKit::copy_cvstate() {
   1.323 +  Node* ns = new_cvstate();
   1.324 +  for (uint i = 0; i < ns->req(); i++) ns->init_req(i, _cvstate->in(i));
   1.325 +  // We must clone memory since it will be updated as we do stores.
   1.326 +  ns->set_req(TypeFunc::Memory, MergeMemNode::make(C, ns->in(TypeFunc::Memory)));
   1.327 +  return ns;
   1.328 +}
   1.329 +
   1.330 +//-----------------------------clear-----------------------------------
   1.331 +void IdealKit::clear(Node* m) {
   1.332 +  for (uint i = 0; i < m->req(); i++) m->set_req(i, NULL);
   1.333 +}
   1.334 +
   1.335 +//-----------------------------IdealVariable----------------------------
   1.336 +IdealVariable::IdealVariable(IdealKit &k) {
   1.337 +  k.declare(this);
   1.338 +}
   1.339 +
   1.340 +Node* IdealKit::memory(uint alias_idx) {
   1.341 +  MergeMemNode* mem = merged_memory();
   1.342 +  Node* p = mem->memory_at(alias_idx);
   1.343 +  _gvn.set_type(p, Type::MEMORY);  // must be mapped
   1.344 +  return p;
   1.345 +}
   1.346 +
   1.347 +void IdealKit::set_memory(Node* mem, uint alias_idx) {
   1.348 +  merged_memory()->set_memory_at(alias_idx, mem);
   1.349 +}
   1.350 +
   1.351 +//----------------------------- make_load ----------------------------
   1.352 +Node* IdealKit::load(Node* ctl,
   1.353 +                     Node* adr,
   1.354 +                     const Type* t,
   1.355 +                     BasicType bt,
   1.356 +                     int adr_idx,
   1.357 +                     bool require_atomic_access) {
   1.358 +
   1.359 +  assert(adr_idx != Compile::AliasIdxTop, "use other make_load factory" );
   1.360 +  const TypePtr* adr_type = NULL; // debug-mode-only argument
   1.361 +  debug_only(adr_type = C->get_adr_type(adr_idx));
   1.362 +  Node* mem = memory(adr_idx);
   1.363 +  Node* ld;
   1.364 +  if (require_atomic_access && bt == T_LONG) {
   1.365 +    ld = LoadLNode::make_atomic(C, ctl, mem, adr, adr_type, t, MemNode::unordered);
   1.366 +  } else {
   1.367 +    ld = LoadNode::make(_gvn, ctl, mem, adr, adr_type, t, bt, MemNode::unordered);
   1.368 +  }
   1.369 +  return transform(ld);
   1.370 +}
   1.371 +
   1.372 +Node* IdealKit::store(Node* ctl, Node* adr, Node *val, BasicType bt,
   1.373 +                      int adr_idx,
   1.374 +                      MemNode::MemOrd mo, bool require_atomic_access) {
   1.375 +  assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory");
   1.376 +  const TypePtr* adr_type = NULL;
   1.377 +  debug_only(adr_type = C->get_adr_type(adr_idx));
   1.378 +  Node *mem = memory(adr_idx);
   1.379 +  Node* st;
   1.380 +  if (require_atomic_access && bt == T_LONG) {
   1.381 +    st = StoreLNode::make_atomic(C, ctl, mem, adr, adr_type, val, mo);
   1.382 +  } else {
   1.383 +    st = StoreNode::make(_gvn, ctl, mem, adr, adr_type, val, bt, mo);
   1.384 +  }
   1.385 +  st = transform(st);
   1.386 +  set_memory(st, adr_idx);
   1.387 +
   1.388 +  return st;
   1.389 +}
   1.390 +
   1.391 +// Card mark store. Must be ordered so that it will come after the store of
   1.392 +// the oop.
   1.393 +Node* IdealKit::storeCM(Node* ctl, Node* adr, Node *val, Node* oop_store, int oop_adr_idx,
   1.394 +                        BasicType bt,
   1.395 +                        int adr_idx) {
   1.396 +  assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" );
   1.397 +  const TypePtr* adr_type = NULL;
   1.398 +  debug_only(adr_type = C->get_adr_type(adr_idx));
   1.399 +  Node *mem = memory(adr_idx);
   1.400 +
   1.401 +  // Add required edge to oop_store, optimizer does not support precedence edges.
   1.402 +  // Convert required edge to precedence edge before allocation.
   1.403 +  Node* st = new (C) StoreCMNode(ctl, mem, adr, adr_type, val, oop_store, oop_adr_idx);
   1.404 +
   1.405 +  st = transform(st);
   1.406 +  set_memory(st, adr_idx);
   1.407 +
   1.408 +  return st;
   1.409 +}
   1.410 +
   1.411 +//---------------------------- do_memory_merge --------------------------------
   1.412 +// The memory from one merging cvstate needs to be merged with the memory for another
   1.413 +// join cvstate. If the join cvstate doesn't have a merged memory yet then we
   1.414 +// can just copy the state from the merging cvstate
   1.415 +
   1.416 +// Merge one slow path into the rest of memory.
   1.417 +void IdealKit::do_memory_merge(Node* merging, Node* join) {
   1.418 +
   1.419 +  // Get the region for the join state
   1.420 +  Node* join_region = join->in(TypeFunc::Control);
   1.421 +  assert(join_region != NULL, "join region must exist");
   1.422 +  if (join->in(TypeFunc::I_O) == NULL ) {
   1.423 +    join->set_req(TypeFunc::I_O,  merging->in(TypeFunc::I_O));
   1.424 +  }
   1.425 +  if (join->in(TypeFunc::Memory) == NULL ) {
   1.426 +    join->set_req(TypeFunc::Memory,  merging->in(TypeFunc::Memory));
   1.427 +    return;
   1.428 +  }
   1.429 +
   1.430 +  // The control flow for merging must have already been attached to the join region
   1.431 +  // we need its index for the phis.
   1.432 +  uint slot;
   1.433 +  for (slot = 1; slot < join_region->req() ; slot ++ ) {
   1.434 +    if (join_region->in(slot) == merging->in(TypeFunc::Control)) break;
   1.435 +  }
   1.436 +  assert(slot !=  join_region->req(), "edge must already exist");
   1.437 +
   1.438 +  MergeMemNode* join_m    = join->in(TypeFunc::Memory)->as_MergeMem();
   1.439 +  MergeMemNode* merging_m = merging->in(TypeFunc::Memory)->as_MergeMem();
   1.440 +
   1.441 +  // join_m should be an ancestor mergemem of merging
   1.442 +  // Slow path memory comes from the current map (which is from a slow call)
   1.443 +  // Fast path/null path memory comes from the call's input
   1.444 +
   1.445 +  // Merge the other fast-memory inputs with the new slow-default memory.
   1.446 +  // for (MergeMemStream mms(merged_memory(), fast_mem->as_MergeMem()); mms.next_non_empty2(); ) {
   1.447 +  for (MergeMemStream mms(join_m, merging_m); mms.next_non_empty2(); ) {
   1.448 +    Node* join_slice = mms.force_memory();
   1.449 +    Node* merging_slice = mms.memory2();
   1.450 +    if (join_slice != merging_slice) {
   1.451 +      PhiNode* phi;
   1.452 +      // bool new_phi = false;
   1.453 +      // Is the phi for this slice one that we created for this join region or simply
   1.454 +      // one we copied? If it is ours then add
   1.455 +      if (join_slice->is_Phi() && join_slice->as_Phi()->region() == join_region) {
   1.456 +        phi = join_slice->as_Phi();
   1.457 +      } else {
   1.458 +        // create the phi with join_slice filling supplying memory for all of the
   1.459 +        // control edges to the join region
   1.460 +        phi = PhiNode::make(join_region, join_slice, Type::MEMORY, mms.adr_type(C));
   1.461 +        phi = (PhiNode*) delay_transform(phi);
   1.462 +        // gvn().set_type(phi, Type::MEMORY);
   1.463 +        // new_phi = true;
   1.464 +      }
   1.465 +      // Now update the phi with the slice for the merging slice
   1.466 +      phi->set_req(slot, merging_slice/* slow_path, slow_slice */);
   1.467 +      // this updates join_m with the phi
   1.468 +      mms.set_memory(phi);
   1.469 +    }
   1.470 +  }
   1.471 +
   1.472 +  Node* join_io    = join->in(TypeFunc::I_O);
   1.473 +  Node* merging_io = merging->in(TypeFunc::I_O);
   1.474 +  if (join_io != merging_io) {
   1.475 +    PhiNode* phi;
   1.476 +    if (join_io->is_Phi() && join_io->as_Phi()->region() == join_region) {
   1.477 +      phi = join_io->as_Phi();
   1.478 +    } else {
   1.479 +      phi = PhiNode::make(join_region, join_io, Type::ABIO);
   1.480 +      phi = (PhiNode*) delay_transform(phi);
   1.481 +      join->set_req(TypeFunc::I_O, phi);
   1.482 +    }
   1.483 +    phi->set_req(slot, merging_io);
   1.484 +  }
   1.485 +}
   1.486 +
   1.487 +
   1.488 +//----------------------------- make_call  ----------------------------
   1.489 +// Trivial runtime call
   1.490 +void IdealKit::make_leaf_call(const TypeFunc *slow_call_type,
   1.491 +                              address slow_call,
   1.492 +                              const char *leaf_name,
   1.493 +                              Node* parm0,
   1.494 +                              Node* parm1,
   1.495 +                              Node* parm2,
   1.496 +                              Node* parm3) {
   1.497 +
   1.498 +  // We only handle taking in RawMem and modifying RawMem
   1.499 +  const TypePtr* adr_type = TypeRawPtr::BOTTOM;
   1.500 +  uint adr_idx = C->get_alias_index(adr_type);
   1.501 +
   1.502 +  // Slow-path leaf call
   1.503 +  CallNode *call =  (CallNode*)new (C) CallLeafNode( slow_call_type, slow_call, leaf_name, adr_type);
   1.504 +
   1.505 +  // Set fixed predefined input arguments
   1.506 +  call->init_req( TypeFunc::Control, ctrl() );
   1.507 +  call->init_req( TypeFunc::I_O    , top() )     ;   // does no i/o
   1.508 +  // Narrow memory as only memory input
   1.509 +  call->init_req( TypeFunc::Memory , memory(adr_idx));
   1.510 +  call->init_req( TypeFunc::FramePtr, top() /* frameptr() */ );
   1.511 +  call->init_req( TypeFunc::ReturnAdr, top() );
   1.512 +
   1.513 +  if (parm0 != NULL)  call->init_req(TypeFunc::Parms+0, parm0);
   1.514 +  if (parm1 != NULL)  call->init_req(TypeFunc::Parms+1, parm1);
   1.515 +  if (parm2 != NULL)  call->init_req(TypeFunc::Parms+2, parm2);
   1.516 +  if (parm3 != NULL)  call->init_req(TypeFunc::Parms+3, parm3);
   1.517 +
   1.518 +  // Node *c = _gvn.transform(call);
   1.519 +  call = (CallNode *) _gvn.transform(call);
   1.520 +  Node *c = call; // dbx gets confused with call call->dump()
   1.521 +
   1.522 +  // Slow leaf call has no side-effects, sets few values
   1.523 +
   1.524 +  set_ctrl(transform( new (C) ProjNode(call,TypeFunc::Control) ));
   1.525 +
   1.526 +  // Make memory for the call
   1.527 +  Node* mem = _gvn.transform( new (C) ProjNode(call, TypeFunc::Memory) );
   1.528 +
   1.529 +  // Set the RawPtr memory state only.
   1.530 +  set_memory(mem, adr_idx);
   1.531 +
   1.532 +  assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type),
   1.533 +         "call node must be constructed correctly");
   1.534 +}
   1.535 +
   1.536 +
   1.537 +void IdealKit::make_leaf_call_no_fp(const TypeFunc *slow_call_type,
   1.538 +                              address slow_call,
   1.539 +                              const char *leaf_name,
   1.540 +                              const TypePtr* adr_type,
   1.541 +                              Node* parm0,
   1.542 +                              Node* parm1,
   1.543 +                              Node* parm2,
   1.544 +                              Node* parm3) {
   1.545 +
   1.546 +  // We only handle taking in RawMem and modifying RawMem
   1.547 +  uint adr_idx = C->get_alias_index(adr_type);
   1.548 +
   1.549 +  // Slow-path leaf call
   1.550 +  CallNode *call =  (CallNode*)new (C) CallLeafNoFPNode( slow_call_type, slow_call, leaf_name, adr_type);
   1.551 +
   1.552 +  // Set fixed predefined input arguments
   1.553 +  call->init_req( TypeFunc::Control, ctrl() );
   1.554 +  call->init_req( TypeFunc::I_O    , top() )     ;   // does no i/o
   1.555 +  // Narrow memory as only memory input
   1.556 +  call->init_req( TypeFunc::Memory , memory(adr_idx));
   1.557 +  call->init_req( TypeFunc::FramePtr, top() /* frameptr() */ );
   1.558 +  call->init_req( TypeFunc::ReturnAdr, top() );
   1.559 +
   1.560 +  if (parm0 != NULL)  call->init_req(TypeFunc::Parms+0, parm0);
   1.561 +  if (parm1 != NULL)  call->init_req(TypeFunc::Parms+1, parm1);
   1.562 +  if (parm2 != NULL)  call->init_req(TypeFunc::Parms+2, parm2);
   1.563 +  if (parm3 != NULL)  call->init_req(TypeFunc::Parms+3, parm3);
   1.564 +
   1.565 +  // Node *c = _gvn.transform(call);
   1.566 +  call = (CallNode *) _gvn.transform(call);
   1.567 +  Node *c = call; // dbx gets confused with call call->dump()
   1.568 +
   1.569 +  // Slow leaf call has no side-effects, sets few values
   1.570 +
   1.571 +  set_ctrl(transform( new (C) ProjNode(call,TypeFunc::Control) ));
   1.572 +
   1.573 +  // Make memory for the call
   1.574 +  Node* mem = _gvn.transform( new (C) ProjNode(call, TypeFunc::Memory) );
   1.575 +
   1.576 +  // Set the RawPtr memory state only.
   1.577 +  set_memory(mem, adr_idx);
   1.578 +
   1.579 +  assert(C->alias_type(call->adr_type()) == C->alias_type(adr_type),
   1.580 +         "call node must be constructed correctly");
   1.581 +}

mercurial