hotspot/src/share/vm/opto/narrowptrnode.cpp
changeset 23528 8f1a7f5e8066
child 30300 4b12a5b40064
equal deleted inserted replaced
23527:397b6816032d 23528:8f1a7f5e8066
       
     1 /*
       
     2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  *
       
    23  */
       
    24 
       
    25 #include "precompiled.hpp"
       
    26 #include "opto/narrowptrnode.hpp"
       
    27 #include "opto/phaseX.hpp"
       
    28 
       
    29 Node* DecodeNNode::Identity(PhaseTransform* phase) {
       
    30   const Type *t = phase->type( in(1) );
       
    31   if( t == Type::TOP ) return in(1);
       
    32 
       
    33   if (in(1)->is_EncodeP()) {
       
    34     // (DecodeN (EncodeP p)) -> p
       
    35     return in(1)->in(1);
       
    36   }
       
    37   return this;
       
    38 }
       
    39 
       
    40 const Type *DecodeNNode::Value( PhaseTransform *phase ) const {
       
    41   const Type *t = phase->type( in(1) );
       
    42   if (t == Type::TOP) return Type::TOP;
       
    43   if (t == TypeNarrowOop::NULL_PTR) return TypePtr::NULL_PTR;
       
    44 
       
    45   assert(t->isa_narrowoop(), "only  narrowoop here");
       
    46   return t->make_ptr();
       
    47 }
       
    48 
       
    49 Node* EncodePNode::Identity(PhaseTransform* phase) {
       
    50   const Type *t = phase->type( in(1) );
       
    51   if( t == Type::TOP ) return in(1);
       
    52 
       
    53   if (in(1)->is_DecodeN()) {
       
    54     // (EncodeP (DecodeN p)) -> p
       
    55     return in(1)->in(1);
       
    56   }
       
    57   return this;
       
    58 }
       
    59 
       
    60 const Type *EncodePNode::Value( PhaseTransform *phase ) const {
       
    61   const Type *t = phase->type( in(1) );
       
    62   if (t == Type::TOP) return Type::TOP;
       
    63   if (t == TypePtr::NULL_PTR) return TypeNarrowOop::NULL_PTR;
       
    64 
       
    65   assert(t->isa_oop_ptr(), "only oopptr here");
       
    66   return t->make_narrowoop();
       
    67 }
       
    68 
       
    69 
       
    70 Node *EncodeNarrowPtrNode::Ideal_DU_postCCP( PhaseCCP *ccp ) {
       
    71   return MemNode::Ideal_common_DU_postCCP(ccp, this, in(1));
       
    72 }
       
    73 
       
    74 Node* DecodeNKlassNode::Identity(PhaseTransform* phase) {
       
    75   const Type *t = phase->type( in(1) );
       
    76   if( t == Type::TOP ) return in(1);
       
    77 
       
    78   if (in(1)->is_EncodePKlass()) {
       
    79     // (DecodeNKlass (EncodePKlass p)) -> p
       
    80     return in(1)->in(1);
       
    81   }
       
    82   return this;
       
    83 }
       
    84 
       
    85 const Type *DecodeNKlassNode::Value( PhaseTransform *phase ) const {
       
    86   const Type *t = phase->type( in(1) );
       
    87   if (t == Type::TOP) return Type::TOP;
       
    88   assert(t != TypeNarrowKlass::NULL_PTR, "null klass?");
       
    89 
       
    90   assert(t->isa_narrowklass(), "only narrow klass ptr here");
       
    91   return t->make_ptr();
       
    92 }
       
    93 
       
    94 Node* EncodePKlassNode::Identity(PhaseTransform* phase) {
       
    95   const Type *t = phase->type( in(1) );
       
    96   if( t == Type::TOP ) return in(1);
       
    97 
       
    98   if (in(1)->is_DecodeNKlass()) {
       
    99     // (EncodePKlass (DecodeNKlass p)) -> p
       
   100     return in(1)->in(1);
       
   101   }
       
   102   return this;
       
   103 }
       
   104 
       
   105 const Type *EncodePKlassNode::Value( PhaseTransform *phase ) const {
       
   106   const Type *t = phase->type( in(1) );
       
   107   if (t == Type::TOP) return Type::TOP;
       
   108   assert (t != TypePtr::NULL_PTR, "null klass?");
       
   109 
       
   110   assert(UseCompressedClassPointers && t->isa_klassptr(), "only klass ptr here");
       
   111   return t->make_narrowklass();
       
   112 }
       
   113