hotspot/src/share/vm/opto/narrowptrnode.cpp
author acorn
Fri, 08 May 2015 14:00:24 -0400
changeset 30615 4713e7c7b96f
parent 30300 4b12a5b40064
child 35551 36ef3841fb34
permissions -rw-r--r--
8030680: 292 cleanup from default method code assessment Summary: small code improvements for increased robustness Reviewed-by: acorn, coleenp Contributed-by: michael.haupt@oracle.com
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/narrowptrnode.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    27
#include "opto/phaseX.hpp"
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    28
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    29
Node* DecodeNNode::Identity(PhaseTransform* phase) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    30
  const Type *t = phase->type( in(1) );
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    31
  if( t == Type::TOP ) return in(1);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    32
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    33
  if (in(1)->is_EncodeP()) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    34
    // (DecodeN (EncodeP p)) -> p
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    35
    return in(1)->in(1);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    36
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    37
  return this;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    38
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    39
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    40
const Type *DecodeNNode::Value( PhaseTransform *phase ) const {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    41
  const Type *t = phase->type( in(1) );
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    42
  if (t == Type::TOP) return Type::TOP;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    43
  if (t == TypeNarrowOop::NULL_PTR) return TypePtr::NULL_PTR;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    44
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    45
  assert(t->isa_narrowoop(), "only  narrowoop here");
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    46
  return t->make_ptr();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    47
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    48
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    49
Node* EncodePNode::Identity(PhaseTransform* phase) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    50
  const Type *t = phase->type( in(1) );
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    51
  if( t == Type::TOP ) return in(1);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    52
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    53
  if (in(1)->is_DecodeN()) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    54
    // (EncodeP (DecodeN p)) -> p
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    55
    return in(1)->in(1);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    56
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    57
  return this;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    58
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    59
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    60
const Type *EncodePNode::Value( PhaseTransform *phase ) const {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    61
  const Type *t = phase->type( in(1) );
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    62
  if (t == Type::TOP) return Type::TOP;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    63
  if (t == TypePtr::NULL_PTR) return TypeNarrowOop::NULL_PTR;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    64
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    65
  assert(t->isa_oop_ptr(), "only oopptr here");
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    66
  return t->make_narrowoop();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    67
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    68
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    69
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    70
Node* DecodeNKlassNode::Identity(PhaseTransform* phase) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    71
  const Type *t = phase->type( in(1) );
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    72
  if( t == Type::TOP ) return in(1);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    73
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    74
  if (in(1)->is_EncodePKlass()) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    75
    // (DecodeNKlass (EncodePKlass p)) -> p
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    76
    return in(1)->in(1);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    77
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    78
  return this;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    79
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    80
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    81
const Type *DecodeNKlassNode::Value( PhaseTransform *phase ) const {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    82
  const Type *t = phase->type( in(1) );
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    83
  if (t == Type::TOP) return Type::TOP;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    84
  assert(t != TypeNarrowKlass::NULL_PTR, "null klass?");
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    85
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    86
  assert(t->isa_narrowklass(), "only narrow klass ptr here");
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    87
  return t->make_ptr();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    88
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    89
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    90
Node* EncodePKlassNode::Identity(PhaseTransform* phase) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    91
  const Type *t = phase->type( in(1) );
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    92
  if( t == Type::TOP ) return in(1);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    93
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    94
  if (in(1)->is_DecodeNKlass()) {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    95
    // (EncodePKlass (DecodeNKlass p)) -> p
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    96
    return in(1)->in(1);
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    97
  }
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    98
  return this;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
    99
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   100
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   101
const Type *EncodePKlassNode::Value( PhaseTransform *phase ) const {
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   102
  const Type *t = phase->type( in(1) );
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   103
  if (t == Type::TOP) return Type::TOP;
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   104
  assert (t != TypePtr::NULL_PTR, "null klass?");
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   105
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   106
  assert(UseCompressedClassPointers && t->isa_klassptr(), "only klass ptr here");
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   107
  return t->make_narrowklass();
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   108
}
8f1a7f5e8066 8001532: C2 node files refactoring
morris
parents:
diff changeset
   109