Mercurial > hg > graal-compiler
annotate src/share/vm/classfile/verificationType.cpp @ 1662:e0ba4e04c839
6969574: invokedynamic call sites deoptimize instead of executing
Reviewed-by: kvn
author | jrose |
---|---|
date | Fri, 16 Jul 2010 18:14:19 -0700 |
parents | c18cbe5936b8 |
children | a5c9d63a187d |
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); | |
73 return comp_this.is_assignable_from(comp_from, context, CHECK_false); | |
74 } | |
75 return false; | |
76 } | |
77 | |
78 VerificationType VerificationType::get_component(TRAPS) const { | |
79 assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array"); | |
80 symbolOop component; | |
81 switch (name()->byte_at(1)) { | |
82 case 'Z': return VerificationType(Boolean); | |
83 case 'B': return VerificationType(Byte); | |
84 case 'C': return VerificationType(Char); | |
85 case 'S': return VerificationType(Short); | |
86 case 'I': return VerificationType(Integer); | |
87 case 'J': return VerificationType(Long); | |
88 case 'F': return VerificationType(Float); | |
89 case 'D': return VerificationType(Double); | |
90 case '[': | |
91 component = SymbolTable::lookup( | |
92 name(), 1, name()->utf8_length(), | |
93 CHECK_(VerificationType::bogus_type())); | |
94 return VerificationType::reference_type(component); | |
95 case 'L': | |
96 component = SymbolTable::lookup( | |
97 name(), 2, name()->utf8_length() - 1, | |
98 CHECK_(VerificationType::bogus_type())); | |
99 return VerificationType::reference_type(component); | |
100 default: | |
101 ShouldNotReachHere(); | |
102 return VerificationType::bogus_type(); | |
103 } | |
104 } | |
105 | |
106 #ifndef PRODUCT | |
107 | |
108 void VerificationType::print_on(outputStream* st) const { | |
109 switch (_u._data) { | |
110 case Bogus: st->print(" bogus "); break; | |
111 case Category1: st->print(" category1 "); break; | |
112 case Category2: st->print(" category2 "); break; | |
113 case Category2_2nd: st->print(" category2_2nd "); break; | |
114 case Boolean: st->print(" boolean "); break; | |
115 case Byte: st->print(" byte "); break; | |
116 case Short: st->print(" short "); break; | |
117 case Char: st->print(" char "); break; | |
118 case Integer: st->print(" integer "); break; | |
119 case Float: st->print(" float "); break; | |
120 case Long: st->print(" long "); break; | |
121 case Double: st->print(" double "); break; | |
122 case Long_2nd: st->print(" long_2nd "); break; | |
123 case Double_2nd: st->print(" double_2nd "); break; | |
124 case Null: st->print(" null "); break; | |
125 default: | |
126 if (is_uninitialized_this()) { | |
127 st->print(" uninitializedThis "); | |
128 } else if (is_uninitialized()) { | |
129 st->print(" uninitialized %d ", bci()); | |
130 } else { | |
131 st->print(" class %s ", name()->as_klass_external_name()); | |
132 } | |
133 } | |
134 } | |
135 | |
136 #endif |