Mercurial > hg > graal-compiler
annotate src/share/vm/classfile/verificationType.cpp @ 1755:8e5955ddf8e4
6978300: G1: debug builds crash if ParallelGCThreads==0
Reviewed-by: tonyp, ysr
author | jcoomes |
---|---|
date | Wed, 25 Aug 2010 14:39:55 -0700 |
parents | a5c9d63a187d |
children | 60f88489896f |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2003, 2006, 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 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_verificationType.cpp.incl" | |
27 | |
28 VerificationType VerificationType::from_tag(u1 tag) { | |
29 switch (tag) { | |
30 case ITEM_Top: return bogus_type(); | |
31 case ITEM_Integer: return integer_type(); | |
32 case ITEM_Float: return float_type(); | |
33 case ITEM_Double: return double_type(); | |
34 case ITEM_Long: return long_type(); | |
35 case ITEM_Null: return null_type(); | |
36 default: | |
37 ShouldNotReachHere(); | |
38 return bogus_type(); | |
39 } | |
40 } | |
41 | |
42 bool VerificationType::is_reference_assignable_from( | |
43 const VerificationType& from, instanceKlassHandle context, TRAPS) const { | |
44 if (from.is_null()) { | |
45 // null is assignable to any reference | |
46 return true; | |
47 } else if (is_null()) { | |
48 return false; | |
49 } else if (name() == from.name()) { | |
50 return true; | |
51 } else if (is_object()) { | |
52 // We need check the class hierarchy to check assignability | |
53 if (name() == vmSymbols::java_lang_Object()) { | |
54 // any object or array is assignable to java.lang.Object | |
55 return true; | |
56 } | |
57 klassOop this_class = SystemDictionary::resolve_or_fail( | |
58 name_handle(), Handle(THREAD, context->class_loader()), | |
59 Handle(THREAD, context->protection_domain()), true, CHECK_false); | |
60 if (this_class->klass_part()->is_interface()) { | |
61 // We treat interfaces as java.lang.Object, including | |
62 // java.lang.Cloneable and java.io.Serializable | |
63 return true; | |
64 } else if (from.is_object()) { | |
65 klassOop from_class = SystemDictionary::resolve_or_fail( | |
66 from.name_handle(), Handle(THREAD, context->class_loader()), | |
67 Handle(THREAD, context->protection_domain()), true, CHECK_false); | |
68 return instanceKlass::cast(from_class)->is_subclass_of(this_class); | |
69 } | |
70 } else if (is_array() && from.is_array()) { | |
71 VerificationType comp_this = get_component(CHECK_false); | |
72 VerificationType comp_from = from.get_component(CHECK_false); | |
1677 | 73 if (!comp_this.is_bogus() && !comp_from.is_bogus()) { |
74 return comp_this.is_assignable_from(comp_from, context, CHECK_false); | |
75 } | |
0 | 76 } |
77 return false; | |
78 } | |
79 | |
80 VerificationType VerificationType::get_component(TRAPS) const { | |
81 assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array"); | |
82 symbolOop component; | |
83 switch (name()->byte_at(1)) { | |
84 case 'Z': return VerificationType(Boolean); | |
85 case 'B': return VerificationType(Byte); | |
86 case 'C': return VerificationType(Char); | |
87 case 'S': return VerificationType(Short); | |
88 case 'I': return VerificationType(Integer); | |
89 case 'J': return VerificationType(Long); | |
90 case 'F': return VerificationType(Float); | |
91 case 'D': return VerificationType(Double); | |
92 case '[': | |
93 component = SymbolTable::lookup( | |
94 name(), 1, name()->utf8_length(), | |
95 CHECK_(VerificationType::bogus_type())); | |
96 return VerificationType::reference_type(component); | |
97 case 'L': | |
98 component = SymbolTable::lookup( | |
99 name(), 2, name()->utf8_length() - 1, | |
100 CHECK_(VerificationType::bogus_type())); | |
101 return VerificationType::reference_type(component); | |
102 default: | |
1677 | 103 // Met an invalid type signature, e.g. [X |
0 | 104 return VerificationType::bogus_type(); |
105 } | |
106 } | |
107 | |
108 #ifndef PRODUCT | |
109 | |
110 void VerificationType::print_on(outputStream* st) const { | |
111 switch (_u._data) { | |
112 case Bogus: st->print(" bogus "); break; | |
113 case Category1: st->print(" category1 "); break; | |
114 case Category2: st->print(" category2 "); break; | |
115 case Category2_2nd: st->print(" category2_2nd "); break; | |
116 case Boolean: st->print(" boolean "); break; | |
117 case Byte: st->print(" byte "); break; | |
118 case Short: st->print(" short "); break; | |
119 case Char: st->print(" char "); break; | |
120 case Integer: st->print(" integer "); break; | |
121 case Float: st->print(" float "); break; | |
122 case Long: st->print(" long "); break; | |
123 case Double: st->print(" double "); break; | |
124 case Long_2nd: st->print(" long_2nd "); break; | |
125 case Double_2nd: st->print(" double_2nd "); break; | |
126 case Null: st->print(" null "); break; | |
127 default: | |
128 if (is_uninitialized_this()) { | |
129 st->print(" uninitializedThis "); | |
130 } else if (is_uninitialized()) { | |
131 st->print(" uninitialized %d ", bci()); | |
132 } else { | |
133 st->print(" class %s ", name()->as_klass_external_name()); | |
134 } | |
135 } | |
136 } | |
137 | |
138 #endif |