Wed, 03 Jul 2019 20:42:37 +0800
Merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #ifndef SHARE_VM_CI_CITYPE_HPP |
aoqi@0 | 26 | #define SHARE_VM_CI_CITYPE_HPP |
aoqi@0 | 27 | |
aoqi@0 | 28 | #include "ci/ciMetadata.hpp" |
aoqi@0 | 29 | |
aoqi@0 | 30 | // ciType |
aoqi@0 | 31 | // |
aoqi@0 | 32 | // This class represents either a class (T_OBJECT), array (T_ARRAY), |
aoqi@0 | 33 | // or one of the primitive types such as T_INT. |
aoqi@0 | 34 | class ciType : public ciMetadata { |
aoqi@0 | 35 | CI_PACKAGE_ACCESS |
aoqi@0 | 36 | friend class ciKlass; |
aoqi@0 | 37 | friend class ciReturnAddress; |
aoqi@0 | 38 | |
aoqi@0 | 39 | private: |
aoqi@0 | 40 | BasicType _basic_type; |
aoqi@0 | 41 | |
aoqi@0 | 42 | ciType(BasicType t); // for primitive and unloaded types |
aoqi@0 | 43 | ciType(KlassHandle k); // for subclasses (reference types) |
aoqi@0 | 44 | |
aoqi@0 | 45 | const char* type_string() { return "ciType"; } |
aoqi@0 | 46 | |
aoqi@0 | 47 | void print_impl(outputStream* st); |
aoqi@0 | 48 | |
aoqi@0 | 49 | // Distinguished instances of primitive ciTypes.. |
aoqi@0 | 50 | static ciType* _basic_types[T_CONFLICT+1]; |
aoqi@0 | 51 | |
aoqi@0 | 52 | public: |
aoqi@0 | 53 | BasicType basic_type() const { return _basic_type; } |
aoqi@0 | 54 | |
aoqi@0 | 55 | // Returns true iff the types are identical, or if both are klasses |
aoqi@0 | 56 | // and the is_subtype_of relation holds between the klasses. |
aoqi@0 | 57 | bool is_subtype_of(ciType* type); |
aoqi@0 | 58 | |
aoqi@0 | 59 | // Get the instance of java.lang.Class corresponding to this type. |
aoqi@0 | 60 | // There are mirrors for instance, array, and primitive types (incl. void). |
aoqi@0 | 61 | virtual ciInstance* java_mirror(); |
aoqi@0 | 62 | |
aoqi@0 | 63 | // Get the class which "boxes" (or "wraps") values of this type. |
aoqi@0 | 64 | // Example: short is boxed by java.lang.Short, etc. |
aoqi@0 | 65 | // Returns self if it is a reference type. |
aoqi@0 | 66 | // Returns NULL for void, since null is used in such cases. |
aoqi@0 | 67 | ciKlass* box_klass(); |
aoqi@0 | 68 | |
aoqi@0 | 69 | // Returns true if this is not a klass or array (i.e., not a reference type). |
aoqi@0 | 70 | bool is_primitive_type() const { return basic_type() != T_OBJECT && basic_type() != T_ARRAY; } |
aoqi@0 | 71 | int size() const { return type2size[basic_type()]; } |
aoqi@0 | 72 | bool is_void() const { return basic_type() == T_VOID; } |
aoqi@0 | 73 | bool is_one_word() const { return size() == 1; } |
aoqi@0 | 74 | bool is_two_word() const { return size() == 2; } |
aoqi@0 | 75 | |
aoqi@0 | 76 | // What kind of ciObject is this? |
aoqi@0 | 77 | bool is_type() const { return true; } |
aoqi@0 | 78 | bool is_classless() const { return is_primitive_type(); } |
aoqi@0 | 79 | |
aoqi@0 | 80 | const char* name(); |
aoqi@0 | 81 | virtual void print_name_on(outputStream* st); |
aoqi@0 | 82 | void print_name() { |
aoqi@0 | 83 | print_name_on(tty); |
aoqi@0 | 84 | } |
aoqi@0 | 85 | |
aoqi@0 | 86 | static ciType* make(BasicType t); |
aoqi@0 | 87 | }; |
aoqi@0 | 88 | |
aoqi@0 | 89 | |
aoqi@0 | 90 | // ciReturnAddress |
aoqi@0 | 91 | // |
aoqi@0 | 92 | // This class represents the type of a specific return address in the |
aoqi@0 | 93 | // bytecodes. |
aoqi@0 | 94 | class ciReturnAddress : public ciType { |
aoqi@0 | 95 | CI_PACKAGE_ACCESS |
aoqi@0 | 96 | |
aoqi@0 | 97 | private: |
aoqi@0 | 98 | // The bci of this return address. |
aoqi@0 | 99 | int _bci; |
aoqi@0 | 100 | |
aoqi@0 | 101 | ciReturnAddress(int bci); |
aoqi@0 | 102 | |
aoqi@0 | 103 | const char* type_string() { return "ciReturnAddress"; } |
aoqi@0 | 104 | |
aoqi@0 | 105 | void print_impl(outputStream* st); |
aoqi@0 | 106 | |
aoqi@0 | 107 | public: |
aoqi@0 | 108 | bool is_return_address() const { return true; } |
aoqi@0 | 109 | |
aoqi@0 | 110 | int bci() { return _bci; } |
aoqi@0 | 111 | |
aoqi@0 | 112 | static ciReturnAddress* make(int bci); |
aoqi@0 | 113 | }; |
aoqi@0 | 114 | |
aoqi@0 | 115 | #endif // SHARE_VM_CI_CITYPE_HPP |