Mercurial > hg > graal-compiler
comparison src/share/vm/classfile/verificationType.cpp @ 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 | 1d1603768966 |
comparison
equal
deleted
inserted
replaced
2176:27e4ea99855d | 2177:3582bf76420e |
---|---|
23 */ | 23 */ |
24 | 24 |
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 #include "classfile/symbolTable.hpp" | 26 #include "classfile/symbolTable.hpp" |
27 #include "classfile/verificationType.hpp" | 27 #include "classfile/verificationType.hpp" |
28 #include "classfile/verifier.hpp" | |
28 | 29 |
29 VerificationType VerificationType::from_tag(u1 tag) { | 30 VerificationType VerificationType::from_tag(u1 tag) { |
30 switch (tag) { | 31 switch (tag) { |
31 case ITEM_Top: return bogus_type(); | 32 case ITEM_Top: return bogus_type(); |
32 case ITEM_Integer: return integer_type(); | 33 case ITEM_Integer: return integer_type(); |
39 return bogus_type(); | 40 return bogus_type(); |
40 } | 41 } |
41 } | 42 } |
42 | 43 |
43 bool VerificationType::is_reference_assignable_from( | 44 bool VerificationType::is_reference_assignable_from( |
44 const VerificationType& from, instanceKlassHandle context, TRAPS) const { | 45 const VerificationType& from, ClassVerifier* context, TRAPS) const { |
46 instanceKlassHandle klass = context->current_class(); | |
45 if (from.is_null()) { | 47 if (from.is_null()) { |
46 // null is assignable to any reference | 48 // null is assignable to any reference |
47 return true; | 49 return true; |
48 } else if (is_null()) { | 50 } else if (is_null()) { |
49 return false; | 51 return false; |
54 if (name() == vmSymbols::java_lang_Object()) { | 56 if (name() == vmSymbols::java_lang_Object()) { |
55 // any object or array is assignable to java.lang.Object | 57 // any object or array is assignable to java.lang.Object |
56 return true; | 58 return true; |
57 } | 59 } |
58 klassOop obj = SystemDictionary::resolve_or_fail( | 60 klassOop obj = SystemDictionary::resolve_or_fail( |
59 name_handle(), Handle(THREAD, context->class_loader()), | 61 name(), Handle(THREAD, klass->class_loader()), |
60 Handle(THREAD, context->protection_domain()), true, CHECK_false); | 62 Handle(THREAD, klass->protection_domain()), true, CHECK_false); |
61 KlassHandle this_class(THREAD, obj); | 63 KlassHandle this_class(THREAD, obj); |
62 | 64 |
63 if (this_class->is_interface()) { | 65 if (this_class->is_interface()) { |
64 // We treat interfaces as java.lang.Object, including | 66 // We treat interfaces as java.lang.Object, including |
65 // java.lang.Cloneable and java.io.Serializable | 67 // java.lang.Cloneable and java.io.Serializable |
66 return true; | 68 return true; |
67 } else if (from.is_object()) { | 69 } else if (from.is_object()) { |
68 klassOop from_class = SystemDictionary::resolve_or_fail( | 70 klassOop from_class = SystemDictionary::resolve_or_fail( |
69 from.name_handle(), Handle(THREAD, context->class_loader()), | 71 from.name(), Handle(THREAD, klass->class_loader()), |
70 Handle(THREAD, context->protection_domain()), true, CHECK_false); | 72 Handle(THREAD, klass->protection_domain()), true, CHECK_false); |
71 return instanceKlass::cast(from_class)->is_subclass_of(this_class()); | 73 return instanceKlass::cast(from_class)->is_subclass_of(this_class()); |
72 } | 74 } |
73 } else if (is_array() && from.is_array()) { | 75 } else if (is_array() && from.is_array()) { |
74 VerificationType comp_this = get_component(CHECK_false); | 76 VerificationType comp_this = get_component(context, CHECK_false); |
75 VerificationType comp_from = from.get_component(CHECK_false); | 77 VerificationType comp_from = from.get_component(context, CHECK_false); |
76 if (!comp_this.is_bogus() && !comp_from.is_bogus()) { | 78 if (!comp_this.is_bogus() && !comp_from.is_bogus()) { |
77 return comp_this.is_assignable_from(comp_from, context, CHECK_false); | 79 return comp_this.is_assignable_from(comp_from, context, CHECK_false); |
78 } | 80 } |
79 } | 81 } |
80 return false; | 82 return false; |
81 } | 83 } |
82 | 84 |
83 VerificationType VerificationType::get_component(TRAPS) const { | 85 VerificationType VerificationType::get_component(ClassVerifier *context, TRAPS) const { |
84 assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array"); | 86 assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array"); |
85 symbolOop component; | 87 Symbol* component; |
86 switch (name()->byte_at(1)) { | 88 switch (name()->byte_at(1)) { |
87 case 'Z': return VerificationType(Boolean); | 89 case 'Z': return VerificationType(Boolean); |
88 case 'B': return VerificationType(Byte); | 90 case 'B': return VerificationType(Byte); |
89 case 'C': return VerificationType(Char); | 91 case 'C': return VerificationType(Char); |
90 case 'S': return VerificationType(Short); | 92 case 'S': return VerificationType(Short); |
91 case 'I': return VerificationType(Integer); | 93 case 'I': return VerificationType(Integer); |
92 case 'J': return VerificationType(Long); | 94 case 'J': return VerificationType(Long); |
93 case 'F': return VerificationType(Float); | 95 case 'F': return VerificationType(Float); |
94 case 'D': return VerificationType(Double); | 96 case 'D': return VerificationType(Double); |
95 case '[': | 97 case '[': |
96 component = SymbolTable::lookup( | 98 component = context->create_temporary_symbol( |
97 name(), 1, name()->utf8_length(), | 99 name(), 1, name()->utf8_length(), |
98 CHECK_(VerificationType::bogus_type())); | 100 CHECK_(VerificationType::bogus_type())); |
99 return VerificationType::reference_type(component); | 101 return VerificationType::reference_type(component); |
100 case 'L': | 102 case 'L': |
101 component = SymbolTable::lookup( | 103 component = context->create_temporary_symbol( |
102 name(), 2, name()->utf8_length() - 1, | 104 name(), 2, name()->utf8_length() - 1, |
103 CHECK_(VerificationType::bogus_type())); | 105 CHECK_(VerificationType::bogus_type())); |
104 return VerificationType::reference_type(component); | 106 return VerificationType::reference_type(component); |
105 default: | 107 default: |
106 // Met an invalid type signature, e.g. [X | 108 // Met an invalid type signature, e.g. [X |