hotspot/src/share/vm/opto/castnode.cpp
author thartmann
Thu, 12 May 2016 08:25:42 +0200
changeset 38676 48614091c64b
parent 36072 2e822f451746
child 42041 f316fd20ed98
permissions -rw-r--r--
8155241: Crash with assert in Xcomp mode and with disabled ReduceBulkZeroing Summary: We should not assume that a CloneBasic arraycopy sets array initialization to complete. Reviewed-by: kvn, roland
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     1
/*
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     4
 *
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     7
 * published by the Free Software Foundation.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     8
 *
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    13
 * accompanied this code).
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    14
 *
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    18
 *
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    21
 * questions.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    22
 *
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    23
 */
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    24
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    25
#include "precompiled.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    26
#include "opto/addnode.hpp"
35545
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    27
#include "opto/callnode.hpp"
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    28
#include "opto/castnode.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    29
#include "opto/connode.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    30
#include "opto/matcher.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    31
#include "opto/phaseX.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    32
#include "opto/subnode.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    33
#include "opto/type.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    34
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    35
//=============================================================================
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    36
// If input is already higher or equal to cast type, then this is an identity.
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 35549
diff changeset
    37
Node* ConstraintCastNode::Identity(PhaseGVN* phase) {
35545
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    38
  Node* dom = dominating_cast(phase);
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    39
  if (dom != NULL) {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    40
    return dom;
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    41
  }
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    42
  if (_carry_dependency) {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    43
    return this;
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    44
  }
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    45
  return phase->type(in(1))->higher_equal_speculative(_type) ? in(1) : this;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    46
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    47
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    48
//------------------------------Value------------------------------------------
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    49
// Take 'join' of input and cast-up type
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 35549
diff changeset
    50
const Type* ConstraintCastNode::Value(PhaseGVN* phase) const {
35545
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    51
  if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP;
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    52
  const Type* ft = phase->type(in(1))->filter_speculative(_type);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    53
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    54
#ifdef ASSERT
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    55
  // Previous versions of this function had some special case logic,
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    56
  // which is no longer necessary.  Make sure of the required effects.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    57
  switch (Opcode()) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    58
    case Op_CastII:
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    59
    {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    60
      const Type* t1 = phase->type(in(1));
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    61
      if( t1 == Type::TOP )  assert(ft == Type::TOP, "special case #1");
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    62
      const Type* rt = t1->join_speculative(_type);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    63
      if (rt->empty())       assert(ft == Type::TOP, "special case #2");
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    64
      break;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    65
    }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    66
    case Op_CastPP:
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    67
    if (phase->type(in(1)) == TypePtr::NULL_PTR &&
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    68
        _type->isa_ptr() && _type->is_ptr()->_ptr == TypePtr::NotNull)
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    69
    assert(ft == Type::TOP, "special case #3");
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    70
    break;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    71
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    72
#endif //ASSERT
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    73
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    74
  return ft;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    75
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    76
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    77
//------------------------------Ideal------------------------------------------
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    78
// Return a node which is more "ideal" than the current node.  Strip out
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    79
// control copies
35545
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    80
Node *ConstraintCastNode::Ideal(PhaseGVN *phase, bool can_reshape) {
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    81
  return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    82
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    83
35545
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    84
uint ConstraintCastNode::cmp(const Node &n) const {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    85
  return TypeNode::cmp(n) && ((ConstraintCastNode&)n)._carry_dependency == _carry_dependency;
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    86
}
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    87
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    88
uint ConstraintCastNode::size_of() const {
27708
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
    89
  return sizeof(*this);
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
    90
}
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
    91
35545
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    92
Node* ConstraintCastNode::make_cast(int opcode, Node* c, Node *n, const Type *t, bool carry_dependency) {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    93
  switch(opcode) {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    94
  case Op_CastII: {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    95
    Node* cast = new CastIINode(n, t, carry_dependency);
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    96
    cast->set_req(0, c);
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    97
    return cast;
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    98
  }
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
    99
  case Op_CastPP: {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   100
    Node* cast = new CastPPNode(n, t, carry_dependency);
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   101
    cast->set_req(0, c);
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   102
    return cast;
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   103
  }
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   104
  case Op_CheckCastPP: return new CheckCastPPNode(c, n, t, carry_dependency);
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   105
  default:
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   106
    fatal("Bad opcode %d", opcode);
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   107
  }
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   108
  return NULL;
27708
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   109
}
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   110
35545
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   111
TypeNode* ConstraintCastNode::dominating_cast(PhaseTransform *phase) const {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   112
  Node* val = in(1);
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   113
  Node* ctl = in(0);
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   114
  int opc = Opcode();
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   115
  if (ctl == NULL) {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   116
    return NULL;
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   117
  }
36065
4f0e0cb7b016 8143542: C2 doesn't eliminate identical checks
roland
parents: 35574
diff changeset
   118
  // Range check CastIIs may all end up under a single range check and
4f0e0cb7b016 8143542: C2 doesn't eliminate identical checks
roland
parents: 35574
diff changeset
   119
  // in that case only the narrower CastII would be kept by the code
4f0e0cb7b016 8143542: C2 doesn't eliminate identical checks
roland
parents: 35574
diff changeset
   120
  // below which would be incorrect.
4f0e0cb7b016 8143542: C2 doesn't eliminate identical checks
roland
parents: 35574
diff changeset
   121
  if (is_CastII() && as_CastII()->has_range_check()) {
4f0e0cb7b016 8143542: C2 doesn't eliminate identical checks
roland
parents: 35574
diff changeset
   122
    return NULL;
4f0e0cb7b016 8143542: C2 doesn't eliminate identical checks
roland
parents: 35574
diff changeset
   123
  }
35545
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   124
  for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   125
    Node* u = val->fast_out(i);
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   126
    if (u != this &&
36072
2e822f451746 8149797: Compilation fails with "assert(in_hash) failed: node should be in igvn hash table"
roland
parents: 36065
diff changeset
   127
        u->outcnt() > 0 &&
35545
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   128
        u->Opcode() == opc &&
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   129
        u->in(0) != NULL &&
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   130
        u->bottom_type()->higher_equal(type())) {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   131
      if (phase->is_dominator(u->in(0), ctl)) {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   132
        return u->as_Type();
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   133
      }
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   134
      if (is_CheckCastPP() && u->in(1)->is_Proj() && u->in(1)->in(0)->is_Allocate() &&
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   135
          u->in(0)->is_Proj() && u->in(0)->in(0)->is_Initialize() &&
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   136
          u->in(1)->in(0)->as_Allocate()->initialization() == u->in(0)->in(0)) {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   137
        // CheckCastPP following an allocation always dominates all
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   138
        // use of the allocation result
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   139
        return u->as_Type();
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   140
      }
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   141
    }
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   142
  }
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   143
  return NULL;
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   144
}
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   145
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   146
#ifndef PRODUCT
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   147
void ConstraintCastNode::dump_spec(outputStream *st) const {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   148
  TypeNode::dump_spec(st);
27708
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   149
  if (_carry_dependency) {
35545
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   150
    st->print(" carry dependency");
27708
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   151
  }
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   152
}
35545
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   153
#endif
27708
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   154
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 35549
diff changeset
   155
const Type* CastIINode::Value(PhaseGVN* phase) const {
27708
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   156
  const Type *res = ConstraintCastNode::Value(phase);
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   157
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   158
  // Try to improve the type of the CastII if we recognize a CmpI/If
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   159
  // pattern.
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   160
  if (_carry_dependency) {
28041
fed7f90dc4c4 8066775: opto/node.hpp:355, assert(i < _max) failed: oob: i=1, _max=1
roland
parents: 27708
diff changeset
   161
    if (in(0) != NULL && in(0)->in(0) != NULL && in(0)->in(0)->is_If()) {
fed7f90dc4c4 8066775: opto/node.hpp:355, assert(i < _max) failed: oob: i=1, _max=1
roland
parents: 27708
diff changeset
   162
      assert(in(0)->is_IfFalse() || in(0)->is_IfTrue(), "should be If proj");
27708
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   163
      Node* proj = in(0);
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   164
      if (proj->in(0)->in(1)->is_Bool()) {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   165
        Node* b = proj->in(0)->in(1);
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   166
        if (b->in(1)->Opcode() == Op_CmpI) {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   167
          Node* cmp = b->in(1);
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   168
          if (cmp->in(1) == in(1) && phase->type(cmp->in(2))->isa_int()) {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   169
            const TypeInt* in2_t = phase->type(cmp->in(2))->is_int();
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   170
            const Type* t = TypeInt::INT;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   171
            BoolTest test = b->as_Bool()->_test;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   172
            if (proj->is_IfFalse()) {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   173
              test = test.negate();
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   174
            }
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   175
            BoolTest::mask m = test._test;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   176
            jlong lo_long = min_jint;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   177
            jlong hi_long = max_jint;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   178
            if (m == BoolTest::le || m == BoolTest::lt) {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   179
              hi_long = in2_t->_hi;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   180
              if (m == BoolTest::lt) {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   181
                hi_long -= 1;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   182
              }
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   183
            } else if (m == BoolTest::ge || m == BoolTest::gt) {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   184
              lo_long = in2_t->_lo;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   185
              if (m == BoolTest::gt) {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   186
                lo_long += 1;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   187
              }
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   188
            } else if (m == BoolTest::eq) {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   189
              lo_long = in2_t->_lo;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   190
              hi_long = in2_t->_hi;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   191
            } else if (m == BoolTest::ne) {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   192
              // can't do any better
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   193
            } else {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   194
              stringStream ss;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   195
              test.dump_on(&ss);
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30300
diff changeset
   196
              fatal("unexpected comparison %s", ss.as_string());
27708
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   197
            }
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   198
            int lo_int = (int)lo_long;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   199
            int hi_int = (int)hi_long;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   200
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   201
            if (lo_long != (jlong)lo_int) {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   202
              lo_int = min_jint;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   203
            }
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   204
            if (hi_long != (jlong)hi_int) {
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   205
              hi_int = max_jint;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   206
            }
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   207
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   208
            t = TypeInt::make(lo_int, hi_int, Type::WidenMax);
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   209
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   210
            res = res->filter_speculative(t);
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   211
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   212
            return res;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   213
          }
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   214
        }
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   215
      }
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   216
    }
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   217
  }
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   218
  return res;
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   219
}
8a8710cb8fc4 8054478: C2: Incorrectly compiled char[] array access crashes JVM
roland
parents: 24923
diff changeset
   220
35549
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   221
Node *CastIINode::Ideal(PhaseGVN *phase, bool can_reshape) {
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   222
  Node* progress = ConstraintCastNode::Ideal(phase, can_reshape);
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   223
  if (progress != NULL) {
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   224
    return progress;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   225
  }
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   226
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   227
  // transform:
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   228
  // (CastII (AddI x const)) -> (AddI (CastII x) const)
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   229
  // So the AddI has a chance to be optimized out
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   230
  if (in(1)->Opcode() == Op_AddI) {
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   231
    Node* in2 = in(1)->in(2);
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   232
    const TypeInt* in2_t = phase->type(in2)->isa_int();
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   233
    if (in2_t != NULL && in2_t->singleton()) {
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   234
      int in2_const = in2_t->_lo;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   235
      const TypeInt* current_type = _type->is_int();
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   236
      jlong new_lo_long = ((jlong)current_type->_lo) - in2_const;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   237
      jlong new_hi_long = ((jlong)current_type->_hi) - in2_const;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   238
      int new_lo = (int)new_lo_long;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   239
      int new_hi = (int)new_hi_long;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   240
      if (((jlong)new_lo) == new_lo_long && ((jlong)new_hi) == new_hi_long) {
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   241
        Node* in1 = in(1)->in(1);
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   242
        CastIINode* new_cast = (CastIINode*)clone();
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   243
        AddINode* new_add = (AddINode*)in(1)->clone();
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   244
        new_cast->set_type(TypeInt::make(new_lo, new_hi, current_type->_widen));
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   245
        new_cast->set_req(1, in1);
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   246
        new_add->set_req(1, phase->transform(new_cast));
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   247
        return new_add;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   248
      }
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   249
    }
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   250
  }
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   251
  // Similar to ConvI2LNode::Ideal() for the same reasons
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   252
  if (can_reshape && !phase->C->major_progress()) {
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   253
    const TypeInt* this_type = this->type()->is_int();
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   254
    const TypeInt* in_type = phase->type(in(1))->isa_int();
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   255
    if (in_type != NULL && this_type != NULL &&
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   256
        (in_type->_lo != this_type->_lo ||
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   257
         in_type->_hi != this_type->_hi)) {
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   258
      int lo1 = this_type->_lo;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   259
      int hi1 = this_type->_hi;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   260
      int w1  = this_type->_widen;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   261
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   262
      if (lo1 >= 0) {
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   263
        // Keep a range assertion of >=0.
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   264
        lo1 = 0;        hi1 = max_jint;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   265
      } else if (hi1 < 0) {
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   266
        // Keep a range assertion of <0.
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   267
        lo1 = min_jint; hi1 = -1;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   268
      } else {
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   269
        lo1 = min_jint; hi1 = max_jint;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   270
      }
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   271
      const TypeInt* wtype = TypeInt::make(MAX2(in_type->_lo, lo1),
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   272
                                           MIN2(in_type->_hi, hi1),
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   273
                                           MAX2((int)in_type->_widen, w1));
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   274
      if (wtype != type()) {
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   275
        set_type(wtype);
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   276
        return this;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   277
      }
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   278
    }
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   279
  }
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   280
  return NULL;
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   281
}
3415401a6b6e 8145322: Code generated from unsafe loops can be slightly improved
roland
parents: 35545
diff changeset
   282
35574
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   283
uint CastIINode::cmp(const Node &n) const {
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   284
  return ConstraintCastNode::cmp(n) && ((CastIINode&)n)._range_check_dependency == _range_check_dependency;
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   285
}
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   286
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   287
uint CastIINode::size_of() const {
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   288
  return sizeof(*this);
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   289
}
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   290
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   291
#ifndef PRODUCT
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   292
void CastIINode::dump_spec(outputStream* st) const {
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   293
  ConstraintCastNode::dump_spec(st);
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   294
  if (_range_check_dependency) {
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   295
    st->print(" range check dependency");
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   296
  }
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   297
}
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   298
#endif
2b25eb88c8d6 6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
thartmann
parents: 35551
diff changeset
   299
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   300
//=============================================================================
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   301
//------------------------------Identity---------------------------------------
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   302
// If input is already higher or equal to cast type, then this is an identity.
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 35549
diff changeset
   303
Node* CheckCastPPNode::Identity(PhaseGVN* phase) {
35545
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   304
  Node* dom = dominating_cast(phase);
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   305
  if (dom != NULL) {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   306
    return dom;
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   307
  }
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   308
  if (_carry_dependency) {
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   309
    return this;
a8f29dfd62b2 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
roland
parents: 33105
diff changeset
   310
  }
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   311
  // Toned down to rescue meeting at a Phi 3 different oops all implementing
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   312
  // the same interface.  CompileTheWorld starting at 502, kd12rc1.zip.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   313
  return (phase->type(in(1)) == phase->type(this)) ? in(1) : this;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   314
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   315
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   316
//------------------------------Value------------------------------------------
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   317
// Take 'join' of input and cast-up type, unless working with an Interface
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 35549
diff changeset
   318
const Type* CheckCastPPNode::Value(PhaseGVN* phase) const {
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   319
  if( in(0) && phase->type(in(0)) == Type::TOP ) return Type::TOP;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   320
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   321
  const Type *inn = phase->type(in(1));
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   322
  if( inn == Type::TOP ) return Type::TOP;  // No information yet
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   323
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   324
  const TypePtr *in_type   = inn->isa_ptr();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   325
  const TypePtr *my_type   = _type->isa_ptr();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   326
  const Type *result = _type;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   327
  if( in_type != NULL && my_type != NULL ) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   328
    TypePtr::PTR   in_ptr    = in_type->ptr();
30213
79c4cfb7f7cf 8076094: CheckCastPPNode::Value() has outdated logic for constants
roland
parents: 28041
diff changeset
   329
    if (in_ptr == TypePtr::Null) {
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   330
      result = in_type;
30213
79c4cfb7f7cf 8076094: CheckCastPPNode::Value() has outdated logic for constants
roland
parents: 28041
diff changeset
   331
    } else if (in_ptr == TypePtr::Constant) {
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   332
      const TypeOopPtr *jptr = my_type->isa_oopptr();
30213
79c4cfb7f7cf 8076094: CheckCastPPNode::Value() has outdated logic for constants
roland
parents: 28041
diff changeset
   333
      assert(jptr, "");
79c4cfb7f7cf 8076094: CheckCastPPNode::Value() has outdated logic for constants
roland
parents: 28041
diff changeset
   334
      result = !in_type->higher_equal(_type)
79c4cfb7f7cf 8076094: CheckCastPPNode::Value() has outdated logic for constants
roland
parents: 28041
diff changeset
   335
      ? my_type->cast_to_ptr_type(TypePtr::NotNull)
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   336
      : in_type;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   337
    } else {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   338
      result =  my_type->cast_to_ptr_type( my_type->join_ptr(in_ptr) );
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   339
    }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   340
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   341
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   342
  // This is the code from TypePtr::xmeet() that prevents us from
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   343
  // having 2 ways to represent the same type. We have to replicate it
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   344
  // here because we don't go through meet/join.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   345
  if (result->remove_speculative() == result->speculative()) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   346
    result = result->remove_speculative();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   347
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   348
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   349
  // Same as above: because we don't go through meet/join, remove the
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   350
  // speculative type if we know we won't use it.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   351
  return result->cleanup_speculative();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   352
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   353
  // JOIN NOT DONE HERE BECAUSE OF INTERFACE ISSUES.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   354
  // FIX THIS (DO THE JOIN) WHEN UNION TYPES APPEAR!
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   355
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   356
  //
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   357
  // Remove this code after overnight run indicates no performance
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   358
  // loss from not performing JOIN at CheckCastPPNode
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   359
  //
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   360
  // const TypeInstPtr *in_oop = in->isa_instptr();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   361
  // const TypeInstPtr *my_oop = _type->isa_instptr();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   362
  // // If either input is an 'interface', return destination type
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   363
  // assert (in_oop == NULL || in_oop->klass() != NULL, "");
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   364
  // assert (my_oop == NULL || my_oop->klass() != NULL, "");
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   365
  // if( (in_oop && in_oop->klass()->is_interface())
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   366
  //   ||(my_oop && my_oop->klass()->is_interface()) ) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   367
  //   TypePtr::PTR  in_ptr = in->isa_ptr() ? in->is_ptr()->_ptr : TypePtr::BotPTR;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   368
  //   // Preserve cast away nullness for interfaces
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   369
  //   if( in_ptr == TypePtr::NotNull && my_oop && my_oop->_ptr == TypePtr::BotPTR ) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   370
  //     return my_oop->cast_to_ptr_type(TypePtr::NotNull);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   371
  //   }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   372
  //   return _type;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   373
  // }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   374
  //
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   375
  // // Neither the input nor the destination type is an interface,
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   376
  //
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   377
  // // history: JOIN used to cause weird corner case bugs
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   378
  // //          return (in == TypeOopPtr::NULL_PTR) ? in : _type;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   379
  // // JOIN picks up NotNull in common instance-of/check-cast idioms, both oops.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   380
  // // JOIN does not preserve NotNull in other cases, e.g. RawPtr vs InstPtr
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   381
  // const Type *join = in->join(_type);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   382
  // // Check if join preserved NotNull'ness for pointers
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   383
  // if( join->isa_ptr() && _type->isa_ptr() ) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   384
  //   TypePtr::PTR join_ptr = join->is_ptr()->_ptr;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   385
  //   TypePtr::PTR type_ptr = _type->is_ptr()->_ptr;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   386
  //   // If there isn't any NotNull'ness to preserve
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   387
  //   // OR if join preserved NotNull'ness then return it
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   388
  //   if( type_ptr == TypePtr::BotPTR  || type_ptr == TypePtr::Null ||
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   389
  //       join_ptr == TypePtr::NotNull || join_ptr == TypePtr::Constant ) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   390
  //     return join;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   391
  //   }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   392
  //   // ELSE return same old type as before
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   393
  //   return _type;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   394
  // }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   395
  // // Not joining two pointers
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   396
  // return join;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   397
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   398
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   399
//=============================================================================
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   400
//------------------------------Value------------------------------------------
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 35549
diff changeset
   401
const Type* CastX2PNode::Value(PhaseGVN* phase) const {
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   402
  const Type* t = phase->type(in(1));
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   403
  if (t == Type::TOP) return Type::TOP;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   404
  if (t->base() == Type_X && t->singleton()) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   405
    uintptr_t bits = (uintptr_t) t->is_intptr_t()->get_con();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   406
    if (bits == 0)   return TypePtr::NULL_PTR;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   407
    return TypeRawPtr::make((address) bits);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   408
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   409
  return CastX2PNode::bottom_type();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   410
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   411
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   412
//------------------------------Idealize---------------------------------------
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   413
static inline bool fits_in_int(const Type* t, bool but_not_min_int = false) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   414
  if (t == Type::TOP)  return false;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   415
  const TypeX* tl = t->is_intptr_t();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   416
  jint lo = min_jint;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   417
  jint hi = max_jint;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   418
  if (but_not_min_int)  ++lo;  // caller wants to negate the value w/o overflow
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   419
  return (tl->_lo >= lo) && (tl->_hi <= hi);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   420
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   421
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   422
static inline Node* addP_of_X2P(PhaseGVN *phase,
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   423
                                Node* base,
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   424
                                Node* dispX,
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   425
                                bool negate = false) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   426
  if (negate) {
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 23528
diff changeset
   427
    dispX = new SubXNode(phase->MakeConX(0), phase->transform(dispX));
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   428
  }
24923
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 23528
diff changeset
   429
  return new AddPNode(phase->C->top(),
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 23528
diff changeset
   430
                      phase->transform(new CastX2PNode(base)),
9631f7d691dc 8034812: remove IDX_INIT macro hack in Node class
thartmann
parents: 23528
diff changeset
   431
                      phase->transform(dispX));
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   432
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   433
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   434
Node *CastX2PNode::Ideal(PhaseGVN *phase, bool can_reshape) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   435
  // convert CastX2P(AddX(x, y)) to AddP(CastX2P(x), y) if y fits in an int
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   436
  int op = in(1)->Opcode();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   437
  Node* x;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   438
  Node* y;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   439
  switch (op) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   440
    case Op_SubX:
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   441
    x = in(1)->in(1);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   442
    // Avoid ideal transformations ping-pong between this and AddP for raw pointers.
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   443
    if (phase->find_intptr_t_con(x, -1) == 0)
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   444
    break;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   445
    y = in(1)->in(2);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   446
    if (fits_in_int(phase->type(y), true)) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   447
      return addP_of_X2P(phase, x, y, true);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   448
    }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   449
    break;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   450
    case Op_AddX:
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   451
    x = in(1)->in(1);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   452
    y = in(1)->in(2);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   453
    if (fits_in_int(phase->type(y))) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   454
      return addP_of_X2P(phase, x, y);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   455
    }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   456
    if (fits_in_int(phase->type(x))) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   457
      return addP_of_X2P(phase, y, x);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   458
    }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   459
    break;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   460
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   461
  return NULL;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   462
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   463
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   464
//------------------------------Identity---------------------------------------
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 35549
diff changeset
   465
Node* CastX2PNode::Identity(PhaseGVN* phase) {
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   466
  if (in(1)->Opcode() == Op_CastP2X)  return in(1)->in(1);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   467
  return this;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   468
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   469
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   470
//=============================================================================
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   471
//------------------------------Value------------------------------------------
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 35549
diff changeset
   472
const Type* CastP2XNode::Value(PhaseGVN* phase) const {
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   473
  const Type* t = phase->type(in(1));
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   474
  if (t == Type::TOP) return Type::TOP;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   475
  if (t->base() == Type::RawPtr && t->singleton()) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   476
    uintptr_t bits = (uintptr_t) t->is_rawptr()->get_con();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   477
    return TypeX::make(bits);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   478
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   479
  return CastP2XNode::bottom_type();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   480
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   481
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   482
Node *CastP2XNode::Ideal(PhaseGVN *phase, bool can_reshape) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   483
  return (in(0) && remove_dead_region(phase, can_reshape)) ? this : NULL;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   484
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   485
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   486
//------------------------------Identity---------------------------------------
35551
36ef3841fb34 8146629: Make phase->is_IterGVN() accessible from Node::Identity and Node::Value
thartmann
parents: 35549
diff changeset
   487
Node* CastP2XNode::Identity(PhaseGVN* phase) {
23528
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   488
  if (in(1)->Opcode() == Op_CastX2P)  return in(1)->in(1);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   489
  return this;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   490
}