Mercurial > hg > graal-compiler
comparison src/share/vm/classfile/verificationType.hpp @ 2177:3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
Summary: move symbols from permgen into C heap and reference count them
Reviewed-by: never, acorn, jmasa, stefank
author | coleenp |
---|---|
date | Thu, 27 Jan 2011 16:11:27 -0800 |
parents | f95d63e2154a |
children | c1a6154012c8 |
comparison
equal
deleted
inserted
replaced
2176:27e4ea99855d | 2177:3582bf76420e |
---|---|
27 | 27 |
28 #include "classfile/systemDictionary.hpp" | 28 #include "classfile/systemDictionary.hpp" |
29 #include "memory/allocation.hpp" | 29 #include "memory/allocation.hpp" |
30 #include "oops/instanceKlass.hpp" | 30 #include "oops/instanceKlass.hpp" |
31 #include "oops/oop.inline.hpp" | 31 #include "oops/oop.inline.hpp" |
32 #include "oops/symbolOop.hpp" | 32 #include "oops/symbol.hpp" |
33 #include "runtime/handles.hpp" | 33 #include "runtime/handles.hpp" |
34 #include "runtime/signature.hpp" | 34 #include "runtime/signature.hpp" |
35 | 35 |
36 enum { | 36 enum { |
37 // As specifed in the JVM spec | 37 // As specifed in the JVM spec |
45 ITEM_Object = 7, | 45 ITEM_Object = 7, |
46 ITEM_Uninitialized = 8, | 46 ITEM_Uninitialized = 8, |
47 ITEM_Bogus = (uint)-1 | 47 ITEM_Bogus = (uint)-1 |
48 }; | 48 }; |
49 | 49 |
50 class ClassVerifier; | |
51 | |
50 class VerificationType VALUE_OBJ_CLASS_SPEC { | 52 class VerificationType VALUE_OBJ_CLASS_SPEC { |
51 private: | 53 private: |
52 // Least significant bits of _handle are always 0, so we use these as | 54 // Least significant bits of _handle are always 0, so we use these as |
53 // the indicator that the _handle is valid. Otherwise, the _data field | 55 // the indicator that the _handle is valid. Otherwise, the _data field |
54 // contains encoded data (as specified below). Should the VM change | 56 // contains encoded data (as specified below). Should the VM change |
55 // and the lower bits on oops aren't 0, the assert in the constructor | 57 // and the lower bits on oops aren't 0, the assert in the constructor |
56 // will catch this and we'll have to add a descriminator tag to this | 58 // will catch this and we'll have to add a descriminator tag to this |
57 // structure. | 59 // structure. |
58 union { | 60 union { |
59 symbolOop* _handle; | 61 Symbol* _sym; |
60 uintptr_t _data; | 62 uintptr_t _data; |
61 } _u; | 63 } _u; |
62 | 64 |
63 enum { | 65 enum { |
64 // These rest are not found in classfiles, but used by the verifier | 66 // These rest are not found in classfiles, but used by the verifier |
71 // Bottom two bits determine if the type is a reference, primitive, | 73 // Bottom two bits determine if the type is a reference, primitive, |
72 // uninitialized or a query-type. | 74 // uninitialized or a query-type. |
73 TypeMask = 0x00000003, | 75 TypeMask = 0x00000003, |
74 | 76 |
75 // Topmost types encoding | 77 // Topmost types encoding |
76 Reference = 0x0, // _handle contains the name | 78 Reference = 0x0, // _sym contains the name |
77 Primitive = 0x1, // see below for primitive list | 79 Primitive = 0x1, // see below for primitive list |
78 Uninitialized = 0x2, // 0x00ffff00 contains bci | 80 Uninitialized = 0x2, // 0x00ffff00 contains bci |
79 TypeQuery = 0x3, // Meta-types used for category testing | 81 TypeQuery = 0x3, // Meta-types used for category testing |
80 | 82 |
81 // Utility flags | 83 // Utility flags |
83 Category1Flag = 0x01, // One-word values | 85 Category1Flag = 0x01, // One-word values |
84 Category2Flag = 0x02, // First word of a two-word value | 86 Category2Flag = 0x02, // First word of a two-word value |
85 Category2_2ndFlag = 0x04, // Second word of a two-word value | 87 Category2_2ndFlag = 0x04, // Second word of a two-word value |
86 | 88 |
87 // special reference values | 89 // special reference values |
88 Null = 0x00000000, // A reference with a 0 handle is null | 90 Null = 0x00000000, // A reference with a 0 sym is null |
89 | 91 |
90 // Primitives categories (the second byte determines the category) | 92 // Primitives categories (the second byte determines the category) |
91 Category1 = (Category1Flag << 1 * BitsPerByte) | Primitive, | 93 Category1 = (Category1Flag << 1 * BitsPerByte) | Primitive, |
92 Category2 = (Category2Flag << 1 * BitsPerByte) | Primitive, | 94 Category2 = (Category2Flag << 1 * BitsPerByte) | Primitive, |
93 Category2_2nd = (Category2_2ndFlag << 1 * BitsPerByte) | Primitive, | 95 Category2_2nd = (Category2_2ndFlag << 1 * BitsPerByte) | Primitive, |
150 static VerificationType category2_check() | 152 static VerificationType category2_check() |
151 { return VerificationType(Category2Query); } | 153 { return VerificationType(Category2Query); } |
152 static VerificationType category2_2nd_check() | 154 static VerificationType category2_2nd_check() |
153 { return VerificationType(Category2_2ndQuery); } | 155 { return VerificationType(Category2_2ndQuery); } |
154 | 156 |
155 // For reference types, store the actual oop* handle | 157 // For reference types, store the actual Symbol |
156 static VerificationType reference_type(symbolHandle sh) { | 158 static VerificationType reference_type(Symbol* sh) { |
157 assert(((uintptr_t)sh.raw_value() & 0x3) == 0, "Oops must be aligned"); | 159 assert(((uintptr_t)sh & 0x3) == 0, "Oops must be aligned"); |
158 // If the above assert fails in the future because oop* isn't aligned, | 160 // If the above assert fails in the future because oop* isn't aligned, |
159 // then this type encoding system will have to change to have a tag value | 161 // then this type encoding system will have to change to have a tag value |
160 // to descriminate between oops and primitives. | 162 // to descriminate between oops and primitives. |
161 return VerificationType((uintptr_t)((symbolOop*)sh.raw_value())); | 163 return VerificationType((uintptr_t)sh); |
162 } | 164 } |
163 static VerificationType reference_type(symbolOop s, TRAPS) | |
164 { return reference_type(symbolHandle(THREAD, s)); } | |
165 | |
166 static VerificationType uninitialized_type(u2 bci) | 165 static VerificationType uninitialized_type(u2 bci) |
167 { return VerificationType(bci << 1 * BitsPerByte | Uninitialized); } | 166 { return VerificationType(bci << 1 * BitsPerByte | Uninitialized); } |
168 static VerificationType uninitialized_this_type() | 167 static VerificationType uninitialized_this_type() |
169 { return uninitialized_type(BciForThis); } | 168 { return uninitialized_type(BciForThis); } |
170 | 169 |
240 u2 bci() const { | 239 u2 bci() const { |
241 assert(is_uninitialized(), "Must be uninitialized type"); | 240 assert(is_uninitialized(), "Must be uninitialized type"); |
242 return ((_u._data & BciMask) >> 1 * BitsPerByte); | 241 return ((_u._data & BciMask) >> 1 * BitsPerByte); |
243 } | 242 } |
244 | 243 |
245 symbolHandle name_handle() const { | 244 Symbol* name() const { |
246 assert(is_reference() && !is_null(), "Must be a non-null reference"); | 245 assert(is_reference() && !is_null(), "Must be a non-null reference"); |
247 return symbolHandle(_u._handle, true); | 246 return _u._sym; |
248 } | |
249 symbolOop name() const { | |
250 assert(is_reference() && !is_null(), "Must be a non-null reference"); | |
251 return *(_u._handle); | |
252 } | 247 } |
253 | 248 |
254 bool equals(const VerificationType& t) const { | 249 bool equals(const VerificationType& t) const { |
255 return (_u._data == t._u._data || | 250 return (_u._data == t._u._data || |
256 (is_reference() && t.is_reference() && !is_null() && !t.is_null() && | 251 (is_reference() && t.is_reference() && !is_null() && !t.is_null() && |
267 | 262 |
268 // The whole point of this type system - check to see if one type | 263 // The whole point of this type system - check to see if one type |
269 // is assignable to another. Returns true if one can assign 'from' to | 264 // is assignable to another. Returns true if one can assign 'from' to |
270 // this. | 265 // this. |
271 bool is_assignable_from( | 266 bool is_assignable_from( |
272 const VerificationType& from, instanceKlassHandle context, TRAPS) const { | 267 const VerificationType& from, ClassVerifier* context, TRAPS) const { |
273 if (equals(from) || is_bogus()) { | 268 if (equals(from) || is_bogus()) { |
274 return true; | 269 return true; |
275 } else { | 270 } else { |
276 switch(_u._data) { | 271 switch(_u._data) { |
277 case Category1Query: | 272 case Category1Query: |
296 } | 291 } |
297 } | 292 } |
298 } | 293 } |
299 } | 294 } |
300 | 295 |
301 VerificationType get_component(TRAPS) const; | 296 VerificationType get_component(ClassVerifier* context, TRAPS) const; |
302 | 297 |
303 int dimensions() const { | 298 int dimensions() const { |
304 assert(is_array(), "Must be an array"); | 299 assert(is_array(), "Must be an array"); |
305 int index = 0; | 300 int index = 0; |
306 while (name()->byte_at(index++) == '['); | 301 while (name()->byte_at(index++) == '['); |
310 void print_on(outputStream* st) const PRODUCT_RETURN; | 305 void print_on(outputStream* st) const PRODUCT_RETURN; |
311 | 306 |
312 private: | 307 private: |
313 | 308 |
314 bool is_reference_assignable_from( | 309 bool is_reference_assignable_from( |
315 const VerificationType&, instanceKlassHandle, TRAPS) const; | 310 const VerificationType&, ClassVerifier*, TRAPS) const; |
316 }; | 311 }; |
317 | 312 |
318 #endif // SHARE_VM_CLASSFILE_VERIFICATIONTYPE_HPP | 313 #endif // SHARE_VM_CLASSFILE_VERIFICATIONTYPE_HPP |