src/share/vm/utilities/constantTag.hpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 5889
28ca974cc21a
parent 0
f90c822e73f8
child 10015
eb7ce841ccec
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 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_UTILITIES_CONSTANTTAG_HPP
aoqi@0 26 #define SHARE_VM_UTILITIES_CONSTANTTAG_HPP
aoqi@0 27
aoqi@0 28 #include "prims/jvm.h"
aoqi@0 29 #include "utilities/top.hpp"
aoqi@0 30
aoqi@0 31 // constant tags in Java .class files
aoqi@0 32
aoqi@0 33
aoqi@0 34 enum {
aoqi@0 35 // See jvm.h for shared JVM_CONSTANT_XXX tags
aoqi@0 36 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/utilities/ConstantTag.java
aoqi@0 37 // Hotspot specific tags
aoqi@0 38 JVM_CONSTANT_Invalid = 0, // For bad value initialization
aoqi@0 39 JVM_CONSTANT_InternalMin = 100, // First implementation tag (aside from bad value of course)
aoqi@0 40 JVM_CONSTANT_UnresolvedClass = 100, // Temporary tag until actual use
aoqi@0 41 JVM_CONSTANT_ClassIndex = 101, // Temporary tag while constructing constant pool
aoqi@0 42 JVM_CONSTANT_StringIndex = 102, // Temporary tag while constructing constant pool
aoqi@0 43 JVM_CONSTANT_UnresolvedClassInError = 103, // Error tag due to resolution error
aoqi@0 44 JVM_CONSTANT_MethodHandleInError = 104, // Error tag due to resolution error
aoqi@0 45 JVM_CONSTANT_MethodTypeInError = 105, // Error tag due to resolution error
aoqi@0 46 JVM_CONSTANT_InternalMax = 105 // Last implementation tag
aoqi@0 47 };
aoqi@0 48
aoqi@0 49
aoqi@0 50 class constantTag VALUE_OBJ_CLASS_SPEC {
aoqi@0 51 private:
aoqi@0 52 jbyte _tag;
aoqi@0 53 public:
aoqi@0 54 bool is_klass() const { return _tag == JVM_CONSTANT_Class; }
aoqi@0 55 bool is_field () const { return _tag == JVM_CONSTANT_Fieldref; }
aoqi@0 56 bool is_method() const { return _tag == JVM_CONSTANT_Methodref; }
aoqi@0 57 bool is_interface_method() const { return _tag == JVM_CONSTANT_InterfaceMethodref; }
aoqi@0 58 bool is_string() const { return _tag == JVM_CONSTANT_String; }
aoqi@0 59 bool is_int() const { return _tag == JVM_CONSTANT_Integer; }
aoqi@0 60 bool is_float() const { return _tag == JVM_CONSTANT_Float; }
aoqi@0 61 bool is_long() const { return _tag == JVM_CONSTANT_Long; }
aoqi@0 62 bool is_double() const { return _tag == JVM_CONSTANT_Double; }
aoqi@0 63 bool is_name_and_type() const { return _tag == JVM_CONSTANT_NameAndType; }
aoqi@0 64 bool is_utf8() const { return _tag == JVM_CONSTANT_Utf8; }
aoqi@0 65
aoqi@0 66 bool is_invalid() const { return _tag == JVM_CONSTANT_Invalid; }
aoqi@0 67
aoqi@0 68 bool is_unresolved_klass() const {
aoqi@0 69 return _tag == JVM_CONSTANT_UnresolvedClass || _tag == JVM_CONSTANT_UnresolvedClassInError;
aoqi@0 70 }
aoqi@0 71
aoqi@0 72 bool is_unresolved_klass_in_error() const {
aoqi@0 73 return _tag == JVM_CONSTANT_UnresolvedClassInError;
aoqi@0 74 }
aoqi@0 75
aoqi@0 76 bool is_method_handle_in_error() const {
aoqi@0 77 return _tag == JVM_CONSTANT_MethodHandleInError;
aoqi@0 78 }
aoqi@0 79 bool is_method_type_in_error() const {
aoqi@0 80 return _tag == JVM_CONSTANT_MethodTypeInError;
aoqi@0 81 }
aoqi@0 82
aoqi@0 83 bool is_klass_index() const { return _tag == JVM_CONSTANT_ClassIndex; }
aoqi@0 84 bool is_string_index() const { return _tag == JVM_CONSTANT_StringIndex; }
aoqi@0 85
aoqi@0 86 bool is_klass_reference() const { return is_klass_index() || is_unresolved_klass(); }
aoqi@0 87 bool is_klass_or_reference() const{ return is_klass() || is_klass_reference(); }
aoqi@0 88 bool is_field_or_method() const { return is_field() || is_method() || is_interface_method(); }
aoqi@0 89 bool is_symbol() const { return is_utf8(); }
aoqi@0 90
aoqi@0 91 bool is_method_type() const { return _tag == JVM_CONSTANT_MethodType; }
aoqi@0 92 bool is_method_handle() const { return _tag == JVM_CONSTANT_MethodHandle; }
aoqi@0 93 bool is_invoke_dynamic() const { return _tag == JVM_CONSTANT_InvokeDynamic; }
aoqi@0 94
aoqi@0 95 bool is_loadable_constant() const {
aoqi@0 96 return ((_tag >= JVM_CONSTANT_Integer && _tag <= JVM_CONSTANT_String) ||
aoqi@0 97 is_method_type() || is_method_handle() ||
aoqi@0 98 is_unresolved_klass());
aoqi@0 99 }
aoqi@0 100
aoqi@0 101 constantTag() {
aoqi@0 102 _tag = JVM_CONSTANT_Invalid;
aoqi@0 103 }
aoqi@0 104 constantTag(jbyte tag) {
aoqi@0 105 assert((tag >= 0 && tag <= JVM_CONSTANT_NameAndType) ||
aoqi@0 106 (tag >= JVM_CONSTANT_MethodHandle && tag <= JVM_CONSTANT_InvokeDynamic) ||
aoqi@0 107 (tag >= JVM_CONSTANT_InternalMin && tag <= JVM_CONSTANT_InternalMax), "Invalid constant tag");
aoqi@0 108 _tag = tag;
aoqi@0 109 }
aoqi@0 110
aoqi@0 111 jbyte value() const { return _tag; }
aoqi@0 112 jbyte non_error_value() const;
aoqi@0 113
aoqi@0 114 BasicType basic_type() const; // if used with ldc, what kind of value gets pushed?
aoqi@0 115
aoqi@0 116 const char* internal_name() const; // for error reporting
aoqi@0 117
aoqi@0 118 void print_on(outputStream* st) const PRODUCT_RETURN;
aoqi@0 119 };
aoqi@0 120
aoqi@0 121 #endif // SHARE_VM_UTILITIES_CONSTANTTAG_HPP

mercurial