1 /* 2 * Copyright (c) 2014, 2019, 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 #ifndef SHARE_OPTO_NARROWPTRNODE_HPP 26 #define SHARE_OPTO_NARROWPTRNODE_HPP 27 28 #include "opto/node.hpp" 29 #include "opto/opcodes.hpp" 30 31 //------------------------------EncodeNarrowPtr-------------------------------- 32 class EncodeNarrowPtrNode : public TypeNode { 33 protected: EncodeNarrowPtrNode(Node * value,const Type * type)34 EncodeNarrowPtrNode(Node* value, const Type* type): 35 TypeNode(type, 2) { 36 init_class_id(Class_EncodeNarrowPtr); 37 init_req(0, NULL); 38 init_req(1, value); 39 } 40 public: ideal_reg() const41 virtual uint ideal_reg() const { return Op_RegN; } 42 }; 43 44 //------------------------------EncodeP-------------------------------- 45 // Encodes an oop pointers into its compressed form 46 // Takes an extra argument which is the real heap base as a long which 47 // may be useful for code generation in the backend. 48 class EncodePNode : public EncodeNarrowPtrNode { 49 public: EncodePNode(Node * value,const Type * type)50 EncodePNode(Node* value, const Type* type): 51 EncodeNarrowPtrNode(value, type) { 52 init_class_id(Class_EncodeP); 53 } 54 virtual int Opcode() const; 55 virtual Node* Identity(PhaseGVN* phase); 56 virtual const Type* Value(PhaseGVN* phase) const; 57 }; 58 59 //------------------------------EncodePKlass-------------------------------- 60 // Encodes a klass pointer into its compressed form 61 // Takes an extra argument which is the real heap base as a long which 62 // may be useful for code generation in the backend. 63 class EncodePKlassNode : public EncodeNarrowPtrNode { 64 public: EncodePKlassNode(Node * value,const Type * type)65 EncodePKlassNode(Node* value, const Type* type): 66 EncodeNarrowPtrNode(value, type) { 67 init_class_id(Class_EncodePKlass); 68 } 69 virtual int Opcode() const; 70 virtual Node* Identity(PhaseGVN* phase); 71 virtual const Type* Value(PhaseGVN* phase) const; 72 }; 73 74 //------------------------------DecodeNarrowPtr-------------------------------- 75 class DecodeNarrowPtrNode : public TypeNode { 76 protected: DecodeNarrowPtrNode(Node * value,const Type * type)77 DecodeNarrowPtrNode(Node* value, const Type* type): 78 TypeNode(type, 2) { 79 init_class_id(Class_DecodeNarrowPtr); 80 init_req(0, NULL); 81 init_req(1, value); 82 } 83 public: ideal_reg() const84 virtual uint ideal_reg() const { return Op_RegP; } 85 }; 86 87 //------------------------------DecodeN-------------------------------- 88 // Converts a narrow oop into a real oop ptr. 89 // Takes an extra argument which is the real heap base as a long which 90 // may be useful for code generation in the backend. 91 class DecodeNNode : public DecodeNarrowPtrNode { 92 public: DecodeNNode(Node * value,const Type * type)93 DecodeNNode(Node* value, const Type* type): 94 DecodeNarrowPtrNode(value, type) { 95 init_class_id(Class_DecodeN); 96 } 97 virtual int Opcode() const; 98 virtual const Type* Value(PhaseGVN* phase) const; 99 virtual Node* Identity(PhaseGVN* phase); 100 }; 101 102 //------------------------------DecodeNKlass-------------------------------- 103 // Converts a narrow klass pointer into a real klass ptr. 104 // Takes an extra argument which is the real heap base as a long which 105 // may be useful for code generation in the backend. 106 class DecodeNKlassNode : public DecodeNarrowPtrNode { 107 public: DecodeNKlassNode(Node * value,const Type * type)108 DecodeNKlassNode(Node* value, const Type* type): 109 DecodeNarrowPtrNode(value, type) { 110 init_class_id(Class_DecodeNKlass); 111 } 112 virtual int Opcode() const; 113 virtual const Type* Value(PhaseGVN* phase) const; 114 virtual Node* Identity(PhaseGVN* phase); 115 }; 116 117 #endif // SHARE_OPTO_NARROWPTRNODE_HPP 118