hotspot/src/share/vm/opto/rootnode.cpp
author kvn
Tue, 05 Nov 2013 17:38:04 -0800
changeset 22838 82c7497fbad4
parent 7397 5b173b4ca846
child 25913 81dbc151e91c
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "opto/callnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "opto/cfgnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "opto/phaseX.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "opto/regmask.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "opto/rootnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "opto/subnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "opto/type.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
//------------------------------Ideal------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// Remove dead inputs
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
Node *RootNode::Ideal(PhaseGVN *phase, bool can_reshape) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  for( uint i = 1; i < req(); i++ ) { // For all inputs
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    // Check for and remove dead inputs
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    if( phase->type(in(i)) == Type::TOP ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
      del_req(i--);             // Delete TOP inputs
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // I used to do tail-splitting in the Ideal graph here, but it does not
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  // work.  The tail-splitting forces values live into the Return to be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // ready at a point which dominates the split returns.  This forces Stores
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // to be hoisted high.  The "proper" fix would be to split Stores down
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  // each path, but this makes the split unprofitable.  If we want to do this
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  // optimization, it needs to be done after allocation so we can count all
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // the instructions needing to be cloned in the cost metric.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // There used to be a spoof here for caffeine marks which completely
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // eliminated very simple self-recursion recursions, but it's not worth it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Deep inlining of self-calls gets nearly all of the same benefits.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // If we want to get the rest of the win later, we should pattern match
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // simple recursive call trees to closed-form solutions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  return NULL;                  // No further opportunities exposed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
HaltNode::HaltNode( Node *ctrl, Node *frameptr ) : Node(TypeFunc::Parms) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  Node* top = Compile::current()->top();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  init_req(TypeFunc::Control,  ctrl        );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  init_req(TypeFunc::I_O,      top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  init_req(TypeFunc::Memory,   top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  init_req(TypeFunc::FramePtr, frameptr    );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  init_req(TypeFunc::ReturnAdr,top);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
const Type *HaltNode::bottom_type() const { return Type::BOTTOM; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
//------------------------------Ideal------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
Node *HaltNode::Ideal(PhaseGVN *phase, bool can_reshape) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  return remove_dead_region(phase, can_reshape) ? this : NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
//------------------------------Value------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
const Type *HaltNode::Value( PhaseTransform *phase ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  return ( phase->type(in(TypeFunc::Control)) == Type::TOP)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    ? Type::TOP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    : Type::BOTTOM;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
const RegMask &HaltNode::out_RegMask() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  return RegMask::Empty;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
}