src/share/vm/utilities/constantTag.hpp

Tue, 05 Apr 2011 14:12:31 -0700

author
trims
date
Tue, 05 Apr 2011 14:12:31 -0700
changeset 2708
1d1603768966
parent 2353
dad31fc330cd
child 2742
ed69575596ac
permissions
-rw-r--r--

7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
Summary: Update the copyright to be 2010 on all changed files in OpenJDK
Reviewed-by: ohair

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

mercurial