duke@435: /* coleenp@4643: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_UTILITIES_CONSTANTTAG_HPP stefank@2314: #define SHARE_VM_UTILITIES_CONSTANTTAG_HPP stefank@2314: stefank@2314: #include "prims/jvm.h" stefank@2314: #include "utilities/top.hpp" stefank@2314: duke@435: // constant tags in Java .class files duke@435: duke@435: duke@435: enum { duke@435: // See jvm.h for shared JVM_CONSTANT_XXX tags duke@435: // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/utilities/ConstantTag.java duke@435: // Hotspot specific tags duke@435: JVM_CONSTANT_Invalid = 0, // For bad value initialization duke@435: JVM_CONSTANT_InternalMin = 100, // First implementation tag (aside from bad value of course) duke@435: JVM_CONSTANT_UnresolvedClass = 100, // Temporary tag until actual use duke@435: JVM_CONSTANT_ClassIndex = 101, // Temporary tag while constructing constant pool coleenp@4037: JVM_CONSTANT_StringIndex = 102, // Temporary tag while constructing constant pool coleenp@4037: JVM_CONSTANT_UnresolvedClassInError = 103, // Error tag due to resolution error coleenp@4037: JVM_CONSTANT_MethodHandleInError = 104, // Error tag due to resolution error coleenp@4037: JVM_CONSTANT_MethodTypeInError = 105, // Error tag due to resolution error coleenp@4643: JVM_CONSTANT_InternalMax = 105 // Last implementation tag duke@435: }; duke@435: duke@435: duke@435: class constantTag VALUE_OBJ_CLASS_SPEC { duke@435: private: duke@435: jbyte _tag; duke@435: public: duke@435: bool is_klass() const { return _tag == JVM_CONSTANT_Class; } duke@435: bool is_field () const { return _tag == JVM_CONSTANT_Fieldref; } duke@435: bool is_method() const { return _tag == JVM_CONSTANT_Methodref; } duke@435: bool is_interface_method() const { return _tag == JVM_CONSTANT_InterfaceMethodref; } duke@435: bool is_string() const { return _tag == JVM_CONSTANT_String; } duke@435: bool is_int() const { return _tag == JVM_CONSTANT_Integer; } duke@435: bool is_float() const { return _tag == JVM_CONSTANT_Float; } duke@435: bool is_long() const { return _tag == JVM_CONSTANT_Long; } duke@435: bool is_double() const { return _tag == JVM_CONSTANT_Double; } duke@435: bool is_name_and_type() const { return _tag == JVM_CONSTANT_NameAndType; } duke@435: bool is_utf8() const { return _tag == JVM_CONSTANT_Utf8; } duke@435: duke@435: bool is_invalid() const { return _tag == JVM_CONSTANT_Invalid; } duke@435: duke@435: bool is_unresolved_klass() const { duke@435: return _tag == JVM_CONSTANT_UnresolvedClass || _tag == JVM_CONSTANT_UnresolvedClassInError; duke@435: } duke@435: duke@435: bool is_unresolved_klass_in_error() const { duke@435: return _tag == JVM_CONSTANT_UnresolvedClassInError; duke@435: } duke@435: coleenp@4037: bool is_method_handle_in_error() const { coleenp@4037: return _tag == JVM_CONSTANT_MethodHandleInError; coleenp@4037: } coleenp@4037: bool is_method_type_in_error() const { coleenp@4037: return _tag == JVM_CONSTANT_MethodTypeInError; coleenp@4037: } coleenp@4037: duke@435: bool is_klass_index() const { return _tag == JVM_CONSTANT_ClassIndex; } duke@435: bool is_string_index() const { return _tag == JVM_CONSTANT_StringIndex; } duke@435: duke@435: bool is_klass_reference() const { return is_klass_index() || is_unresolved_klass(); } jrose@866: bool is_klass_or_reference() const{ return is_klass() || is_klass_reference(); } duke@435: bool is_field_or_method() const { return is_field() || is_method() || is_interface_method(); } duke@435: bool is_symbol() const { return is_utf8(); } duke@435: jrose@1957: bool is_method_type() const { return _tag == JVM_CONSTANT_MethodType; } jrose@1957: bool is_method_handle() const { return _tag == JVM_CONSTANT_MethodHandle; } jrose@2742: bool is_invoke_dynamic() const { return _tag == JVM_CONSTANT_InvokeDynamic; } jrose@1957: jrose@2268: bool is_loadable_constant() const { jrose@2268: return ((_tag >= JVM_CONSTANT_Integer && _tag <= JVM_CONSTANT_String) || jrose@2268: is_method_type() || is_method_handle() || coleenp@4643: is_unresolved_klass()); jrose@2268: } jrose@2268: jrose@1957: constantTag() { jrose@1957: _tag = JVM_CONSTANT_Invalid; jrose@1957: } duke@435: constantTag(jbyte tag) { duke@435: assert((tag >= 0 && tag <= JVM_CONSTANT_NameAndType) || jrose@2015: (tag >= JVM_CONSTANT_MethodHandle && tag <= JVM_CONSTANT_InvokeDynamic) || duke@435: (tag >= JVM_CONSTANT_InternalMin && tag <= JVM_CONSTANT_InternalMax), "Invalid constant tag"); duke@435: _tag = tag; duke@435: } duke@435: coleenp@5889: jbyte value() const { return _tag; } coleenp@5889: jbyte non_error_value() const; duke@435: jrose@1957: BasicType basic_type() const; // if used with ldc, what kind of value gets pushed? jrose@1957: jrose@1957: const char* internal_name() const; // for error reporting jrose@1957: duke@435: void print_on(outputStream* st) const PRODUCT_RETURN; duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_UTILITIES_CONSTANTTAG_HPP