hotspot/src/share/vm/opto/multnode.cpp
author roland
Fri, 23 Jun 2017 09:33:21 +0200
changeset 45766 4b5557c9b656
parent 35551 36ef3841fb34
child 46589 f1c04490ded1
permissions -rw-r--r--
8181742: Load that bypasses arraycopy has wrong memory state Summary: Set load memory edge to the memory state right before the arraycopy. Reviewed-by: kvn, thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
32084
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
     2
 * Copyright (c) 1997, 2015, 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"
17383
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    26
#include "opto/callnode.hpp"
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
    27
#include "opto/cfgnode.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "opto/matcher.hpp"
20289
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 17383
diff changeset
    29
#include "opto/mathexactnode.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
#include "opto/multnode.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "opto/opcodes.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    32
#include "opto/phaseX.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    33
#include "opto/regmask.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    34
#include "opto/type.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
//------------------------------MultiNode--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
const RegMask &MultiNode::out_RegMask() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  return RegMask::Empty;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
Node *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
//------------------------------proj_out---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// Get a named projection
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
ProjNode* MultiNode::proj_out(uint which_proj) const {
34164
a9e6034d7707 8137168: Replace IfNode with a new RangeCheckNode for range checks
roland
parents: 32084
diff changeset
    47
  assert((Opcode() != Op_If && Opcode() != Op_RangeCheck) || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0");
a9e6034d7707 8137168: Replace IfNode with a new RangeCheckNode for range checks
roland
parents: 32084
diff changeset
    48
  assert((Opcode() != Op_If && Opcode() != Op_RangeCheck) || outcnt() == 2, "bad if #1");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    Node *p = fast_out(i);
20289
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 17383
diff changeset
    51
    if (p->is_Proj()) {
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 17383
diff changeset
    52
      ProjNode *proj = p->as_Proj();
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 17383
diff changeset
    53
      if (proj->_con == which_proj) {
34164
a9e6034d7707 8137168: Replace IfNode with a new RangeCheckNode for range checks
roland
parents: 32084
diff changeset
    54
        assert((Opcode() != Op_If && Opcode() != Op_RangeCheck) || proj->Opcode() == (which_proj ? Op_IfTrue : Op_IfFalse), "bad if #2");
20289
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 17383
diff changeset
    55
        return proj;
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 17383
diff changeset
    56
      }
35d78de0c547 8024924: Intrinsify java.lang.Math.addExact
rbackman
parents: 17383
diff changeset
    57
    } else {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
      assert(p == this && this->is_Start(), "else must be proj");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
      continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
//=============================================================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
//------------------------------ProjNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
uint ProjNode::hash() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // only one input
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  return (uintptr_t)in(TypeFunc::Control) + (_con << 1) + (_is_io_use ? 1 : 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
uint ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
uint ProjNode::size_of() const { return sizeof(ProjNode); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
// Test if we propagate interesting control along this projection
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
bool ProjNode::is_CFG() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  Node *def = in(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  return (_con == TypeFunc::Control && def->is_CFG());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
17383
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    80
const Type* ProjNode::proj_type(const Type* t) const {
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    81
  if (t == Type::TOP) {
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    82
    return Type::TOP;
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    83
  }
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    84
  if (t == Type::BOTTOM) {
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    85
    return Type::BOTTOM;
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    86
  }
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    87
  t = t->is_tuple()->field_at(_con);
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    88
  Node* n = in(0);
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    89
  if ((_con == TypeFunc::Parms) &&
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    90
      n->is_CallStaticJava() && n->as_CallStaticJava()->is_boxing_method()) {
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    91
    // The result of autoboxing is always non-null on normal path.
22799
83e58bac7980 8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed
roland
parents: 22234
diff changeset
    92
    t = t->join_speculative(TypePtr::NOTNULL);
17383
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    93
  }
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    94
  return t;
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    95
}
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    96
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
const Type *ProjNode::bottom_type() const {
17383
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    98
  if (in(0) == NULL) return Type::TOP;
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
    99
  return proj_type(in(0)->bottom_type());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
const TypePtr *ProjNode::adr_type() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  if (bottom_type() == Type::MEMORY) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    // in(0) might be a narrow MemBar; otherwise we will report TypePtr::BOTTOM
27697
ae60f551e5c8 8062258: compiler/debug/TraceIterativeGVN.java segfaults in trace_PhaseIterGVN
vlivanov
parents: 23217
diff changeset
   105
    Node* ctrl = in(0);
ae60f551e5c8 8062258: compiler/debug/TraceIterativeGVN.java segfaults in trace_PhaseIterGVN
vlivanov
parents: 23217
diff changeset
   106
    if (ctrl == NULL)  return NULL; // node is dead
ae60f551e5c8 8062258: compiler/debug/TraceIterativeGVN.java segfaults in trace_PhaseIterGVN
vlivanov
parents: 23217
diff changeset
   107
    const TypePtr* adr_type = ctrl->adr_type();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    if (!is_error_reported() && !Node::in_dump())
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
      assert(adr_type != NULL, "source must have adr_type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    #endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    return adr_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  assert(bottom_type()->base() != Type::Memory, "no other memories?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
bool ProjNode::pinned() const { return in(0)->pinned(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
void ProjNode::dump_spec(outputStream *st) const { st->print("#%d",_con); if(_is_io_use) st->print(" (i_o_use)");}
32084
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   121
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   122
void ProjNode::dump_compact_spec(outputStream *st) const {
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   123
  for (DUIterator i = this->outs(); this->has_out(i); i++) {
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   124
    Node* o = this->out(i);
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   125
    if (NotANode(o)) {
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   126
      st->print("[?]");
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   127
    } else if (o == NULL) {
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   128
      st->print("[_]");
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   129
    } else {
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   130
      st->print("[%d]", o->_idx);
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   131
    }
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   132
  }
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   133
  st->print("#%d", _con);
7743e6943cdf 8004073: Implement C2 Ideal node specific dump() method
mhaupt
parents: 30183
diff changeset
   134
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
//----------------------------check_con----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
void ProjNode::check_con() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  Node* n = in(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  if (n == NULL)       return;  // should be assert, but NodeHash makes bogons
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  if (n->is_Mach())    return;  // mach. projs. are not type-safe
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  if (n->is_Start())   return;  // alas, starts can have mach. projs. also
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  if (_con == SCMemProjNode::SCMEMPROJCON ) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  const Type* t = n->bottom_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  if (t == Type::TOP)  return;  // multi is dead
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  assert(_con < t->is_tuple()->cnt(), "ProjNode::_con must be in range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
//------------------------------Value------------------------------------------
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 34164
diff changeset
   150
const Type* ProjNode::Value(PhaseGVN* phase) const {
17383
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
   151
  if (in(0) == NULL) return Type::TOP;
3665c0901a0d 6934604: enable parts of EliminateAutoBox by default
kvn
parents: 13728
diff changeset
   152
  return proj_type(phase->type(in(0)));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
//------------------------------out_RegMask------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
// Pass the buck uphill
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
const RegMask &ProjNode::out_RegMask() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  return RegMask::Empty;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
//------------------------------ideal_reg--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
uint ProjNode::ideal_reg() const {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 7397
diff changeset
   163
  return bottom_type()->ideal_reg();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
}
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   165
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   166
//-------------------------------is_uncommon_trap_proj----------------------------
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   167
// Return uncommon trap call node if proj is for "proj->[region->..]call_uct"
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   168
// NULL otherwise
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   169
CallStaticJavaNode* ProjNode::is_uncommon_trap_proj(Deoptimization::DeoptReason reason) {
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   170
  int path_limit = 10;
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   171
  Node* out = this;
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   172
  for (int ct = 0; ct < path_limit; ct++) {
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   173
    out = out->unique_ctrl_out();
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   174
    if (out == NULL)
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   175
      return NULL;
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   176
    if (out->is_CallStaticJava()) {
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   177
      CallStaticJavaNode* call = out->as_CallStaticJava();
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   178
      int req = call->uncommon_trap_request();
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   179
      if (req != 0) {
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   180
        Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req);
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   181
        if (trap_reason == reason || reason == Deoptimization::Reason_none) {
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   182
          return call;
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   183
        }
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   184
      }
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   185
      return NULL; // don't do further after call
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   186
    }
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   187
    if (out->Opcode() != Op_Region)
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   188
      return NULL;
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   189
  }
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   190
  return NULL;
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   191
}
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   192
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   193
//-------------------------------is_uncommon_trap_if_pattern-------------------------
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   194
// Return uncommon trap call node for    "if(test)-> proj -> ...
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   195
//                                                 |
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   196
//                                                 V
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   197
//                                             other_proj->[region->..]call_uct"
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   198
// NULL otherwise
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   199
// "must_reason_predicate" means the uct reason must be Reason_predicate
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   200
CallStaticJavaNode* ProjNode::is_uncommon_trap_if_pattern(Deoptimization::DeoptReason reason) {
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   201
  Node *in0 = in(0);
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   202
  if (!in0->is_If()) return NULL;
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   203
  // Variation of a dead If node.
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   204
  if (in0->outcnt() < 2)  return NULL;
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   205
  IfNode* iff = in0->as_If();
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   206
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   207
  // we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   208
  if (reason != Deoptimization::Reason_none) {
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   209
    if (iff->in(1)->Opcode() != Op_Conv2B ||
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   210
       iff->in(1)->in(1)->Opcode() != Op_Opaque1) {
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   211
      return NULL;
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   212
    }
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   213
  }
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   214
23217
35c6db6d3575 8028037: [parfait] warnings from b114 for hotspot.src.share.vm
drchase
parents: 22911
diff changeset
   215
  ProjNode* other_proj = iff->proj_out(1-_con);
35c6db6d3575 8028037: [parfait] warnings from b114 for hotspot.src.share.vm
drchase
parents: 22911
diff changeset
   216
  if (other_proj == NULL) // Should never happen, but make Parfait happy.
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   217
      return NULL;
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   218
  CallStaticJavaNode* call = other_proj->is_uncommon_trap_proj(reason);
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   219
  if (call != NULL) {
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   220
    assert(reason == Deoptimization::Reason_none ||
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   221
           Compile::current()->is_predicate_opaq(iff->in(1)->in(1)), "should be on the list");
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   222
    return call;
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   223
  }
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   224
  return NULL;
21089
e1986ff6fe2e 8024069: replace_in_map() should operate on parent maps
roland
parents: 20289
diff changeset
   225
}
30183
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   226
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   227
ProjNode* ProjNode::other_if_proj() const {
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   228
  assert(_con == 0 || _con == 1, "not an if?");
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   229
  return in(0)->as_If()->proj_out(1-_con);
a6588c0a3259 8073480: C2 should optimize explicit range checks
roland
parents: 27697
diff changeset
   230
}