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(PhaseGVN* 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(PhaseGVN* 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(PhaseGVN* 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(PhaseGVN* 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* DecodeNKlassNode::Identity(PhaseGVN* phase) { 71 const Type *t = phase->type( in(1) ); 72 if( t == Type::TOP ) return in(1); 73 74 if (in(1)->is_EncodePKlass()) { 75 // (DecodeNKlass (EncodePKlass p)) -> p 76 return in(1)->in(1); 77 } 78 return this; 79 } 80 81 const Type* DecodeNKlassNode::Value(PhaseGVN* phase) const { 82 const Type *t = phase->type( in(1) ); 83 if (t == Type::TOP) return Type::TOP; 84 assert(t != TypeNarrowKlass::NULL_PTR, "null klass?"); 85 86 assert(t->isa_narrowklass(), "only narrow klass ptr here"); 87 return t->make_ptr(); 88 } 89 90 Node* EncodePKlassNode::Identity(PhaseGVN* phase) { 91 const Type *t = phase->type( in(1) ); 92 if( t == Type::TOP ) return in(1); 93 94 if (in(1)->is_DecodeNKlass()) { 95 // (EncodePKlass (DecodeNKlass p)) -> p 96 return in(1)->in(1); 97 } 98 return this; 99 } 100 101 const Type* EncodePKlassNode::Value(PhaseGVN* phase) const { 102 const Type *t = phase->type( in(1) ); 103 if (t == Type::TOP) return Type::TOP; 104 assert (t != TypePtr::NULL_PTR, "null klass?"); 105 106 assert(UseCompressedClassPointers && t->isa_klassptr(), "only klass ptr here"); 107 return t->make_narrowklass(); 108 } 109