annotate src/share/vm/classfile/verificationType.hpp @ 2244:4f26f535a225

6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111" Reviewed-by: jrose, acorn
author never
date Mon, 31 Jan 2011 17:48:21 -0800
parents 3582bf76420e
children c1a6154012c8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_CLASSFILE_VERIFICATIONTYPE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_CLASSFILE_VERIFICATIONTYPE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "oops/instanceKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "oops/oop.inline.hpp"
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
32 #include "oops/symbol.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #include "runtime/handles.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #include "runtime/signature.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // As specifed in the JVM spec
a61af66fc99e Initial load
duke
parents:
diff changeset
38 ITEM_Top = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
39 ITEM_Integer = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
40 ITEM_Float = 2,
a61af66fc99e Initial load
duke
parents:
diff changeset
41 ITEM_Double = 3,
a61af66fc99e Initial load
duke
parents:
diff changeset
42 ITEM_Long = 4,
a61af66fc99e Initial load
duke
parents:
diff changeset
43 ITEM_Null = 5,
a61af66fc99e Initial load
duke
parents:
diff changeset
44 ITEM_UninitializedThis = 6,
a61af66fc99e Initial load
duke
parents:
diff changeset
45 ITEM_Object = 7,
a61af66fc99e Initial load
duke
parents:
diff changeset
46 ITEM_Uninitialized = 8,
a61af66fc99e Initial load
duke
parents:
diff changeset
47 ITEM_Bogus = (uint)-1
a61af66fc99e Initial load
duke
parents:
diff changeset
48 };
a61af66fc99e Initial load
duke
parents:
diff changeset
49
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
50 class ClassVerifier;
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
51
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 class VerificationType VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // Least significant bits of _handle are always 0, so we use these as
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // the indicator that the _handle is valid. Otherwise, the _data field
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // contains encoded data (as specified below). Should the VM change
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // and the lower bits on oops aren't 0, the assert in the constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // will catch this and we'll have to add a descriminator tag to this
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // structure.
a61af66fc99e Initial load
duke
parents:
diff changeset
60 union {
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
61 Symbol* _sym;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
62 uintptr_t _data;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 } _u;
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // These rest are not found in classfiles, but used by the verifier
a61af66fc99e Initial load
duke
parents:
diff changeset
67 ITEM_Boolean = 9, ITEM_Byte, ITEM_Short, ITEM_Char,
a61af66fc99e Initial load
duke
parents:
diff changeset
68 ITEM_Long_2nd, ITEM_Double_2nd
a61af66fc99e Initial load
duke
parents:
diff changeset
69 };
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // Enum for the _data field
a61af66fc99e Initial load
duke
parents:
diff changeset
72 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // Bottom two bits determine if the type is a reference, primitive,
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // uninitialized or a query-type.
a61af66fc99e Initial load
duke
parents:
diff changeset
75 TypeMask = 0x00000003,
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // Topmost types encoding
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
78 Reference = 0x0, // _sym contains the name
0
a61af66fc99e Initial load
duke
parents:
diff changeset
79 Primitive = 0x1, // see below for primitive list
a61af66fc99e Initial load
duke
parents:
diff changeset
80 Uninitialized = 0x2, // 0x00ffff00 contains bci
a61af66fc99e Initial load
duke
parents:
diff changeset
81 TypeQuery = 0x3, // Meta-types used for category testing
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Utility flags
a61af66fc99e Initial load
duke
parents:
diff changeset
84 ReferenceFlag = 0x00, // For reference query types
a61af66fc99e Initial load
duke
parents:
diff changeset
85 Category1Flag = 0x01, // One-word values
a61af66fc99e Initial load
duke
parents:
diff changeset
86 Category2Flag = 0x02, // First word of a two-word value
a61af66fc99e Initial load
duke
parents:
diff changeset
87 Category2_2ndFlag = 0x04, // Second word of a two-word value
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // special reference values
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
90 Null = 0x00000000, // A reference with a 0 sym is null
0
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // Primitives categories (the second byte determines the category)
a61af66fc99e Initial load
duke
parents:
diff changeset
93 Category1 = (Category1Flag << 1 * BitsPerByte) | Primitive,
a61af66fc99e Initial load
duke
parents:
diff changeset
94 Category2 = (Category2Flag << 1 * BitsPerByte) | Primitive,
a61af66fc99e Initial load
duke
parents:
diff changeset
95 Category2_2nd = (Category2_2ndFlag << 1 * BitsPerByte) | Primitive,
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // Primitive values (type descriminator stored in most-signifcant bytes)
a61af66fc99e Initial load
duke
parents:
diff changeset
98 Bogus = (ITEM_Bogus << 2 * BitsPerByte) | Category1,
a61af66fc99e Initial load
duke
parents:
diff changeset
99 Boolean = (ITEM_Boolean << 2 * BitsPerByte) | Category1,
a61af66fc99e Initial load
duke
parents:
diff changeset
100 Byte = (ITEM_Byte << 2 * BitsPerByte) | Category1,
a61af66fc99e Initial load
duke
parents:
diff changeset
101 Short = (ITEM_Short << 2 * BitsPerByte) | Category1,
a61af66fc99e Initial load
duke
parents:
diff changeset
102 Char = (ITEM_Char << 2 * BitsPerByte) | Category1,
a61af66fc99e Initial load
duke
parents:
diff changeset
103 Integer = (ITEM_Integer << 2 * BitsPerByte) | Category1,
a61af66fc99e Initial load
duke
parents:
diff changeset
104 Float = (ITEM_Float << 2 * BitsPerByte) | Category1,
a61af66fc99e Initial load
duke
parents:
diff changeset
105 Long = (ITEM_Long << 2 * BitsPerByte) | Category2,
a61af66fc99e Initial load
duke
parents:
diff changeset
106 Double = (ITEM_Double << 2 * BitsPerByte) | Category2,
a61af66fc99e Initial load
duke
parents:
diff changeset
107 Long_2nd = (ITEM_Long_2nd << 2 * BitsPerByte) | Category2_2nd,
a61af66fc99e Initial load
duke
parents:
diff changeset
108 Double_2nd = (ITEM_Double_2nd << 2 * BitsPerByte) | Category2_2nd,
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // Used by Uninitialized (second and third bytes hold the bci)
a61af66fc99e Initial load
duke
parents:
diff changeset
111 BciMask = 0xffff << 1 * BitsPerByte,
a61af66fc99e Initial load
duke
parents:
diff changeset
112 BciForThis = ((u2)-1), // A bci of -1 is an Unintialized-This
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // Query values
a61af66fc99e Initial load
duke
parents:
diff changeset
115 ReferenceQuery = (ReferenceFlag << 1 * BitsPerByte) | TypeQuery,
a61af66fc99e Initial load
duke
parents:
diff changeset
116 Category1Query = (Category1Flag << 1 * BitsPerByte) | TypeQuery,
a61af66fc99e Initial load
duke
parents:
diff changeset
117 Category2Query = (Category2Flag << 1 * BitsPerByte) | TypeQuery,
a61af66fc99e Initial load
duke
parents:
diff changeset
118 Category2_2ndQuery = (Category2_2ndFlag << 1 * BitsPerByte) | TypeQuery
a61af66fc99e Initial load
duke
parents:
diff changeset
119 };
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 VerificationType(uintptr_t raw_data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 _u._data = raw_data;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 VerificationType() { *this = bogus_type(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Create verification types
a61af66fc99e Initial load
duke
parents:
diff changeset
130 static VerificationType bogus_type() { return VerificationType(Bogus); }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 static VerificationType null_type() { return VerificationType(Null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 static VerificationType integer_type() { return VerificationType(Integer); }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 static VerificationType float_type() { return VerificationType(Float); }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 static VerificationType long_type() { return VerificationType(Long); }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 static VerificationType long2_type() { return VerificationType(Long_2nd); }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 static VerificationType double_type() { return VerificationType(Double); }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 static VerificationType boolean_type() { return VerificationType(Boolean); }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 static VerificationType byte_type() { return VerificationType(Byte); }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 static VerificationType char_type() { return VerificationType(Char); }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 static VerificationType short_type() { return VerificationType(Short); }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 static VerificationType double2_type()
a61af66fc99e Initial load
duke
parents:
diff changeset
142 { return VerificationType(Double_2nd); }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // "check" types are used for queries. A "check" type is not assignable
a61af66fc99e Initial load
duke
parents:
diff changeset
145 // to anything, but the specified types are assignable to a "check". For
a61af66fc99e Initial load
duke
parents:
diff changeset
146 // example, any category1 primitive is assignable to category1_check and
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // any reference is assignable to reference_check.
a61af66fc99e Initial load
duke
parents:
diff changeset
148 static VerificationType reference_check()
a61af66fc99e Initial load
duke
parents:
diff changeset
149 { return VerificationType(ReferenceQuery); }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 static VerificationType category1_check()
a61af66fc99e Initial load
duke
parents:
diff changeset
151 { return VerificationType(Category1Query); }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 static VerificationType category2_check()
a61af66fc99e Initial load
duke
parents:
diff changeset
153 { return VerificationType(Category2Query); }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 static VerificationType category2_2nd_check()
a61af66fc99e Initial load
duke
parents:
diff changeset
155 { return VerificationType(Category2_2ndQuery); }
a61af66fc99e Initial load
duke
parents:
diff changeset
156
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
157 // For reference types, store the actual Symbol
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
158 static VerificationType reference_type(Symbol* sh) {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
159 assert(((uintptr_t)sh & 0x3) == 0, "Oops must be aligned");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // If the above assert fails in the future because oop* isn't aligned,
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // then this type encoding system will have to change to have a tag value
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // to descriminate between oops and primitives.
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
163 return VerificationType((uintptr_t)sh);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 static VerificationType uninitialized_type(u2 bci)
a61af66fc99e Initial load
duke
parents:
diff changeset
166 { return VerificationType(bci << 1 * BitsPerByte | Uninitialized); }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 static VerificationType uninitialized_this_type()
a61af66fc99e Initial load
duke
parents:
diff changeset
168 { return uninitialized_type(BciForThis); }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // Create based on u1 read from classfile
a61af66fc99e Initial load
duke
parents:
diff changeset
171 static VerificationType from_tag(u1 tag);
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 bool is_bogus() const { return (_u._data == Bogus); }
a61af66fc99e Initial load
duke
parents:
diff changeset
174 bool is_null() const { return (_u._data == Null); }
a61af66fc99e Initial load
duke
parents:
diff changeset
175 bool is_boolean() const { return (_u._data == Boolean); }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 bool is_byte() const { return (_u._data == Byte); }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 bool is_char() const { return (_u._data == Char); }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 bool is_short() const { return (_u._data == Short); }
a61af66fc99e Initial load
duke
parents:
diff changeset
179 bool is_integer() const { return (_u._data == Integer); }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 bool is_long() const { return (_u._data == Long); }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 bool is_float() const { return (_u._data == Float); }
a61af66fc99e Initial load
duke
parents:
diff changeset
182 bool is_double() const { return (_u._data == Double); }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 bool is_long2() const { return (_u._data == Long_2nd); }
a61af66fc99e Initial load
duke
parents:
diff changeset
184 bool is_double2() const { return (_u._data == Double_2nd); }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 bool is_reference() const { return ((_u._data & TypeMask) == Reference); }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 bool is_category1() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // This should return true for all one-word types, which are category1
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // primitives, and references (including uninitialized refs). Though
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // the 'query' types should technically return 'false' here, if we
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // allow this to return true, we can perform the test using only
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // 2 operations rather than 8 (3 masks, 3 compares and 2 logical 'ands').
a61af66fc99e Initial load
duke
parents:
diff changeset
192 // Since noone should call this on a query type anyway, this is ok.
a61af66fc99e Initial load
duke
parents:
diff changeset
193 assert(!is_check(), "Must not be a check type (wrong value returned)");
a61af66fc99e Initial load
duke
parents:
diff changeset
194 return ((_u._data & Category1) != Primitive);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // should only return false if it's a primitive, and the category1 flag
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // is not set.
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 bool is_category2() const { return ((_u._data & Category2) == Category2); }
a61af66fc99e Initial load
duke
parents:
diff changeset
199 bool is_category2_2nd() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 return ((_u._data & Category2_2nd) == Category2_2nd);
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 bool is_reference_check() const { return _u._data == ReferenceQuery; }
a61af66fc99e Initial load
duke
parents:
diff changeset
203 bool is_category1_check() const { return _u._data == Category1Query; }
a61af66fc99e Initial load
duke
parents:
diff changeset
204 bool is_category2_check() const { return _u._data == Category2Query; }
a61af66fc99e Initial load
duke
parents:
diff changeset
205 bool is_category2_2nd_check() const { return _u._data == Category2_2ndQuery; }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 bool is_check() const { return (_u._data & TypeQuery) == TypeQuery; }
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 bool is_x_array(char sig) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 return is_null() || (is_array() && (name()->byte_at(1) == sig));
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211 bool is_int_array() const { return is_x_array('I'); }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 bool is_byte_array() const { return is_x_array('B'); }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 bool is_bool_array() const { return is_x_array('Z'); }
a61af66fc99e Initial load
duke
parents:
diff changeset
214 bool is_char_array() const { return is_x_array('C'); }
a61af66fc99e Initial load
duke
parents:
diff changeset
215 bool is_short_array() const { return is_x_array('S'); }
a61af66fc99e Initial load
duke
parents:
diff changeset
216 bool is_long_array() const { return is_x_array('J'); }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 bool is_float_array() const { return is_x_array('F'); }
a61af66fc99e Initial load
duke
parents:
diff changeset
218 bool is_double_array() const { return is_x_array('D'); }
a61af66fc99e Initial load
duke
parents:
diff changeset
219 bool is_object_array() const { return is_x_array('L'); }
a61af66fc99e Initial load
duke
parents:
diff changeset
220 bool is_array_array() const { return is_x_array('['); }
a61af66fc99e Initial load
duke
parents:
diff changeset
221 bool is_reference_array() const
a61af66fc99e Initial load
duke
parents:
diff changeset
222 { return is_object_array() || is_array_array(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 bool is_object() const
a61af66fc99e Initial load
duke
parents:
diff changeset
224 { return (is_reference() && !is_null() && name()->utf8_length() >= 1 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
225 name()->byte_at(0) != '['); }
a61af66fc99e Initial load
duke
parents:
diff changeset
226 bool is_array() const
a61af66fc99e Initial load
duke
parents:
diff changeset
227 { return (is_reference() && !is_null() && name()->utf8_length() >= 2 &&
a61af66fc99e Initial load
duke
parents:
diff changeset
228 name()->byte_at(0) == '['); }
a61af66fc99e Initial load
duke
parents:
diff changeset
229 bool is_uninitialized() const
a61af66fc99e Initial load
duke
parents:
diff changeset
230 { return ((_u._data & Uninitialized) == Uninitialized); }
a61af66fc99e Initial load
duke
parents:
diff changeset
231 bool is_uninitialized_this() const
a61af66fc99e Initial load
duke
parents:
diff changeset
232 { return is_uninitialized() && bci() == BciForThis; }
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 VerificationType to_category2_2nd() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 assert(is_category2(), "Must be a double word");
a61af66fc99e Initial load
duke
parents:
diff changeset
236 return VerificationType(is_long() ? Long_2nd : Double_2nd);
a61af66fc99e Initial load
duke
parents:
diff changeset
237 }
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 u2 bci() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 assert(is_uninitialized(), "Must be uninitialized type");
a61af66fc99e Initial load
duke
parents:
diff changeset
241 return ((_u._data & BciMask) >> 1 * BitsPerByte);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
244 Symbol* name() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
245 assert(is_reference() && !is_null(), "Must be a non-null reference");
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
246 return _u._sym;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
247 }
a61af66fc99e Initial load
duke
parents:
diff changeset
248
a61af66fc99e Initial load
duke
parents:
diff changeset
249 bool equals(const VerificationType& t) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 return (_u._data == t._u._data ||
a61af66fc99e Initial load
duke
parents:
diff changeset
251 (is_reference() && t.is_reference() && !is_null() && !t.is_null() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
252 name() == t.name()));
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 bool operator ==(const VerificationType& t) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 return equals(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 bool operator !=(const VerificationType& t) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
260 return !equals(t);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // The whole point of this type system - check to see if one type
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // is assignable to another. Returns true if one can assign 'from' to
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // this.
a61af66fc99e Initial load
duke
parents:
diff changeset
266 bool is_assignable_from(
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
267 const VerificationType& from, ClassVerifier* context, TRAPS) const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
268 if (equals(from) || is_bogus()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
269 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
270 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 switch(_u._data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 case Category1Query:
a61af66fc99e Initial load
duke
parents:
diff changeset
273 return from.is_category1();
a61af66fc99e Initial load
duke
parents:
diff changeset
274 case Category2Query:
a61af66fc99e Initial load
duke
parents:
diff changeset
275 return from.is_category2();
a61af66fc99e Initial load
duke
parents:
diff changeset
276 case Category2_2ndQuery:
a61af66fc99e Initial load
duke
parents:
diff changeset
277 return from.is_category2_2nd();
a61af66fc99e Initial load
duke
parents:
diff changeset
278 case ReferenceQuery:
a61af66fc99e Initial load
duke
parents:
diff changeset
279 return from.is_reference() || from.is_uninitialized();
a61af66fc99e Initial load
duke
parents:
diff changeset
280 case Boolean:
a61af66fc99e Initial load
duke
parents:
diff changeset
281 case Byte:
a61af66fc99e Initial load
duke
parents:
diff changeset
282 case Char:
a61af66fc99e Initial load
duke
parents:
diff changeset
283 case Short:
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // An int can be assigned to boolean, byte, char or short values.
a61af66fc99e Initial load
duke
parents:
diff changeset
285 return from.is_integer();
a61af66fc99e Initial load
duke
parents:
diff changeset
286 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
287 if (is_reference() && from.is_reference()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
288 return is_reference_assignable_from(from, context, CHECK_false);
a61af66fc99e Initial load
duke
parents:
diff changeset
289 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
290 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
296 VerificationType get_component(ClassVerifier* context, TRAPS) const;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
297
a61af66fc99e Initial load
duke
parents:
diff changeset
298 int dimensions() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
299 assert(is_array(), "Must be an array");
a61af66fc99e Initial load
duke
parents:
diff changeset
300 int index = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
301 while (name()->byte_at(index++) == '[');
a61af66fc99e Initial load
duke
parents:
diff changeset
302 return index;
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304
a61af66fc99e Initial load
duke
parents:
diff changeset
305 void print_on(outputStream* st) const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 bool is_reference_assignable_from(
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
310 const VerificationType&, ClassVerifier*, TRAPS) const;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
311 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
312
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
313 #endif // SHARE_VM_CLASSFILE_VERIFICATIONTYPE_HPP