annotate src/share/vm/utilities/constantTag.hpp @ 12823:b756e7a2ec33

Added tag jdk-9+181 for changeset 4a443796f6f5
author prr
date Thu, 03 Aug 2017 18:56:57 +0000
parents 003c36658224
children
rev   line source
duke@0 1 /*
coleenp@6384 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1879 25 #ifndef SHARE_VM_UTILITIES_CONSTANTTAG_HPP
stefank@1879 26 #define SHARE_VM_UTILITIES_CONSTANTTAG_HPP
stefank@1879 27
stefank@10870 28 #include "memory/allocation.hpp"
stefank@1879 29 #include "prims/jvm.h"
stefank@1879 30
duke@0 31 // constant tags in Java .class files
duke@0 32
duke@0 33
duke@0 34 enum {
duke@0 35 // See jvm.h for shared JVM_CONSTANT_XXX tags
duke@0 36 // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/utilities/ConstantTag.java
duke@0 37 // Hotspot specific tags
duke@0 38 JVM_CONSTANT_Invalid = 0, // For bad value initialization
duke@0 39 JVM_CONSTANT_InternalMin = 100, // First implementation tag (aside from bad value of course)
duke@0 40 JVM_CONSTANT_UnresolvedClass = 100, // Temporary tag until actual use
duke@0 41 JVM_CONSTANT_ClassIndex = 101, // Temporary tag while constructing constant pool
coleenp@3602 42 JVM_CONSTANT_StringIndex = 102, // Temporary tag while constructing constant pool
coleenp@3602 43 JVM_CONSTANT_UnresolvedClassInError = 103, // Error tag due to resolution error
coleenp@3602 44 JVM_CONSTANT_MethodHandleInError = 104, // Error tag due to resolution error
coleenp@3602 45 JVM_CONSTANT_MethodTypeInError = 105, // Error tag due to resolution error
coleenp@4208 46 JVM_CONSTANT_InternalMax = 105 // Last implementation tag
duke@0 47 };
duke@0 48
duke@0 49
duke@0 50 class constantTag VALUE_OBJ_CLASS_SPEC {
duke@0 51 private:
duke@0 52 jbyte _tag;
duke@0 53 public:
duke@0 54 bool is_klass() const { return _tag == JVM_CONSTANT_Class; }
duke@0 55 bool is_field () const { return _tag == JVM_CONSTANT_Fieldref; }
duke@0 56 bool is_method() const { return _tag == JVM_CONSTANT_Methodref; }
duke@0 57 bool is_interface_method() const { return _tag == JVM_CONSTANT_InterfaceMethodref; }
duke@0 58 bool is_string() const { return _tag == JVM_CONSTANT_String; }
duke@0 59 bool is_int() const { return _tag == JVM_CONSTANT_Integer; }
duke@0 60 bool is_float() const { return _tag == JVM_CONSTANT_Float; }
duke@0 61 bool is_long() const { return _tag == JVM_CONSTANT_Long; }
duke@0 62 bool is_double() const { return _tag == JVM_CONSTANT_Double; }
duke@0 63 bool is_name_and_type() const { return _tag == JVM_CONSTANT_NameAndType; }
duke@0 64 bool is_utf8() const { return _tag == JVM_CONSTANT_Utf8; }
duke@0 65
duke@0 66 bool is_invalid() const { return _tag == JVM_CONSTANT_Invalid; }
duke@0 67
duke@0 68 bool is_unresolved_klass() const {
duke@0 69 return _tag == JVM_CONSTANT_UnresolvedClass || _tag == JVM_CONSTANT_UnresolvedClassInError;
duke@0 70 }
duke@0 71
duke@0 72 bool is_unresolved_klass_in_error() const {
duke@0 73 return _tag == JVM_CONSTANT_UnresolvedClassInError;
duke@0 74 }
duke@0 75
coleenp@3602 76 bool is_method_handle_in_error() const {
coleenp@3602 77 return _tag == JVM_CONSTANT_MethodHandleInError;
coleenp@3602 78 }
coleenp@3602 79 bool is_method_type_in_error() const {
coleenp@3602 80 return _tag == JVM_CONSTANT_MethodTypeInError;
coleenp@3602 81 }
coleenp@3602 82
duke@0 83 bool is_klass_index() const { return _tag == JVM_CONSTANT_ClassIndex; }
duke@0 84 bool is_string_index() const { return _tag == JVM_CONSTANT_StringIndex; }
duke@0 85
duke@0 86 bool is_klass_reference() const { return is_klass_index() || is_unresolved_klass(); }
jrose@431 87 bool is_klass_or_reference() const{ return is_klass() || is_klass_reference(); }
duke@0 88 bool is_field_or_method() const { return is_field() || is_method() || is_interface_method(); }
duke@0 89 bool is_symbol() const { return is_utf8(); }
duke@0 90
jrose@1522 91 bool is_method_type() const { return _tag == JVM_CONSTANT_MethodType; }
jrose@1522 92 bool is_method_handle() const { return _tag == JVM_CONSTANT_MethodHandle; }
jrose@2307 93 bool is_invoke_dynamic() const { return _tag == JVM_CONSTANT_InvokeDynamic; }
jrose@1522 94
jrose@1833 95 bool is_loadable_constant() const {
jrose@1833 96 return ((_tag >= JVM_CONSTANT_Integer && _tag <= JVM_CONSTANT_String) ||
jrose@1833 97 is_method_type() || is_method_handle() ||
coleenp@4208 98 is_unresolved_klass());
jrose@1833 99 }
jrose@1833 100
jrose@1522 101 constantTag() {
jrose@1522 102 _tag = JVM_CONSTANT_Invalid;
jrose@1522 103 }
duke@0 104 constantTag(jbyte tag) {
duke@0 105 assert((tag >= 0 && tag <= JVM_CONSTANT_NameAndType) ||
jrose@1580 106 (tag >= JVM_CONSTANT_MethodHandle && tag <= JVM_CONSTANT_InvokeDynamic) ||
duke@0 107 (tag >= JVM_CONSTANT_InternalMin && tag <= JVM_CONSTANT_InternalMax), "Invalid constant tag");
duke@0 108 _tag = tag;
duke@0 109 }
duke@0 110
coleenp@5454 111 jbyte value() const { return _tag; }
coleenp@6384 112 jbyte error_value() const;
coleenp@5454 113 jbyte non_error_value() const;
duke@0 114
jrose@1522 115 BasicType basic_type() const; // if used with ldc, what kind of value gets pushed?
jrose@1522 116
jrose@1522 117 const char* internal_name() const; // for error reporting
jrose@1522 118
duke@0 119 void print_on(outputStream* st) const PRODUCT_RETURN;
duke@0 120 };
stefank@1879 121
stefank@1879 122 #endif // SHARE_VM_UTILITIES_CONSTANTTAG_HPP