Mercurial > hg > truffle
annotate src/share/vm/classfile/verificationType.cpp @ 13257:4eacfd0767ed
get deoptimization constants in HotSpotMetaAccessProvider from HotSpotVMConfig
author | twisti |
---|---|
date | Thu, 05 Dec 2013 19:28:30 -0800 |
parents | da91efe96a93 |
children | 2373a1f4987c |
rev | line source |
---|---|
0 | 1 /* |
6605 | 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
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 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/symbolTable.hpp" | |
27 #include "classfile/verificationType.hpp" | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
28 #include "classfile/verifier.hpp" |
0 | 29 |
30 VerificationType VerificationType::from_tag(u1 tag) { | |
31 switch (tag) { | |
32 case ITEM_Top: return bogus_type(); | |
33 case ITEM_Integer: return integer_type(); | |
34 case ITEM_Float: return float_type(); | |
35 case ITEM_Double: return double_type(); | |
36 case ITEM_Long: return long_type(); | |
37 case ITEM_Null: return null_type(); | |
38 default: | |
39 ShouldNotReachHere(); | |
40 return bogus_type(); | |
41 } | |
42 } | |
43 | |
44 bool VerificationType::is_reference_assignable_from( | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
45 const VerificationType& from, ClassVerifier* context, TRAPS) const { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
46 instanceKlassHandle klass = context->current_class(); |
0 | 47 if (from.is_null()) { |
48 // null is assignable to any reference | |
49 return true; | |
50 } else if (is_null()) { | |
51 return false; | |
52 } else if (name() == from.name()) { | |
53 return true; | |
54 } else if (is_object()) { | |
55 // We need check the class hierarchy to check assignability | |
56 if (name() == vmSymbols::java_lang_Object()) { | |
57 // any object or array is assignable to java.lang.Object | |
58 return true; | |
59 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6605
diff
changeset
|
60 Klass* obj = SystemDictionary::resolve_or_fail( |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
61 name(), Handle(THREAD, klass->class_loader()), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
62 Handle(THREAD, klass->protection_domain()), true, CHECK_false); |
1803 | 63 KlassHandle this_class(THREAD, obj); |
64 | |
65 if (this_class->is_interface()) { | |
0 | 66 // We treat interfaces as java.lang.Object, including |
67 // java.lang.Cloneable and java.io.Serializable | |
68 return true; | |
69 } else if (from.is_object()) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6605
diff
changeset
|
70 Klass* from_class = SystemDictionary::resolve_or_fail( |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
71 from.name(), Handle(THREAD, klass->class_loader()), |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
72 Handle(THREAD, klass->protection_domain()), true, CHECK_false); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6605
diff
changeset
|
73 return InstanceKlass::cast(from_class)->is_subclass_of(this_class()); |
0 | 74 } |
75 } else if (is_array() && from.is_array()) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
76 VerificationType comp_this = get_component(context, CHECK_false); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
77 VerificationType comp_from = from.get_component(context, CHECK_false); |
1677 | 78 if (!comp_this.is_bogus() && !comp_from.is_bogus()) { |
79 return comp_this.is_assignable_from(comp_from, context, CHECK_false); | |
80 } | |
0 | 81 } |
82 return false; | |
83 } | |
84 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
85 VerificationType VerificationType::get_component(ClassVerifier *context, TRAPS) const { |
0 | 86 assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array"); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
87 Symbol* component; |
0 | 88 switch (name()->byte_at(1)) { |
89 case 'Z': return VerificationType(Boolean); | |
90 case 'B': return VerificationType(Byte); | |
91 case 'C': return VerificationType(Char); | |
92 case 'S': return VerificationType(Short); | |
93 case 'I': return VerificationType(Integer); | |
94 case 'J': return VerificationType(Long); | |
95 case 'F': return VerificationType(Float); | |
96 case 'D': return VerificationType(Double); | |
97 case '[': | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
98 component = context->create_temporary_symbol( |
0 | 99 name(), 1, name()->utf8_length(), |
100 CHECK_(VerificationType::bogus_type())); | |
101 return VerificationType::reference_type(component); | |
102 case 'L': | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
103 component = context->create_temporary_symbol( |
0 | 104 name(), 2, name()->utf8_length() - 1, |
105 CHECK_(VerificationType::bogus_type())); | |
106 return VerificationType::reference_type(component); | |
107 default: | |
1677 | 108 // Met an invalid type signature, e.g. [X |
0 | 109 return VerificationType::bogus_type(); |
110 } | |
111 } | |
112 | |
113 void VerificationType::print_on(outputStream* st) const { | |
114 switch (_u._data) { | |
6605 | 115 case Bogus: st->print("top"); break; |
116 case Category1: st->print("category1"); break; | |
117 case Category2: st->print("category2"); break; | |
118 case Category2_2nd: st->print("category2_2nd"); break; | |
119 case Boolean: st->print("boolean"); break; | |
120 case Byte: st->print("byte"); break; | |
121 case Short: st->print("short"); break; | |
122 case Char: st->print("char"); break; | |
123 case Integer: st->print("integer"); break; | |
124 case Float: st->print("float"); break; | |
125 case Long: st->print("long"); break; | |
126 case Double: st->print("double"); break; | |
127 case Long_2nd: st->print("long_2nd"); break; | |
128 case Double_2nd: st->print("double_2nd"); break; | |
129 case Null: st->print("null"); break; | |
130 case ReferenceQuery: st->print("reference type"); break; | |
131 case Category1Query: st->print("category1 type"); break; | |
132 case Category2Query: st->print("category2 type"); break; | |
133 case Category2_2ndQuery: st->print("category2_2nd type"); break; | |
0 | 134 default: |
135 if (is_uninitialized_this()) { | |
6605 | 136 st->print("uninitializedThis"); |
0 | 137 } else if (is_uninitialized()) { |
6605 | 138 st->print("uninitialized %d", bci()); |
0 | 139 } else { |
6605 | 140 name()->print_value_on(st); |
0 | 141 } |
142 } | |
143 } |