Mercurial > hg > graal-jvmci-8
annotate src/share/vm/classfile/verifier.cpp @ 23974:f13e777eb255
Merge with jdk8u111-b14
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 16 Nov 2016 12:32:54 -0800 |
parents | dd9cc155639c e4525db27263 |
children | 9b69cec6d01b |
rev | line source |
---|---|
0 | 1 /* |
22847
ecdf1e03db40
8064335: Null pointer dereference in hotspot/src/share/vm/classfile/verifier.cpp
hseigel
parents:
20762
diff
changeset
|
2 * Copyright (c) 1998, 2015, 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:
1142
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1142
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:
1142
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "classfile/classFileStream.hpp" | |
27 #include "classfile/javaClasses.hpp" | |
28 #include "classfile/stackMapTable.hpp" | |
6605 | 29 #include "classfile/stackMapFrame.hpp" |
30 #include "classfile/stackMapTableFormat.hpp" | |
1972 | 31 #include "classfile/systemDictionary.hpp" |
32 #include "classfile/verifier.hpp" | |
33 #include "classfile/vmSymbols.hpp" | |
6605 | 34 #include "interpreter/bytecodes.hpp" |
1972 | 35 #include "interpreter/bytecodeStream.hpp" |
36 #include "memory/oopFactory.hpp" | |
37 #include "memory/resourceArea.hpp" | |
38 #include "oops/instanceKlass.hpp" | |
39 #include "oops/oop.inline.hpp" | |
40 #include "oops/typeArrayOop.hpp" | |
41 #include "prims/jvm.h" | |
42 #include "runtime/fieldDescriptor.hpp" | |
43 #include "runtime/handles.inline.hpp" | |
44 #include "runtime/interfaceSupport.hpp" | |
45 #include "runtime/javaCalls.hpp" | |
20197
ce8f6bb717c9
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
17937
diff
changeset
|
46 #include "runtime/orderAccess.inline.hpp" |
1972 | 47 #include "runtime/os.hpp" |
48 #ifdef TARGET_ARCH_x86 | |
49 # include "bytes_x86.hpp" | |
50 #endif | |
51 #ifdef TARGET_ARCH_sparc | |
52 # include "bytes_sparc.hpp" | |
53 #endif | |
54 #ifdef TARGET_ARCH_zero | |
55 # include "bytes_zero.hpp" | |
56 #endif | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
57 #ifdef TARGET_ARCH_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
58 # include "bytes_arm.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
59 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
60 #ifdef TARGET_ARCH_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
61 # include "bytes_ppc.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
2177
diff
changeset
|
62 #endif |
0 | 63 |
8816
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
64 #define NOFAILOVER_MAJOR_VERSION 51 |
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
65 #define NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION 51 |
9066
09b0d3e9ba6c
8011671: JCK tests on static interface methods fail under b84: Illegal type at constant pool entry 5
bharadwaj
parents:
8819
diff
changeset
|
66 #define STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION 52 |
1560
e40a3601bc1f
6911922: JVM must throw VerifyError for jsr or jsr_w opcodes in class file v.51+
kamg
parents:
1142
diff
changeset
|
67 |
0 | 68 // Access to external entry for VerifyClassCodes - old byte code verifier |
69 | |
70 extern "C" { | |
71 typedef jboolean (*verify_byte_codes_fn_t)(JNIEnv *, jclass, char *, jint); | |
72 typedef jboolean (*verify_byte_codes_fn_new_t)(JNIEnv *, jclass, char *, jint, jint); | |
73 } | |
74 | |
75 static void* volatile _verify_byte_codes_fn = NULL; | |
76 | |
77 static volatile jint _is_new_verify_byte_codes_fn = (jint) true; | |
78 | |
79 static void* verify_byte_codes_fn() { | |
80 if (_verify_byte_codes_fn == NULL) { | |
81 void *lib_handle = os::native_java_library(); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
82 void *func = os::dll_lookup(lib_handle, "VerifyClassCodesForMajorVersion"); |
0 | 83 OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func); |
84 if (func == NULL) { | |
85 OrderAccess::release_store(&_is_new_verify_byte_codes_fn, false); | |
1980
828eafbd85cc
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
1972
diff
changeset
|
86 func = os::dll_lookup(lib_handle, "VerifyClassCodes"); |
0 | 87 OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func); |
88 } | |
89 } | |
90 return (void*)_verify_byte_codes_fn; | |
91 } | |
92 | |
93 | |
94 // Methods in Verifier | |
95 | |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
844
diff
changeset
|
96 bool Verifier::should_verify_for(oop class_loader, bool should_verify_class) { |
21559
be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
20804
diff
changeset
|
97 return (class_loader == NULL JVMCI_ONLY(|| class_loader == SystemDictionary::jvmci_loader()) || !should_verify_class) ? |
0 | 98 BytecodeVerificationLocal : BytecodeVerificationRemote; |
99 } | |
100 | |
101 bool Verifier::relax_verify_for(oop loader) { | |
102 bool trusted = java_lang_ClassLoader::is_trusted_loader(loader); | |
103 bool need_verify = | |
104 // verifyAll | |
105 (BytecodeVerificationLocal && BytecodeVerificationRemote) || | |
106 // verifyRemote | |
107 (!BytecodeVerificationLocal && BytecodeVerificationRemote && !trusted); | |
108 return !need_verify; | |
109 } | |
110 | |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
844
diff
changeset
|
111 bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool should_verify_class, TRAPS) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
112 HandleMark hm; |
0 | 113 ResourceMark rm(THREAD); |
114 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
115 Symbol* exception_name = NULL; |
0 | 116 const size_t message_buffer_len = klass->name()->utf8_length() + 1024; |
117 char* message_buffer = NEW_RESOURCE_ARRAY(char, message_buffer_len); | |
6605 | 118 char* exception_message = message_buffer; |
0 | 119 |
120 const char* klassName = klass->external_name(); | |
6605 | 121 bool can_failover = FailOverToOldVerifier && |
122 klass->major_version() < NOFAILOVER_MAJOR_VERSION; | |
0 | 123 |
124 // If the class should be verified, first see if we can use the split | |
125 // verifier. If not, or if verification fails and FailOverToOldVerifier | |
126 // is set, then call the inference verifier. | |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
844
diff
changeset
|
127 if (is_eligible_for_verification(klass, should_verify_class)) { |
0 | 128 if (TraceClassInitialization) { |
129 tty->print_cr("Start class verification for: %s", klassName); | |
130 } | |
8819
36376b540a98
8009595: The UseSplitVerifier option needs to be deprecated.
hseigel
parents:
8817
diff
changeset
|
131 if (klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) { |
6605 | 132 ClassVerifier split_verifier(klass, THREAD); |
133 split_verifier.verify_class(THREAD); | |
134 exception_name = split_verifier.result(); | |
135 if (can_failover && !HAS_PENDING_EXCEPTION && | |
0 | 136 (exception_name == vmSymbols::java_lang_VerifyError() || |
137 exception_name == vmSymbols::java_lang_ClassFormatError())) { | |
6605 | 138 if (TraceClassInitialization || VerboseVerification) { |
0 | 139 tty->print_cr( |
140 "Fail over class verification to old verifier for: %s", klassName); | |
141 } | |
142 exception_name = inference_verify( | |
143 klass, message_buffer, message_buffer_len, THREAD); | |
144 } | |
6605 | 145 if (exception_name != NULL) { |
146 exception_message = split_verifier.exception_message(); | |
147 } | |
0 | 148 } else { |
149 exception_name = inference_verify( | |
150 klass, message_buffer, message_buffer_len, THREAD); | |
151 } | |
152 | |
6605 | 153 if (TraceClassInitialization || VerboseVerification) { |
0 | 154 if (HAS_PENDING_EXCEPTION) { |
155 tty->print("Verification for %s has", klassName); | |
156 tty->print_cr(" exception pending %s ", | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
157 InstanceKlass::cast(PENDING_EXCEPTION->klass())->external_name()); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
158 } else if (exception_name != NULL) { |
0 | 159 tty->print_cr("Verification for %s failed", klassName); |
160 } | |
161 tty->print_cr("End class verification for: %s", klassName); | |
162 } | |
163 } | |
164 | |
165 if (HAS_PENDING_EXCEPTION) { | |
166 return false; // use the existing exception | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
167 } else if (exception_name == NULL) { |
0 | 168 return true; // verifcation succeeded |
169 } else { // VerifyError or ClassFormatError to be created and thrown | |
170 ResourceMark rm(THREAD); | |
171 instanceKlassHandle kls = | |
172 SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false); | |
173 while (!kls.is_null()) { | |
174 if (kls == klass) { | |
175 // If the class being verified is the exception we're creating | |
176 // or one of it's superclasses, we're in trouble and are going | |
177 // to infinitely recurse when we try to initialize the exception. | |
178 // So bail out here by throwing the preallocated VM error. | |
179 THROW_OOP_(Universe::virtual_machine_error_instance(), false); | |
180 } | |
181 kls = kls->super(); | |
182 } | |
183 message_buffer[message_buffer_len - 1] = '\0'; // just to be sure | |
6605 | 184 THROW_MSG_(exception_name, exception_message, false); |
0 | 185 } |
186 } | |
187 | |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
844
diff
changeset
|
188 bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
189 Symbol* name = klass->name(); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
190 Klass* refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass(); |
12154
3a1df0dce3e5
8023872: Verification error in generated lambda classes
acorn
parents:
12142
diff
changeset
|
191 |
3a1df0dce3e5
8023872: Verification error in generated lambda classes
acorn
parents:
12142
diff
changeset
|
192 bool is_reflect = refl_magic_klass != NULL && klass->is_subtype_of(refl_magic_klass); |
0 | 193 |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
844
diff
changeset
|
194 return (should_verify_for(klass->class_loader(), should_verify_class) && |
0 | 195 // return if the class is a bootstrapping class |
973
ad6585fd4087
6830542: Performance: JVM_DefineClass already verified.
acorn
parents:
844
diff
changeset
|
196 // or defineClass specified not to verify by default (flags override passed arg) |
0 | 197 // We need to skip the following four for bootstraping |
198 name != vmSymbols::java_lang_Object() && | |
199 name != vmSymbols::java_lang_Class() && | |
200 name != vmSymbols::java_lang_String() && | |
201 name != vmSymbols::java_lang_Throwable() && | |
202 | |
203 // Can not verify the bytecodes for shared classes because they have | |
204 // already been rewritten to contain constant pool cache indices, | |
205 // which the verifier can't understand. | |
206 // Shared classes shouldn't have stackmaps either. | |
207 !klass()->is_shared() && | |
208 | |
209 // As of the fix for 4486457 we disable verification for all of the | |
210 // dynamically-generated bytecodes associated with the 1.4 | |
211 // reflection implementation, not just those associated with | |
212 // sun/reflect/SerializationConstructorAccessor. | |
213 // NOTE: this is called too early in the bootstrapping process to be | |
214 // guarded by Universe::is_gte_jdk14x_version()/UseNewReflection. | |
12154
3a1df0dce3e5
8023872: Verification error in generated lambda classes
acorn
parents:
12142
diff
changeset
|
215 // Also for lambda generated code, gte jdk8 |
13385
cdf20166ec45
8025632: Remove all references to MagicLambdaImpl from Hotspot
minqi
parents:
12891
diff
changeset
|
216 (!is_reflect || VerifyReflectionBytecodes)); |
0 | 217 } |
218 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
219 Symbol* Verifier::inference_verify( |
0 | 220 instanceKlassHandle klass, char* message, size_t message_len, TRAPS) { |
221 JavaThread* thread = (JavaThread*)THREAD; | |
222 JNIEnv *env = thread->jni_environment(); | |
223 | |
224 void* verify_func = verify_byte_codes_fn(); | |
225 | |
226 if (verify_func == NULL) { | |
227 jio_snprintf(message, message_len, "Could not link verifier"); | |
228 return vmSymbols::java_lang_VerifyError(); | |
229 } | |
230 | |
231 ResourceMark rm(THREAD); | |
6605 | 232 if (VerboseVerification) { |
0 | 233 tty->print_cr("Verifying class %s with old format", klass->external_name()); |
234 } | |
235 | |
236 jclass cls = (jclass) JNIHandles::make_local(env, klass->java_mirror()); | |
237 jint result; | |
238 | |
239 { | |
240 HandleMark hm(thread); | |
241 ThreadToNativeFromVM ttn(thread); | |
242 // ThreadToNativeFromVM takes care of changing thread_state, so safepoint | |
243 // code knows that we have left the VM | |
244 | |
245 if (_is_new_verify_byte_codes_fn) { | |
246 verify_byte_codes_fn_new_t func = | |
247 CAST_TO_FN_PTR(verify_byte_codes_fn_new_t, verify_func); | |
248 result = (*func)(env, cls, message, (int)message_len, | |
249 klass->major_version()); | |
250 } else { | |
251 verify_byte_codes_fn_t func = | |
252 CAST_TO_FN_PTR(verify_byte_codes_fn_t, verify_func); | |
253 result = (*func)(env, cls, message, (int)message_len); | |
254 } | |
255 } | |
256 | |
257 JNIHandles::destroy_local(cls); | |
258 | |
259 // These numbers are chosen so that VerifyClassCodes interface doesn't need | |
260 // to be changed (still return jboolean (unsigned char)), and result is | |
261 // 1 when verification is passed. | |
262 if (result == 0) { | |
263 return vmSymbols::java_lang_VerifyError(); | |
264 } else if (result == 1) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
265 return NULL; // verified. |
0 | 266 } else if (result == 2) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
267 THROW_MSG_(vmSymbols::java_lang_OutOfMemoryError(), message, NULL); |
0 | 268 } else if (result == 3) { |
269 return vmSymbols::java_lang_ClassFormatError(); | |
270 } else { | |
271 ShouldNotReachHere(); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
272 return NULL; |
0 | 273 } |
274 } | |
275 | |
6605 | 276 TypeOrigin TypeOrigin::null() { |
277 return TypeOrigin(); | |
278 } | |
279 TypeOrigin TypeOrigin::local(u2 index, StackMapFrame* frame) { | |
280 assert(frame != NULL, "Must have a frame"); | |
281 return TypeOrigin(CF_LOCALS, index, StackMapFrame::copy(frame), | |
282 frame->local_at(index)); | |
283 } | |
284 TypeOrigin TypeOrigin::stack(u2 index, StackMapFrame* frame) { | |
285 assert(frame != NULL, "Must have a frame"); | |
286 return TypeOrigin(CF_STACK, index, StackMapFrame::copy(frame), | |
287 frame->stack_at(index)); | |
288 } | |
289 TypeOrigin TypeOrigin::sm_local(u2 index, StackMapFrame* frame) { | |
290 assert(frame != NULL, "Must have a frame"); | |
291 return TypeOrigin(SM_LOCALS, index, StackMapFrame::copy(frame), | |
292 frame->local_at(index)); | |
293 } | |
294 TypeOrigin TypeOrigin::sm_stack(u2 index, StackMapFrame* frame) { | |
295 assert(frame != NULL, "Must have a frame"); | |
296 return TypeOrigin(SM_STACK, index, StackMapFrame::copy(frame), | |
297 frame->stack_at(index)); | |
298 } | |
299 TypeOrigin TypeOrigin::bad_index(u2 index) { | |
300 return TypeOrigin(BAD_INDEX, index, NULL, VerificationType::bogus_type()); | |
301 } | |
302 TypeOrigin TypeOrigin::cp(u2 index, VerificationType vt) { | |
303 return TypeOrigin(CONST_POOL, index, NULL, vt); | |
304 } | |
305 TypeOrigin TypeOrigin::signature(VerificationType vt) { | |
306 return TypeOrigin(SIG, 0, NULL, vt); | |
307 } | |
308 TypeOrigin TypeOrigin::implicit(VerificationType t) { | |
309 return TypeOrigin(IMPLICIT, 0, NULL, t); | |
310 } | |
311 TypeOrigin TypeOrigin::frame(StackMapFrame* frame) { | |
312 return TypeOrigin(FRAME_ONLY, 0, StackMapFrame::copy(frame), | |
313 VerificationType::bogus_type()); | |
314 } | |
315 | |
316 void TypeOrigin::reset_frame() { | |
317 if (_frame != NULL) { | |
318 _frame->restore(); | |
319 } | |
320 } | |
321 | |
322 void TypeOrigin::details(outputStream* ss) const { | |
323 _type.print_on(ss); | |
324 switch (_origin) { | |
325 case CF_LOCALS: | |
326 ss->print(" (current frame, locals[%d])", _index); | |
327 break; | |
328 case CF_STACK: | |
329 ss->print(" (current frame, stack[%d])", _index); | |
330 break; | |
331 case SM_LOCALS: | |
332 ss->print(" (stack map, locals[%d])", _index); | |
333 break; | |
334 case SM_STACK: | |
335 ss->print(" (stack map, stack[%d])", _index); | |
336 break; | |
337 case CONST_POOL: | |
338 ss->print(" (constant pool %d)", _index); | |
339 break; | |
340 case SIG: | |
341 ss->print(" (from method signature)"); | |
342 break; | |
343 case IMPLICIT: | |
344 case FRAME_ONLY: | |
345 case NONE: | |
346 default: | |
347 ; | |
348 } | |
349 } | |
350 | |
351 #ifdef ASSERT | |
352 void TypeOrigin::print_on(outputStream* str) const { | |
353 str->print("{%d,%d,%p:", _origin, _index, _frame); | |
354 if (_frame != NULL) { | |
355 _frame->print_on(str); | |
356 } else { | |
357 str->print("null"); | |
358 } | |
359 str->print(","); | |
360 _type.print_on(str); | |
361 str->print("}"); | |
362 } | |
363 #endif | |
364 | |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
9066
diff
changeset
|
365 void ErrorContext::details(outputStream* ss, const Method* method) const { |
6605 | 366 if (is_valid()) { |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
367 ss->cr(); |
6605 | 368 ss->print_cr("Exception Details:"); |
369 location_details(ss, method); | |
370 reason_details(ss); | |
371 frame_details(ss); | |
372 bytecode_details(ss, method); | |
373 handler_details(ss, method); | |
374 stackmap_details(ss, method); | |
375 } | |
376 } | |
377 | |
378 void ErrorContext::reason_details(outputStream* ss) const { | |
379 streamIndentor si(ss); | |
380 ss->indent().print_cr("Reason:"); | |
381 streamIndentor si2(ss); | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
382 ss->indent().print("%s", ""); |
6605 | 383 switch (_fault) { |
384 case INVALID_BYTECODE: | |
385 ss->print("Error exists in the bytecode"); | |
386 break; | |
387 case WRONG_TYPE: | |
388 if (_expected.is_valid()) { | |
389 ss->print("Type "); | |
390 _type.details(ss); | |
391 ss->print(" is not assignable to "); | |
392 _expected.details(ss); | |
393 } else { | |
394 ss->print("Invalid type: "); | |
395 _type.details(ss); | |
396 } | |
397 break; | |
398 case FLAGS_MISMATCH: | |
399 if (_expected.is_valid()) { | |
400 ss->print("Current frame's flags are not assignable " | |
401 "to stack map frame's."); | |
402 } else { | |
403 ss->print("Current frame's flags are invalid in this context."); | |
404 } | |
405 break; | |
406 case BAD_CP_INDEX: | |
407 ss->print("Constant pool index %d is invalid", _type.index()); | |
408 break; | |
409 case BAD_LOCAL_INDEX: | |
410 ss->print("Local index %d is invalid", _type.index()); | |
411 break; | |
412 case LOCALS_SIZE_MISMATCH: | |
413 ss->print("Current frame's local size doesn't match stackmap."); | |
414 break; | |
415 case STACK_SIZE_MISMATCH: | |
416 ss->print("Current frame's stack size doesn't match stackmap."); | |
417 break; | |
418 case STACK_OVERFLOW: | |
419 ss->print("Exceeded max stack size."); | |
420 break; | |
421 case STACK_UNDERFLOW: | |
422 ss->print("Attempt to pop empty stack."); | |
423 break; | |
424 case MISSING_STACKMAP: | |
425 ss->print("Expected stackmap frame at this location."); | |
426 break; | |
427 case BAD_STACKMAP: | |
428 ss->print("Invalid stackmap specification."); | |
429 break; | |
430 case UNKNOWN: | |
431 default: | |
432 ShouldNotReachHere(); | |
433 ss->print_cr("Unknown"); | |
434 } | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
435 ss->cr(); |
6605 | 436 } |
437 | |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
9066
diff
changeset
|
438 void ErrorContext::location_details(outputStream* ss, const Method* method) const { |
6605 | 439 if (_bci != -1 && method != NULL) { |
440 streamIndentor si(ss); | |
441 const char* bytecode_name = "<invalid>"; | |
442 if (method->validate_bci_from_bcx(_bci) != -1) { | |
443 Bytecodes::Code code = Bytecodes::code_or_bp_at(method->bcp_from(_bci)); | |
444 if (Bytecodes::is_defined(code)) { | |
445 bytecode_name = Bytecodes::name(code); | |
446 } else { | |
447 bytecode_name = "<illegal>"; | |
448 } | |
449 } | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6934
diff
changeset
|
450 InstanceKlass* ik = method->method_holder(); |
6605 | 451 ss->indent().print_cr("Location:"); |
452 streamIndentor si2(ss); | |
453 ss->indent().print_cr("%s.%s%s @%d: %s", | |
454 ik->name()->as_C_string(), method->name()->as_C_string(), | |
455 method->signature()->as_C_string(), _bci, bytecode_name); | |
456 } | |
457 } | |
458 | |
459 void ErrorContext::frame_details(outputStream* ss) const { | |
460 streamIndentor si(ss); | |
461 if (_type.is_valid() && _type.frame() != NULL) { | |
462 ss->indent().print_cr("Current Frame:"); | |
463 streamIndentor si2(ss); | |
464 _type.frame()->print_on(ss); | |
465 } | |
466 if (_expected.is_valid() && _expected.frame() != NULL) { | |
467 ss->indent().print_cr("Stackmap Frame:"); | |
468 streamIndentor si2(ss); | |
469 _expected.frame()->print_on(ss); | |
470 } | |
471 } | |
472 | |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
9066
diff
changeset
|
473 void ErrorContext::bytecode_details(outputStream* ss, const Method* method) const { |
6605 | 474 if (method != NULL) { |
475 streamIndentor si(ss); | |
476 ss->indent().print_cr("Bytecode:"); | |
477 streamIndentor si2(ss); | |
478 ss->print_data(method->code_base(), method->code_size(), false); | |
479 } | |
480 } | |
481 | |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
9066
diff
changeset
|
482 void ErrorContext::handler_details(outputStream* ss, const Method* method) const { |
6605 | 483 if (method != NULL) { |
484 streamIndentor si(ss); | |
485 ExceptionTable table(method); | |
486 if (table.length() > 0) { | |
487 ss->indent().print_cr("Exception Handler Table:"); | |
488 streamIndentor si2(ss); | |
489 for (int i = 0; i < table.length(); ++i) { | |
490 ss->indent().print_cr("bci [%d, %d] => handler: %d", table.start_pc(i), | |
491 table.end_pc(i), table.handler_pc(i)); | |
492 } | |
493 } | |
494 } | |
495 } | |
496 | |
10265
92ef81e2f571
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
9066
diff
changeset
|
497 void ErrorContext::stackmap_details(outputStream* ss, const Method* method) const { |
6605 | 498 if (method != NULL && method->has_stackmap_table()) { |
499 streamIndentor si(ss); | |
500 ss->indent().print_cr("Stackmap Table:"); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
501 Array<u1>* data = method->stackmap_data(); |
6605 | 502 stack_map_table* sm_table = |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
503 stack_map_table::at((address)data->adr_at(0)); |
6605 | 504 stack_map_frame* sm_frame = sm_table->entries(); |
505 streamIndentor si2(ss); | |
506 int current_offset = -1; | |
23962 | 507 // Subtract two from StackMapAttribute length because the length includes |
508 // two bytes for number of table entries. | |
509 size_t sm_table_space = method->stackmap_data()->length() - 2; | |
6605 | 510 for (u2 i = 0; i < sm_table->number_of_entries(); ++i) { |
511 ss->indent(); | |
23962 | 512 size_t sm_frame_size = sm_frame->size(); |
513 // If the size of the next stackmap exceeds the length of the entire | |
514 // stackmap table then print a truncated message and return. | |
515 if (sm_frame_size > sm_table_space) { | |
516 sm_frame->print_truncated(ss, current_offset); | |
517 return; | |
518 } | |
519 sm_table_space -= sm_frame_size; | |
6605 | 520 sm_frame->print_on(ss, current_offset); |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
521 ss->cr(); |
6605 | 522 current_offset += sm_frame->offset_delta(); |
523 sm_frame = sm_frame->next(); | |
524 } | |
525 } | |
526 } | |
527 | |
0 | 528 // Methods in ClassVerifier |
529 | |
530 ClassVerifier::ClassVerifier( | |
6605 | 531 instanceKlassHandle klass, TRAPS) |
532 : _thread(THREAD), _exception_type(NULL), _message(NULL), _klass(klass) { | |
0 | 533 _this_type = VerificationType::reference_type(klass->name()); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
534 // Create list to hold symbols in reference area. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
535 _symbols = new GrowableArray<Symbol*>(100, 0, NULL); |
0 | 536 } |
537 | |
538 ClassVerifier::~ClassVerifier() { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
539 // Decrement the reference count for any symbols created. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
540 for (int i = 0; i < _symbols->length(); i++) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
541 Symbol* s = _symbols->at(i); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
542 s->decrement_refcount(); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
543 } |
0 | 544 } |
545 | |
1955
1070423b51f3
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
1678
diff
changeset
|
546 VerificationType ClassVerifier::object_type() const { |
1070423b51f3
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
1678
diff
changeset
|
547 return VerificationType::reference_type(vmSymbols::java_lang_Object()); |
1070423b51f3
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
1678
diff
changeset
|
548 } |
1070423b51f3
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
1678
diff
changeset
|
549 |
6605 | 550 TypeOrigin ClassVerifier::ref_ctx(const char* sig, TRAPS) { |
551 VerificationType vt = VerificationType::reference_type( | |
552 create_temporary_symbol(sig, (int)strlen(sig), THREAD)); | |
553 return TypeOrigin::implicit(vt); | |
554 } | |
555 | |
0 | 556 void ClassVerifier::verify_class(TRAPS) { |
6605 | 557 if (VerboseVerification) { |
0 | 558 tty->print_cr("Verifying class %s with new format", |
559 _klass->external_name()); | |
560 } | |
561 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
562 Array<Method*>* methods = _klass->methods(); |
0 | 563 int num_methods = methods->length(); |
564 | |
565 for (int index = 0; index < num_methods; index++) { | |
1570 | 566 // Check for recursive re-verification before each method. |
567 if (was_recursively_verified()) return; | |
568 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
569 Method* m = methods->at(index); |
6934 | 570 if (m->is_native() || m->is_abstract() || m->is_overpass()) { |
0 | 571 // If m is native or abstract, skip it. It is checked in class file |
6934 | 572 // parser that methods do not override a final method. Overpass methods |
573 // are trusted since the VM generates them. | |
0 | 574 continue; |
575 } | |
576 verify_method(methodHandle(THREAD, m), CHECK_VERIFY(this)); | |
577 } | |
1570 | 578 |
6605 | 579 if (VerboseVerification || TraceClassInitialization) { |
1570 | 580 if (was_recursively_verified()) |
581 tty->print_cr("Recursive verification detected for: %s", | |
582 _klass->external_name()); | |
583 } | |
0 | 584 } |
585 | |
586 void ClassVerifier::verify_method(methodHandle m, TRAPS) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
587 HandleMark hm(THREAD); |
0 | 588 _method = m; // initialize _method |
6605 | 589 if (VerboseVerification) { |
0 | 590 tty->print_cr("Verifying method %s", m->name_and_sig_as_C_string()); |
591 } | |
592 | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
593 // For clang, the only good constant format string is a literal constant format string. |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
594 #define bad_type_msg "Bad type on operand stack in %s" |
0 | 595 |
6271
93c71eb28866
7188911: nightly failures after JSR 292 lazy method handle update (round 2)
twisti
parents:
6214
diff
changeset
|
596 int32_t max_stack = m->verifier_max_stack(); |
0 | 597 int32_t max_locals = m->max_locals(); |
598 constantPoolHandle cp(THREAD, m->constants()); | |
599 | |
600 if (!SignatureVerifier::is_valid_method_signature(m->signature())) { | |
601 class_format_error("Invalid method signature"); | |
602 return; | |
603 } | |
604 | |
605 // Initial stack map frame: offset is 0, stack is initially empty. | |
606 StackMapFrame current_frame(max_locals, max_stack, this); | |
607 // Set initial locals | |
608 VerificationType return_type = current_frame.set_locals_from_arg( | |
609 m, current_type(), CHECK_VERIFY(this)); | |
610 | |
611 int32_t stackmap_index = 0; // index to the stackmap array | |
612 | |
613 u4 code_length = m->code_size(); | |
614 | |
615 // Scan the bytecode and map each instruction's start offset to a number. | |
616 char* code_data = generate_code_data(m, code_length, CHECK_VERIFY(this)); | |
617 | |
618 int ex_min = code_length; | |
619 int ex_max = -1; | |
620 // Look through each item on the exception table. Each of the fields must refer | |
621 // to a legal instruction. | |
622 verify_exception_handler_table( | |
623 code_length, code_data, ex_min, ex_max, CHECK_VERIFY(this)); | |
624 | |
625 // Look through each entry on the local variable table and make sure | |
626 // its range of code array offsets is valid. (4169817) | |
627 if (m->has_localvariable_table()) { | |
628 verify_local_variable_table(code_length, code_data, CHECK_VERIFY(this)); | |
629 } | |
630 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
631 Array<u1>* stackmap_data = m->stackmap_data(); |
0 | 632 StackMapStream stream(stackmap_data); |
633 StackMapReader reader(this, &stream, code_data, code_length, THREAD); | |
634 StackMapTable stackmap_table(&reader, ¤t_frame, max_locals, max_stack, | |
635 code_data, code_length, CHECK_VERIFY(this)); | |
636 | |
6605 | 637 if (VerboseVerification) { |
638 stackmap_table.print_on(tty); | |
0 | 639 } |
640 | |
641 RawBytecodeStream bcs(m); | |
642 | |
643 // Scan the byte code linearly from the start to the end | |
644 bool no_control_flow = false; // Set to true when there is no direct control | |
645 // flow from current instruction to the next | |
646 // instruction in sequence | |
17573 | 647 |
0 | 648 Bytecodes::Code opcode; |
649 while (!bcs.is_last_bytecode()) { | |
1570 | 650 // Check for recursive re-verification before each bytecode. |
651 if (was_recursively_verified()) return; | |
652 | |
0 | 653 opcode = bcs.raw_next(); |
654 u2 bci = bcs.bci(); | |
655 | |
656 // Set current frame's offset to bci | |
657 current_frame.set_offset(bci); | |
6605 | 658 current_frame.set_mark(); |
0 | 659 |
660 // Make sure every offset in stackmap table point to the beginning to | |
661 // an instruction. Match current_frame to stackmap_table entry with | |
662 // the same offset if exists. | |
663 stackmap_index = verify_stackmap_table( | |
664 stackmap_index, bci, ¤t_frame, &stackmap_table, | |
665 no_control_flow, CHECK_VERIFY(this)); | |
666 | |
6605 | 667 |
0 | 668 bool this_uninit = false; // Set to true when invokespecial <init> initialized 'this' |
22916
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
669 bool verified_exc_handlers = false; |
0 | 670 |
671 // Merge with the next instruction | |
672 { | |
673 u2 index; | |
674 int target; | |
675 VerificationType type, type2; | |
676 VerificationType atype; | |
677 | |
678 #ifndef PRODUCT | |
6605 | 679 if (VerboseVerification) { |
680 current_frame.print_on(tty); | |
0 | 681 tty->print_cr("offset = %d, opcode = %s", bci, Bytecodes::name(opcode)); |
682 } | |
683 #endif | |
684 | |
685 // Make sure wide instruction is in correct format | |
686 if (bcs.is_wide()) { | |
687 if (opcode != Bytecodes::_iinc && opcode != Bytecodes::_iload && | |
688 opcode != Bytecodes::_aload && opcode != Bytecodes::_lload && | |
689 opcode != Bytecodes::_istore && opcode != Bytecodes::_astore && | |
690 opcode != Bytecodes::_lstore && opcode != Bytecodes::_fload && | |
691 opcode != Bytecodes::_dload && opcode != Bytecodes::_fstore && | |
692 opcode != Bytecodes::_dstore) { | |
6605 | 693 /* Unreachable? RawBytecodeStream's raw_next() returns 'illegal' |
694 * if we encounter a wide instruction that modifies an invalid | |
695 * opcode (not one of the ones listed above) */ | |
696 verify_error(ErrorContext::bad_code(bci), "Bad wide instruction"); | |
0 | 697 return; |
698 } | |
699 } | |
700 | |
22916
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
701 // Look for possible jump target in exception handlers and see if it |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
702 // matches current_frame. Do this check here for astore*, dstore*, |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
703 // fstore*, istore*, and lstore* opcodes because they can change the type |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
704 // state by adding a local. JVM Spec says that the incoming type state |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
705 // should be used for this check. So, do the check here before a possible |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
706 // local is added to the type state. |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
707 if (Bytecodes::is_store_into_local(opcode) && bci >= ex_min && bci < ex_max) { |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
708 verify_exception_handler_targets( |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
709 bci, this_uninit, ¤t_frame, &stackmap_table, CHECK_VERIFY(this)); |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
710 verified_exc_handlers = true; |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
711 } |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
712 |
0 | 713 switch (opcode) { |
714 case Bytecodes::_nop : | |
715 no_control_flow = false; break; | |
716 case Bytecodes::_aconst_null : | |
717 current_frame.push_stack( | |
718 VerificationType::null_type(), CHECK_VERIFY(this)); | |
719 no_control_flow = false; break; | |
720 case Bytecodes::_iconst_m1 : | |
721 case Bytecodes::_iconst_0 : | |
722 case Bytecodes::_iconst_1 : | |
723 case Bytecodes::_iconst_2 : | |
724 case Bytecodes::_iconst_3 : | |
725 case Bytecodes::_iconst_4 : | |
726 case Bytecodes::_iconst_5 : | |
727 current_frame.push_stack( | |
728 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
729 no_control_flow = false; break; | |
730 case Bytecodes::_lconst_0 : | |
731 case Bytecodes::_lconst_1 : | |
732 current_frame.push_stack_2( | |
733 VerificationType::long_type(), | |
734 VerificationType::long2_type(), CHECK_VERIFY(this)); | |
735 no_control_flow = false; break; | |
736 case Bytecodes::_fconst_0 : | |
737 case Bytecodes::_fconst_1 : | |
738 case Bytecodes::_fconst_2 : | |
739 current_frame.push_stack( | |
740 VerificationType::float_type(), CHECK_VERIFY(this)); | |
741 no_control_flow = false; break; | |
742 case Bytecodes::_dconst_0 : | |
743 case Bytecodes::_dconst_1 : | |
744 current_frame.push_stack_2( | |
745 VerificationType::double_type(), | |
746 VerificationType::double2_type(), CHECK_VERIFY(this)); | |
747 no_control_flow = false; break; | |
748 case Bytecodes::_sipush : | |
749 case Bytecodes::_bipush : | |
750 current_frame.push_stack( | |
751 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
752 no_control_flow = false; break; | |
753 case Bytecodes::_ldc : | |
754 verify_ldc( | |
1565 | 755 opcode, bcs.get_index_u1(), ¤t_frame, |
0 | 756 cp, bci, CHECK_VERIFY(this)); |
757 no_control_flow = false; break; | |
758 case Bytecodes::_ldc_w : | |
759 case Bytecodes::_ldc2_w : | |
760 verify_ldc( | |
1565 | 761 opcode, bcs.get_index_u2(), ¤t_frame, |
0 | 762 cp, bci, CHECK_VERIFY(this)); |
763 no_control_flow = false; break; | |
764 case Bytecodes::_iload : | |
765 verify_iload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); | |
766 no_control_flow = false; break; | |
767 case Bytecodes::_iload_0 : | |
768 case Bytecodes::_iload_1 : | |
769 case Bytecodes::_iload_2 : | |
770 case Bytecodes::_iload_3 : | |
771 index = opcode - Bytecodes::_iload_0; | |
772 verify_iload(index, ¤t_frame, CHECK_VERIFY(this)); | |
773 no_control_flow = false; break; | |
774 case Bytecodes::_lload : | |
775 verify_lload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); | |
776 no_control_flow = false; break; | |
777 case Bytecodes::_lload_0 : | |
778 case Bytecodes::_lload_1 : | |
779 case Bytecodes::_lload_2 : | |
780 case Bytecodes::_lload_3 : | |
781 index = opcode - Bytecodes::_lload_0; | |
782 verify_lload(index, ¤t_frame, CHECK_VERIFY(this)); | |
783 no_control_flow = false; break; | |
784 case Bytecodes::_fload : | |
785 verify_fload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); | |
786 no_control_flow = false; break; | |
787 case Bytecodes::_fload_0 : | |
788 case Bytecodes::_fload_1 : | |
789 case Bytecodes::_fload_2 : | |
790 case Bytecodes::_fload_3 : | |
791 index = opcode - Bytecodes::_fload_0; | |
792 verify_fload(index, ¤t_frame, CHECK_VERIFY(this)); | |
793 no_control_flow = false; break; | |
794 case Bytecodes::_dload : | |
795 verify_dload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); | |
796 no_control_flow = false; break; | |
797 case Bytecodes::_dload_0 : | |
798 case Bytecodes::_dload_1 : | |
799 case Bytecodes::_dload_2 : | |
800 case Bytecodes::_dload_3 : | |
801 index = opcode - Bytecodes::_dload_0; | |
802 verify_dload(index, ¤t_frame, CHECK_VERIFY(this)); | |
803 no_control_flow = false; break; | |
804 case Bytecodes::_aload : | |
805 verify_aload(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); | |
806 no_control_flow = false; break; | |
807 case Bytecodes::_aload_0 : | |
808 case Bytecodes::_aload_1 : | |
809 case Bytecodes::_aload_2 : | |
810 case Bytecodes::_aload_3 : | |
811 index = opcode - Bytecodes::_aload_0; | |
812 verify_aload(index, ¤t_frame, CHECK_VERIFY(this)); | |
813 no_control_flow = false; break; | |
814 case Bytecodes::_iaload : | |
815 type = current_frame.pop_stack( | |
816 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
817 atype = current_frame.pop_stack( | |
818 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
819 if (!atype.is_int_array()) { | |
6605 | 820 verify_error(ErrorContext::bad_type(bci, |
821 current_frame.stack_top_ctx(), ref_ctx("[I", THREAD)), | |
822 bad_type_msg, "iaload"); | |
0 | 823 return; |
824 } | |
825 current_frame.push_stack( | |
826 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
827 no_control_flow = false; break; | |
828 case Bytecodes::_baload : | |
829 type = current_frame.pop_stack( | |
830 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
831 atype = current_frame.pop_stack( | |
832 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
833 if (!atype.is_bool_array() && !atype.is_byte_array()) { | |
6605 | 834 verify_error( |
835 ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), | |
836 bad_type_msg, "baload"); | |
0 | 837 return; |
838 } | |
839 current_frame.push_stack( | |
840 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
841 no_control_flow = false; break; | |
842 case Bytecodes::_caload : | |
843 type = current_frame.pop_stack( | |
844 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
845 atype = current_frame.pop_stack( | |
846 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
847 if (!atype.is_char_array()) { | |
6605 | 848 verify_error(ErrorContext::bad_type(bci, |
849 current_frame.stack_top_ctx(), ref_ctx("[C", THREAD)), | |
850 bad_type_msg, "caload"); | |
0 | 851 return; |
852 } | |
853 current_frame.push_stack( | |
854 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
855 no_control_flow = false; break; | |
856 case Bytecodes::_saload : | |
857 type = current_frame.pop_stack( | |
858 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
859 atype = current_frame.pop_stack( | |
860 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
861 if (!atype.is_short_array()) { | |
6605 | 862 verify_error(ErrorContext::bad_type(bci, |
863 current_frame.stack_top_ctx(), ref_ctx("[S", THREAD)), | |
864 bad_type_msg, "saload"); | |
0 | 865 return; |
866 } | |
867 current_frame.push_stack( | |
868 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
869 no_control_flow = false; break; | |
870 case Bytecodes::_laload : | |
871 type = current_frame.pop_stack( | |
872 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
873 atype = current_frame.pop_stack( | |
874 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
875 if (!atype.is_long_array()) { | |
6605 | 876 verify_error(ErrorContext::bad_type(bci, |
877 current_frame.stack_top_ctx(), ref_ctx("[J", THREAD)), | |
878 bad_type_msg, "laload"); | |
0 | 879 return; |
880 } | |
881 current_frame.push_stack_2( | |
882 VerificationType::long_type(), | |
883 VerificationType::long2_type(), CHECK_VERIFY(this)); | |
884 no_control_flow = false; break; | |
885 case Bytecodes::_faload : | |
886 type = current_frame.pop_stack( | |
887 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
888 atype = current_frame.pop_stack( | |
889 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
890 if (!atype.is_float_array()) { | |
6605 | 891 verify_error(ErrorContext::bad_type(bci, |
892 current_frame.stack_top_ctx(), ref_ctx("[F", THREAD)), | |
893 bad_type_msg, "faload"); | |
0 | 894 return; |
895 } | |
896 current_frame.push_stack( | |
897 VerificationType::float_type(), CHECK_VERIFY(this)); | |
898 no_control_flow = false; break; | |
899 case Bytecodes::_daload : | |
900 type = current_frame.pop_stack( | |
901 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
902 atype = current_frame.pop_stack( | |
903 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
904 if (!atype.is_double_array()) { | |
6605 | 905 verify_error(ErrorContext::bad_type(bci, |
906 current_frame.stack_top_ctx(), ref_ctx("[D", THREAD)), | |
907 bad_type_msg, "daload"); | |
0 | 908 return; |
909 } | |
910 current_frame.push_stack_2( | |
911 VerificationType::double_type(), | |
912 VerificationType::double2_type(), CHECK_VERIFY(this)); | |
913 no_control_flow = false; break; | |
914 case Bytecodes::_aaload : { | |
915 type = current_frame.pop_stack( | |
916 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
917 atype = current_frame.pop_stack( | |
918 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
919 if (!atype.is_reference_array()) { | |
6605 | 920 verify_error(ErrorContext::bad_type(bci, |
921 current_frame.stack_top_ctx(), | |
922 TypeOrigin::implicit(VerificationType::reference_check())), | |
923 bad_type_msg, "aaload"); | |
0 | 924 return; |
925 } | |
926 if (atype.is_null()) { | |
927 current_frame.push_stack( | |
928 VerificationType::null_type(), CHECK_VERIFY(this)); | |
929 } else { | |
930 VerificationType component = | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
931 atype.get_component(this, CHECK_VERIFY(this)); |
0 | 932 current_frame.push_stack(component, CHECK_VERIFY(this)); |
933 } | |
934 no_control_flow = false; break; | |
935 } | |
936 case Bytecodes::_istore : | |
937 verify_istore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); | |
938 no_control_flow = false; break; | |
939 case Bytecodes::_istore_0 : | |
940 case Bytecodes::_istore_1 : | |
941 case Bytecodes::_istore_2 : | |
942 case Bytecodes::_istore_3 : | |
943 index = opcode - Bytecodes::_istore_0; | |
944 verify_istore(index, ¤t_frame, CHECK_VERIFY(this)); | |
945 no_control_flow = false; break; | |
946 case Bytecodes::_lstore : | |
947 verify_lstore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); | |
948 no_control_flow = false; break; | |
949 case Bytecodes::_lstore_0 : | |
950 case Bytecodes::_lstore_1 : | |
951 case Bytecodes::_lstore_2 : | |
952 case Bytecodes::_lstore_3 : | |
953 index = opcode - Bytecodes::_lstore_0; | |
954 verify_lstore(index, ¤t_frame, CHECK_VERIFY(this)); | |
955 no_control_flow = false; break; | |
956 case Bytecodes::_fstore : | |
957 verify_fstore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); | |
958 no_control_flow = false; break; | |
959 case Bytecodes::_fstore_0 : | |
960 case Bytecodes::_fstore_1 : | |
961 case Bytecodes::_fstore_2 : | |
962 case Bytecodes::_fstore_3 : | |
963 index = opcode - Bytecodes::_fstore_0; | |
964 verify_fstore(index, ¤t_frame, CHECK_VERIFY(this)); | |
965 no_control_flow = false; break; | |
966 case Bytecodes::_dstore : | |
967 verify_dstore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); | |
968 no_control_flow = false; break; | |
969 case Bytecodes::_dstore_0 : | |
970 case Bytecodes::_dstore_1 : | |
971 case Bytecodes::_dstore_2 : | |
972 case Bytecodes::_dstore_3 : | |
973 index = opcode - Bytecodes::_dstore_0; | |
974 verify_dstore(index, ¤t_frame, CHECK_VERIFY(this)); | |
975 no_control_flow = false; break; | |
976 case Bytecodes::_astore : | |
977 verify_astore(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); | |
978 no_control_flow = false; break; | |
979 case Bytecodes::_astore_0 : | |
980 case Bytecodes::_astore_1 : | |
981 case Bytecodes::_astore_2 : | |
982 case Bytecodes::_astore_3 : | |
983 index = opcode - Bytecodes::_astore_0; | |
984 verify_astore(index, ¤t_frame, CHECK_VERIFY(this)); | |
985 no_control_flow = false; break; | |
986 case Bytecodes::_iastore : | |
987 type = current_frame.pop_stack( | |
988 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
989 type2 = current_frame.pop_stack( | |
990 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
991 atype = current_frame.pop_stack( | |
992 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
993 if (!atype.is_int_array()) { | |
6605 | 994 verify_error(ErrorContext::bad_type(bci, |
995 current_frame.stack_top_ctx(), ref_ctx("[I", THREAD)), | |
996 bad_type_msg, "iastore"); | |
0 | 997 return; |
998 } | |
999 no_control_flow = false; break; | |
1000 case Bytecodes::_bastore : | |
1001 type = current_frame.pop_stack( | |
1002 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1003 type2 = current_frame.pop_stack( | |
1004 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1005 atype = current_frame.pop_stack( | |
1006 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
1007 if (!atype.is_bool_array() && !atype.is_byte_array()) { | |
6605 | 1008 verify_error( |
1009 ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), | |
1010 bad_type_msg, "bastore"); | |
0 | 1011 return; |
1012 } | |
1013 no_control_flow = false; break; | |
1014 case Bytecodes::_castore : | |
1015 current_frame.pop_stack( | |
1016 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1017 current_frame.pop_stack( | |
1018 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1019 atype = current_frame.pop_stack( | |
1020 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
1021 if (!atype.is_char_array()) { | |
6605 | 1022 verify_error(ErrorContext::bad_type(bci, |
1023 current_frame.stack_top_ctx(), ref_ctx("[C", THREAD)), | |
1024 bad_type_msg, "castore"); | |
0 | 1025 return; |
1026 } | |
1027 no_control_flow = false; break; | |
1028 case Bytecodes::_sastore : | |
1029 current_frame.pop_stack( | |
1030 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1031 current_frame.pop_stack( | |
1032 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1033 atype = current_frame.pop_stack( | |
1034 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
1035 if (!atype.is_short_array()) { | |
6605 | 1036 verify_error(ErrorContext::bad_type(bci, |
1037 current_frame.stack_top_ctx(), ref_ctx("[S", THREAD)), | |
1038 bad_type_msg, "sastore"); | |
0 | 1039 return; |
1040 } | |
1041 no_control_flow = false; break; | |
1042 case Bytecodes::_lastore : | |
1043 current_frame.pop_stack_2( | |
1044 VerificationType::long2_type(), | |
1045 VerificationType::long_type(), CHECK_VERIFY(this)); | |
1046 current_frame.pop_stack( | |
1047 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1048 atype = current_frame.pop_stack( | |
1049 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
1050 if (!atype.is_long_array()) { | |
6605 | 1051 verify_error(ErrorContext::bad_type(bci, |
1052 current_frame.stack_top_ctx(), ref_ctx("[J", THREAD)), | |
1053 bad_type_msg, "lastore"); | |
0 | 1054 return; |
1055 } | |
1056 no_control_flow = false; break; | |
1057 case Bytecodes::_fastore : | |
1058 current_frame.pop_stack( | |
1059 VerificationType::float_type(), CHECK_VERIFY(this)); | |
1060 current_frame.pop_stack | |
1061 (VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1062 atype = current_frame.pop_stack( | |
1063 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
1064 if (!atype.is_float_array()) { | |
6605 | 1065 verify_error(ErrorContext::bad_type(bci, |
1066 current_frame.stack_top_ctx(), ref_ctx("[F", THREAD)), | |
1067 bad_type_msg, "fastore"); | |
0 | 1068 return; |
1069 } | |
1070 no_control_flow = false; break; | |
1071 case Bytecodes::_dastore : | |
1072 current_frame.pop_stack_2( | |
1073 VerificationType::double2_type(), | |
1074 VerificationType::double_type(), CHECK_VERIFY(this)); | |
1075 current_frame.pop_stack( | |
1076 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1077 atype = current_frame.pop_stack( | |
1078 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
1079 if (!atype.is_double_array()) { | |
6605 | 1080 verify_error(ErrorContext::bad_type(bci, |
1081 current_frame.stack_top_ctx(), ref_ctx("[D", THREAD)), | |
1082 bad_type_msg, "dastore"); | |
0 | 1083 return; |
1084 } | |
1085 no_control_flow = false; break; | |
1086 case Bytecodes::_aastore : | |
1955
1070423b51f3
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
1678
diff
changeset
|
1087 type = current_frame.pop_stack(object_type(), CHECK_VERIFY(this)); |
0 | 1088 type2 = current_frame.pop_stack( |
1089 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1090 atype = current_frame.pop_stack( | |
1091 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
1092 // more type-checking is done at runtime | |
1093 if (!atype.is_reference_array()) { | |
6605 | 1094 verify_error(ErrorContext::bad_type(bci, |
1095 current_frame.stack_top_ctx(), | |
1096 TypeOrigin::implicit(VerificationType::reference_check())), | |
1097 bad_type_msg, "aastore"); | |
0 | 1098 return; |
1099 } | |
1100 // 4938384: relaxed constraint in JVMS 3nd edition. | |
1101 no_control_flow = false; break; | |
1102 case Bytecodes::_pop : | |
1103 current_frame.pop_stack( | |
1104 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1105 no_control_flow = false; break; | |
1106 case Bytecodes::_pop2 : | |
1107 type = current_frame.pop_stack(CHECK_VERIFY(this)); | |
1108 if (type.is_category1()) { | |
1109 current_frame.pop_stack( | |
1110 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1111 } else if (type.is_category2_2nd()) { | |
1112 current_frame.pop_stack( | |
1113 VerificationType::category2_check(), CHECK_VERIFY(this)); | |
1114 } else { | |
6605 | 1115 /* Unreachable? Would need a category2_1st on TOS |
1116 * which does not appear possible. */ | |
1117 verify_error( | |
1118 ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), | |
1119 bad_type_msg, "pop2"); | |
0 | 1120 return; |
1121 } | |
1122 no_control_flow = false; break; | |
1123 case Bytecodes::_dup : | |
1124 type = current_frame.pop_stack( | |
1125 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1126 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1127 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1128 no_control_flow = false; break; | |
1129 case Bytecodes::_dup_x1 : | |
1130 type = current_frame.pop_stack( | |
1131 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1132 type2 = current_frame.pop_stack( | |
1133 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1134 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1135 current_frame.push_stack(type2, CHECK_VERIFY(this)); | |
1136 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1137 no_control_flow = false; break; | |
1138 case Bytecodes::_dup_x2 : | |
1139 { | |
1140 VerificationType type3; | |
1141 type = current_frame.pop_stack( | |
1142 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1143 type2 = current_frame.pop_stack(CHECK_VERIFY(this)); | |
1144 if (type2.is_category1()) { | |
1145 type3 = current_frame.pop_stack( | |
1146 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1147 } else if (type2.is_category2_2nd()) { | |
1148 type3 = current_frame.pop_stack( | |
1149 VerificationType::category2_check(), CHECK_VERIFY(this)); | |
1150 } else { | |
6605 | 1151 /* Unreachable? Would need a category2_1st at stack depth 2 with |
1152 * a category1 on TOS which does not appear possible. */ | |
1153 verify_error(ErrorContext::bad_type( | |
1154 bci, current_frame.stack_top_ctx()), bad_type_msg, "dup_x2"); | |
0 | 1155 return; |
1156 } | |
1157 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1158 current_frame.push_stack(type3, CHECK_VERIFY(this)); | |
1159 current_frame.push_stack(type2, CHECK_VERIFY(this)); | |
1160 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1161 no_control_flow = false; break; | |
1162 } | |
1163 case Bytecodes::_dup2 : | |
1164 type = current_frame.pop_stack(CHECK_VERIFY(this)); | |
1165 if (type.is_category1()) { | |
1166 type2 = current_frame.pop_stack( | |
1167 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1168 } else if (type.is_category2_2nd()) { | |
1169 type2 = current_frame.pop_stack( | |
1170 VerificationType::category2_check(), CHECK_VERIFY(this)); | |
1171 } else { | |
6605 | 1172 /* Unreachable? Would need a category2_1st on TOS which does not |
1173 * appear possible. */ | |
1174 verify_error( | |
1175 ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), | |
1176 bad_type_msg, "dup2"); | |
0 | 1177 return; |
1178 } | |
1179 current_frame.push_stack(type2, CHECK_VERIFY(this)); | |
1180 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1181 current_frame.push_stack(type2, CHECK_VERIFY(this)); | |
1182 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1183 no_control_flow = false; break; | |
1184 case Bytecodes::_dup2_x1 : | |
1185 { | |
1186 VerificationType type3; | |
1187 type = current_frame.pop_stack(CHECK_VERIFY(this)); | |
1188 if (type.is_category1()) { | |
1189 type2 = current_frame.pop_stack( | |
1190 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
6605 | 1191 } else if (type.is_category2_2nd()) { |
1192 type2 = current_frame.pop_stack( | |
1193 VerificationType::category2_check(), CHECK_VERIFY(this)); | |
0 | 1194 } else { |
6605 | 1195 /* Unreachable? Would need a category2_1st on TOS which does |
1196 * not appear possible. */ | |
1197 verify_error( | |
1198 ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), | |
1199 bad_type_msg, "dup2_x1"); | |
0 | 1200 return; |
1201 } | |
1202 type3 = current_frame.pop_stack( | |
1203 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1204 current_frame.push_stack(type2, CHECK_VERIFY(this)); | |
1205 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1206 current_frame.push_stack(type3, CHECK_VERIFY(this)); | |
1207 current_frame.push_stack(type2, CHECK_VERIFY(this)); | |
1208 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1209 no_control_flow = false; break; | |
1210 } | |
1211 case Bytecodes::_dup2_x2 : | |
1212 { | |
1213 VerificationType type3, type4; | |
1214 type = current_frame.pop_stack(CHECK_VERIFY(this)); | |
1215 if (type.is_category1()) { | |
1216 type2 = current_frame.pop_stack( | |
1217 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1218 } else if (type.is_category2_2nd()) { | |
1219 type2 = current_frame.pop_stack( | |
1220 VerificationType::category2_check(), CHECK_VERIFY(this)); | |
1221 } else { | |
6605 | 1222 /* Unreachable? Would need a category2_1st on TOS which does |
1223 * not appear possible. */ | |
1224 verify_error( | |
1225 ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), | |
1226 bad_type_msg, "dup2_x2"); | |
0 | 1227 return; |
1228 } | |
1229 type3 = current_frame.pop_stack(CHECK_VERIFY(this)); | |
1230 if (type3.is_category1()) { | |
1231 type4 = current_frame.pop_stack( | |
1232 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1233 } else if (type3.is_category2_2nd()) { | |
1234 type4 = current_frame.pop_stack( | |
1235 VerificationType::category2_check(), CHECK_VERIFY(this)); | |
1236 } else { | |
6605 | 1237 /* Unreachable? Would need a category2_1st on TOS after popping |
1238 * a long/double or two category 1's, which does not | |
1239 * appear possible. */ | |
1240 verify_error( | |
1241 ErrorContext::bad_type(bci, current_frame.stack_top_ctx()), | |
1242 bad_type_msg, "dup2_x2"); | |
0 | 1243 return; |
1244 } | |
1245 current_frame.push_stack(type2, CHECK_VERIFY(this)); | |
1246 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1247 current_frame.push_stack(type4, CHECK_VERIFY(this)); | |
1248 current_frame.push_stack(type3, CHECK_VERIFY(this)); | |
1249 current_frame.push_stack(type2, CHECK_VERIFY(this)); | |
1250 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1251 no_control_flow = false; break; | |
1252 } | |
1253 case Bytecodes::_swap : | |
1254 type = current_frame.pop_stack( | |
1255 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1256 type2 = current_frame.pop_stack( | |
1257 VerificationType::category1_check(), CHECK_VERIFY(this)); | |
1258 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1259 current_frame.push_stack(type2, CHECK_VERIFY(this)); | |
1260 no_control_flow = false; break; | |
1261 case Bytecodes::_iadd : | |
1262 case Bytecodes::_isub : | |
1263 case Bytecodes::_imul : | |
1264 case Bytecodes::_idiv : | |
1265 case Bytecodes::_irem : | |
1266 case Bytecodes::_ishl : | |
1267 case Bytecodes::_ishr : | |
1268 case Bytecodes::_iushr : | |
1269 case Bytecodes::_ior : | |
1270 case Bytecodes::_ixor : | |
1271 case Bytecodes::_iand : | |
1272 current_frame.pop_stack( | |
1273 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1274 // fall through | |
1275 case Bytecodes::_ineg : | |
1276 current_frame.pop_stack( | |
1277 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1278 current_frame.push_stack( | |
1279 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1280 no_control_flow = false; break; | |
1281 case Bytecodes::_ladd : | |
1282 case Bytecodes::_lsub : | |
1283 case Bytecodes::_lmul : | |
1284 case Bytecodes::_ldiv : | |
1285 case Bytecodes::_lrem : | |
1286 case Bytecodes::_land : | |
1287 case Bytecodes::_lor : | |
1288 case Bytecodes::_lxor : | |
1289 current_frame.pop_stack_2( | |
1290 VerificationType::long2_type(), | |
1291 VerificationType::long_type(), CHECK_VERIFY(this)); | |
1292 // fall through | |
1293 case Bytecodes::_lneg : | |
1294 current_frame.pop_stack_2( | |
1295 VerificationType::long2_type(), | |
1296 VerificationType::long_type(), CHECK_VERIFY(this)); | |
1297 current_frame.push_stack_2( | |
1298 VerificationType::long_type(), | |
1299 VerificationType::long2_type(), CHECK_VERIFY(this)); | |
1300 no_control_flow = false; break; | |
1301 case Bytecodes::_lshl : | |
1302 case Bytecodes::_lshr : | |
1303 case Bytecodes::_lushr : | |
1304 current_frame.pop_stack( | |
1305 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1306 current_frame.pop_stack_2( | |
1307 VerificationType::long2_type(), | |
1308 VerificationType::long_type(), CHECK_VERIFY(this)); | |
1309 current_frame.push_stack_2( | |
1310 VerificationType::long_type(), | |
1311 VerificationType::long2_type(), CHECK_VERIFY(this)); | |
1312 no_control_flow = false; break; | |
1313 case Bytecodes::_fadd : | |
1314 case Bytecodes::_fsub : | |
1315 case Bytecodes::_fmul : | |
1316 case Bytecodes::_fdiv : | |
1317 case Bytecodes::_frem : | |
1318 current_frame.pop_stack( | |
1319 VerificationType::float_type(), CHECK_VERIFY(this)); | |
1320 // fall through | |
1321 case Bytecodes::_fneg : | |
1322 current_frame.pop_stack( | |
1323 VerificationType::float_type(), CHECK_VERIFY(this)); | |
1324 current_frame.push_stack( | |
1325 VerificationType::float_type(), CHECK_VERIFY(this)); | |
1326 no_control_flow = false; break; | |
1327 case Bytecodes::_dadd : | |
1328 case Bytecodes::_dsub : | |
1329 case Bytecodes::_dmul : | |
1330 case Bytecodes::_ddiv : | |
1331 case Bytecodes::_drem : | |
1332 current_frame.pop_stack_2( | |
1333 VerificationType::double2_type(), | |
1334 VerificationType::double_type(), CHECK_VERIFY(this)); | |
1335 // fall through | |
1336 case Bytecodes::_dneg : | |
1337 current_frame.pop_stack_2( | |
1338 VerificationType::double2_type(), | |
1339 VerificationType::double_type(), CHECK_VERIFY(this)); | |
1340 current_frame.push_stack_2( | |
1341 VerificationType::double_type(), | |
1342 VerificationType::double2_type(), CHECK_VERIFY(this)); | |
1343 no_control_flow = false; break; | |
1344 case Bytecodes::_iinc : | |
1345 verify_iinc(bcs.get_index(), ¤t_frame, CHECK_VERIFY(this)); | |
1346 no_control_flow = false; break; | |
1347 case Bytecodes::_i2l : | |
1348 type = current_frame.pop_stack( | |
1349 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1350 current_frame.push_stack_2( | |
1351 VerificationType::long_type(), | |
1352 VerificationType::long2_type(), CHECK_VERIFY(this)); | |
1353 no_control_flow = false; break; | |
1354 case Bytecodes::_l2i : | |
1355 current_frame.pop_stack_2( | |
1356 VerificationType::long2_type(), | |
1357 VerificationType::long_type(), CHECK_VERIFY(this)); | |
1358 current_frame.push_stack( | |
1359 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1360 no_control_flow = false; break; | |
1361 case Bytecodes::_i2f : | |
1362 current_frame.pop_stack( | |
1363 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1364 current_frame.push_stack( | |
1365 VerificationType::float_type(), CHECK_VERIFY(this)); | |
1366 no_control_flow = false; break; | |
1367 case Bytecodes::_i2d : | |
1368 current_frame.pop_stack( | |
1369 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1370 current_frame.push_stack_2( | |
1371 VerificationType::double_type(), | |
1372 VerificationType::double2_type(), CHECK_VERIFY(this)); | |
1373 no_control_flow = false; break; | |
1374 case Bytecodes::_l2f : | |
1375 current_frame.pop_stack_2( | |
1376 VerificationType::long2_type(), | |
1377 VerificationType::long_type(), CHECK_VERIFY(this)); | |
1378 current_frame.push_stack( | |
1379 VerificationType::float_type(), CHECK_VERIFY(this)); | |
1380 no_control_flow = false; break; | |
1381 case Bytecodes::_l2d : | |
1382 current_frame.pop_stack_2( | |
1383 VerificationType::long2_type(), | |
1384 VerificationType::long_type(), CHECK_VERIFY(this)); | |
1385 current_frame.push_stack_2( | |
1386 VerificationType::double_type(), | |
1387 VerificationType::double2_type(), CHECK_VERIFY(this)); | |
1388 no_control_flow = false; break; | |
1389 case Bytecodes::_f2i : | |
1390 current_frame.pop_stack( | |
1391 VerificationType::float_type(), CHECK_VERIFY(this)); | |
1392 current_frame.push_stack( | |
1393 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1394 no_control_flow = false; break; | |
1395 case Bytecodes::_f2l : | |
1396 current_frame.pop_stack( | |
1397 VerificationType::float_type(), CHECK_VERIFY(this)); | |
1398 current_frame.push_stack_2( | |
1399 VerificationType::long_type(), | |
1400 VerificationType::long2_type(), CHECK_VERIFY(this)); | |
1401 no_control_flow = false; break; | |
1402 case Bytecodes::_f2d : | |
1403 current_frame.pop_stack( | |
1404 VerificationType::float_type(), CHECK_VERIFY(this)); | |
1405 current_frame.push_stack_2( | |
1406 VerificationType::double_type(), | |
1407 VerificationType::double2_type(), CHECK_VERIFY(this)); | |
1408 no_control_flow = false; break; | |
1409 case Bytecodes::_d2i : | |
1410 current_frame.pop_stack_2( | |
1411 VerificationType::double2_type(), | |
1412 VerificationType::double_type(), CHECK_VERIFY(this)); | |
1413 current_frame.push_stack( | |
1414 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1415 no_control_flow = false; break; | |
1416 case Bytecodes::_d2l : | |
1417 current_frame.pop_stack_2( | |
1418 VerificationType::double2_type(), | |
1419 VerificationType::double_type(), CHECK_VERIFY(this)); | |
1420 current_frame.push_stack_2( | |
1421 VerificationType::long_type(), | |
1422 VerificationType::long2_type(), CHECK_VERIFY(this)); | |
1423 no_control_flow = false; break; | |
1424 case Bytecodes::_d2f : | |
1425 current_frame.pop_stack_2( | |
1426 VerificationType::double2_type(), | |
1427 VerificationType::double_type(), CHECK_VERIFY(this)); | |
1428 current_frame.push_stack( | |
1429 VerificationType::float_type(), CHECK_VERIFY(this)); | |
1430 no_control_flow = false; break; | |
1431 case Bytecodes::_i2b : | |
1432 case Bytecodes::_i2c : | |
1433 case Bytecodes::_i2s : | |
1434 current_frame.pop_stack( | |
1435 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1436 current_frame.push_stack( | |
1437 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1438 no_control_flow = false; break; | |
1439 case Bytecodes::_lcmp : | |
1440 current_frame.pop_stack_2( | |
1441 VerificationType::long2_type(), | |
1442 VerificationType::long_type(), CHECK_VERIFY(this)); | |
1443 current_frame.pop_stack_2( | |
1444 VerificationType::long2_type(), | |
1445 VerificationType::long_type(), CHECK_VERIFY(this)); | |
1446 current_frame.push_stack( | |
1447 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1448 no_control_flow = false; break; | |
1449 case Bytecodes::_fcmpl : | |
1450 case Bytecodes::_fcmpg : | |
1451 current_frame.pop_stack( | |
1452 VerificationType::float_type(), CHECK_VERIFY(this)); | |
1453 current_frame.pop_stack( | |
1454 VerificationType::float_type(), CHECK_VERIFY(this)); | |
1455 current_frame.push_stack( | |
1456 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1457 no_control_flow = false; break; | |
1458 case Bytecodes::_dcmpl : | |
1459 case Bytecodes::_dcmpg : | |
1460 current_frame.pop_stack_2( | |
1461 VerificationType::double2_type(), | |
1462 VerificationType::double_type(), CHECK_VERIFY(this)); | |
1463 current_frame.pop_stack_2( | |
1464 VerificationType::double2_type(), | |
1465 VerificationType::double_type(), CHECK_VERIFY(this)); | |
1466 current_frame.push_stack( | |
1467 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1468 no_control_flow = false; break; | |
1469 case Bytecodes::_if_icmpeq: | |
1470 case Bytecodes::_if_icmpne: | |
1471 case Bytecodes::_if_icmplt: | |
1472 case Bytecodes::_if_icmpge: | |
1473 case Bytecodes::_if_icmpgt: | |
1474 case Bytecodes::_if_icmple: | |
1475 current_frame.pop_stack( | |
1476 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1477 // fall through | |
1478 case Bytecodes::_ifeq: | |
1479 case Bytecodes::_ifne: | |
1480 case Bytecodes::_iflt: | |
1481 case Bytecodes::_ifge: | |
1482 case Bytecodes::_ifgt: | |
1483 case Bytecodes::_ifle: | |
1484 current_frame.pop_stack( | |
1485 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1486 target = bcs.dest(); | |
1487 stackmap_table.check_jump_target( | |
1488 ¤t_frame, target, CHECK_VERIFY(this)); | |
1489 no_control_flow = false; break; | |
1490 case Bytecodes::_if_acmpeq : | |
1491 case Bytecodes::_if_acmpne : | |
1492 current_frame.pop_stack( | |
1493 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
1494 // fall through | |
1495 case Bytecodes::_ifnull : | |
1496 case Bytecodes::_ifnonnull : | |
1497 current_frame.pop_stack( | |
1498 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
1499 target = bcs.dest(); | |
1500 stackmap_table.check_jump_target | |
1501 (¤t_frame, target, CHECK_VERIFY(this)); | |
1502 no_control_flow = false; break; | |
1503 case Bytecodes::_goto : | |
1504 target = bcs.dest(); | |
1505 stackmap_table.check_jump_target( | |
1506 ¤t_frame, target, CHECK_VERIFY(this)); | |
1507 no_control_flow = true; break; | |
1508 case Bytecodes::_goto_w : | |
1509 target = bcs.dest_w(); | |
1510 stackmap_table.check_jump_target( | |
1511 ¤t_frame, target, CHECK_VERIFY(this)); | |
1512 no_control_flow = true; break; | |
1513 case Bytecodes::_tableswitch : | |
1514 case Bytecodes::_lookupswitch : | |
1515 verify_switch( | |
1516 &bcs, code_length, code_data, ¤t_frame, | |
1517 &stackmap_table, CHECK_VERIFY(this)); | |
1518 no_control_flow = true; break; | |
1519 case Bytecodes::_ireturn : | |
1520 type = current_frame.pop_stack( | |
1521 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
6605 | 1522 verify_return_value(return_type, type, bci, |
1523 ¤t_frame, CHECK_VERIFY(this)); | |
0 | 1524 no_control_flow = true; break; |
1525 case Bytecodes::_lreturn : | |
1526 type2 = current_frame.pop_stack( | |
1527 VerificationType::long2_type(), CHECK_VERIFY(this)); | |
1528 type = current_frame.pop_stack( | |
1529 VerificationType::long_type(), CHECK_VERIFY(this)); | |
6605 | 1530 verify_return_value(return_type, type, bci, |
1531 ¤t_frame, CHECK_VERIFY(this)); | |
0 | 1532 no_control_flow = true; break; |
1533 case Bytecodes::_freturn : | |
1534 type = current_frame.pop_stack( | |
1535 VerificationType::float_type(), CHECK_VERIFY(this)); | |
6605 | 1536 verify_return_value(return_type, type, bci, |
1537 ¤t_frame, CHECK_VERIFY(this)); | |
0 | 1538 no_control_flow = true; break; |
1539 case Bytecodes::_dreturn : | |
1540 type2 = current_frame.pop_stack( | |
1541 VerificationType::double2_type(), CHECK_VERIFY(this)); | |
1542 type = current_frame.pop_stack( | |
1543 VerificationType::double_type(), CHECK_VERIFY(this)); | |
6605 | 1544 verify_return_value(return_type, type, bci, |
1545 ¤t_frame, CHECK_VERIFY(this)); | |
0 | 1546 no_control_flow = true; break; |
1547 case Bytecodes::_areturn : | |
1548 type = current_frame.pop_stack( | |
1549 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
6605 | 1550 verify_return_value(return_type, type, bci, |
1551 ¤t_frame, CHECK_VERIFY(this)); | |
0 | 1552 no_control_flow = true; break; |
1553 case Bytecodes::_return : | |
1554 if (return_type != VerificationType::bogus_type()) { | |
6605 | 1555 verify_error(ErrorContext::bad_code(bci), |
1556 "Method expects a return value"); | |
0 | 1557 return; |
1558 } | |
1559 // Make sure "this" has been initialized if current method is an | |
1560 // <init> | |
1561 if (_method->name() == vmSymbols::object_initializer_name() && | |
1562 current_frame.flag_this_uninit()) { | |
6605 | 1563 verify_error(ErrorContext::bad_code(bci), |
1564 "Constructor must call super() or this() " | |
1565 "before return"); | |
0 | 1566 return; |
1567 } | |
1568 no_control_flow = true; break; | |
1569 case Bytecodes::_getstatic : | |
1570 case Bytecodes::_putstatic : | |
1571 case Bytecodes::_getfield : | |
1572 case Bytecodes::_putfield : | |
1573 verify_field_instructions( | |
1574 &bcs, ¤t_frame, cp, CHECK_VERIFY(this)); | |
1575 no_control_flow = false; break; | |
1576 case Bytecodes::_invokevirtual : | |
1577 case Bytecodes::_invokespecial : | |
1578 case Bytecodes::_invokestatic : | |
1579 verify_invoke_instructions( | |
20759
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
1580 &bcs, code_length, ¤t_frame, (bci >= ex_min && bci < ex_max), |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
1581 &this_uninit, return_type, cp, &stackmap_table, CHECK_VERIFY(this)); |
0 | 1582 no_control_flow = false; break; |
1583 case Bytecodes::_invokeinterface : | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
1584 case Bytecodes::_invokedynamic : |
0 | 1585 verify_invoke_instructions( |
20759
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
1586 &bcs, code_length, ¤t_frame, (bci >= ex_min && bci < ex_max), |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
1587 &this_uninit, return_type, cp, &stackmap_table, CHECK_VERIFY(this)); |
0 | 1588 no_control_flow = false; break; |
1589 case Bytecodes::_new : | |
1590 { | |
1565 | 1591 index = bcs.get_index_u2(); |
6605 | 1592 verify_cp_class_type(bci, index, cp, CHECK_VERIFY(this)); |
0 | 1593 VerificationType new_class_type = |
1594 cp_index_to_type(index, cp, CHECK_VERIFY(this)); | |
1595 if (!new_class_type.is_object()) { | |
6605 | 1596 verify_error(ErrorContext::bad_type(bci, |
1597 TypeOrigin::cp(index, new_class_type)), | |
1598 "Illegal new instruction"); | |
0 | 1599 return; |
1600 } | |
1601 type = VerificationType::uninitialized_type(bci); | |
1602 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1603 no_control_flow = false; break; | |
1604 } | |
1605 case Bytecodes::_newarray : | |
1606 type = get_newarray_type(bcs.get_index(), bci, CHECK_VERIFY(this)); | |
1607 current_frame.pop_stack( | |
1608 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1609 current_frame.push_stack(type, CHECK_VERIFY(this)); | |
1610 no_control_flow = false; break; | |
1611 case Bytecodes::_anewarray : | |
1612 verify_anewarray( | |
6605 | 1613 bci, bcs.get_index_u2(), cp, ¤t_frame, CHECK_VERIFY(this)); |
0 | 1614 no_control_flow = false; break; |
1615 case Bytecodes::_arraylength : | |
1616 type = current_frame.pop_stack( | |
1617 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
134
8a79f7ec8f5d
6692246: Regression : JDK 6u4 b01 fails two JCK tests when fallback is switched off
kamg
parents:
0
diff
changeset
|
1618 if (!(type.is_null() || type.is_array())) { |
6605 | 1619 verify_error(ErrorContext::bad_type( |
1620 bci, current_frame.stack_top_ctx()), | |
1621 bad_type_msg, "arraylength"); | |
0 | 1622 } |
1623 current_frame.push_stack( | |
1624 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1625 no_control_flow = false; break; | |
1626 case Bytecodes::_checkcast : | |
1627 { | |
1565 | 1628 index = bcs.get_index_u2(); |
6605 | 1629 verify_cp_class_type(bci, index, cp, CHECK_VERIFY(this)); |
1955
1070423b51f3
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
1678
diff
changeset
|
1630 current_frame.pop_stack(object_type(), CHECK_VERIFY(this)); |
0 | 1631 VerificationType klass_type = cp_index_to_type( |
1632 index, cp, CHECK_VERIFY(this)); | |
1633 current_frame.push_stack(klass_type, CHECK_VERIFY(this)); | |
1634 no_control_flow = false; break; | |
1635 } | |
1636 case Bytecodes::_instanceof : { | |
1565 | 1637 index = bcs.get_index_u2(); |
6605 | 1638 verify_cp_class_type(bci, index, cp, CHECK_VERIFY(this)); |
1955
1070423b51f3
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
1678
diff
changeset
|
1639 current_frame.pop_stack(object_type(), CHECK_VERIFY(this)); |
0 | 1640 current_frame.push_stack( |
1641 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1642 no_control_flow = false; break; | |
1643 } | |
1644 case Bytecodes::_monitorenter : | |
1645 case Bytecodes::_monitorexit : | |
1646 current_frame.pop_stack( | |
1647 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
1648 no_control_flow = false; break; | |
1649 case Bytecodes::_multianewarray : | |
1650 { | |
1565 | 1651 index = bcs.get_index_u2(); |
0 | 1652 u2 dim = *(bcs.bcp()+3); |
6605 | 1653 verify_cp_class_type(bci, index, cp, CHECK_VERIFY(this)); |
0 | 1654 VerificationType new_array_type = |
1655 cp_index_to_type(index, cp, CHECK_VERIFY(this)); | |
1656 if (!new_array_type.is_array()) { | |
6605 | 1657 verify_error(ErrorContext::bad_type(bci, |
1658 TypeOrigin::cp(index, new_array_type)), | |
1659 "Illegal constant pool index in multianewarray instruction"); | |
0 | 1660 return; |
1661 } | |
1662 if (dim < 1 || new_array_type.dimensions() < dim) { | |
6605 | 1663 verify_error(ErrorContext::bad_code(bci), |
1664 "Illegal dimension in multianewarray instruction: %d", dim); | |
0 | 1665 return; |
1666 } | |
1667 for (int i = 0; i < dim; i++) { | |
1668 current_frame.pop_stack( | |
1669 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1670 } | |
1671 current_frame.push_stack(new_array_type, CHECK_VERIFY(this)); | |
1672 no_control_flow = false; break; | |
1673 } | |
1674 case Bytecodes::_athrow : | |
1675 type = VerificationType::reference_type( | |
1676 vmSymbols::java_lang_Throwable()); | |
1677 current_frame.pop_stack(type, CHECK_VERIFY(this)); | |
1678 no_control_flow = true; break; | |
1679 default: | |
1680 // We only need to check the valid bytecodes in class file. | |
1681 // And jsr and ret are not in the new class file format in JDK1.5. | |
6605 | 1682 verify_error(ErrorContext::bad_code(bci), |
1683 "Bad instruction: %02x", opcode); | |
0 | 1684 no_control_flow = false; |
1685 return; | |
1686 } // end switch | |
1687 } // end Merge with the next instruction | |
1688 | |
22916
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
1689 // Look for possible jump target in exception handlers and see if it matches |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
1690 // current_frame. Don't do this check if it has already been done (for |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
1691 // ([a,d,f,i,l]store* opcodes). This check cannot be done earlier because |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
1692 // opcodes, such as invokespecial, may set the this_uninit flag. |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
1693 assert(!(verified_exc_handlers && this_uninit), |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
1694 "Exception handler targets got verified before this_uninit got set"); |
6b65121b3258
7127066: Class verifier accepts an invalid class file
hseigel
parents:
22893
diff
changeset
|
1695 if (!verified_exc_handlers && bci >= ex_min && bci < ex_max) { |
0 | 1696 verify_exception_handler_targets( |
1697 bci, this_uninit, ¤t_frame, &stackmap_table, CHECK_VERIFY(this)); | |
1698 } | |
1699 } // end while | |
1700 | |
1701 // Make sure that control flow does not fall through end of the method | |
1702 if (!no_control_flow) { | |
6605 | 1703 verify_error(ErrorContext::bad_code(code_length), |
1704 "Control flow falls through code end"); | |
0 | 1705 return; |
1706 } | |
1707 } | |
1708 | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
1709 #undef bad_type_message |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
1710 |
0 | 1711 char* ClassVerifier::generate_code_data(methodHandle m, u4 code_length, TRAPS) { |
1712 char* code_data = NEW_RESOURCE_ARRAY(char, code_length); | |
1713 memset(code_data, 0, sizeof(char) * code_length); | |
1714 RawBytecodeStream bcs(m); | |
1715 | |
1716 while (!bcs.is_last_bytecode()) { | |
1717 if (bcs.raw_next() != Bytecodes::_illegal) { | |
1718 int bci = bcs.bci(); | |
1565 | 1719 if (bcs.raw_code() == Bytecodes::_new) { |
0 | 1720 code_data[bci] = NEW_OFFSET; |
1721 } else { | |
1722 code_data[bci] = BYTECODE_OFFSET; | |
1723 } | |
1724 } else { | |
6605 | 1725 verify_error(ErrorContext::bad_code(bcs.bci()), "Bad instruction"); |
0 | 1726 return NULL; |
1727 } | |
1728 } | |
1729 | |
1730 return code_data; | |
1731 } | |
1732 | |
1733 void ClassVerifier::verify_exception_handler_table(u4 code_length, char* code_data, int& min, int& max, TRAPS) { | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1734 ExceptionTable exhandlers(_method()); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1735 int exlength = exhandlers.length(); |
0 | 1736 constantPoolHandle cp (THREAD, _method->constants()); |
1737 | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1738 for(int i = 0; i < exlength; i++) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1739 //reacquire the table in case a GC happened |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1740 ExceptionTable exhandlers(_method()); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1741 u2 start_pc = exhandlers.start_pc(i); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1742 u2 end_pc = exhandlers.end_pc(i); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1743 u2 handler_pc = exhandlers.handler_pc(i); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1744 if (start_pc >= code_length || code_data[start_pc] == 0) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1745 class_format_error("Illegal exception table start_pc %d", start_pc); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1746 return; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1747 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1748 if (end_pc != code_length) { // special case: end_pc == code_length |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1749 if (end_pc > code_length || code_data[end_pc] == 0) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1750 class_format_error("Illegal exception table end_pc %d", end_pc); |
0 | 1751 return; |
1752 } | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1753 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1754 if (handler_pc >= code_length || code_data[handler_pc] == 0) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1755 class_format_error("Illegal exception table handler_pc %d", handler_pc); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1756 return; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1757 } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1758 int catch_type_index = exhandlers.catch_type_index(i); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1759 if (catch_type_index != 0) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1760 VerificationType catch_type = cp_index_to_type( |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1761 catch_type_index, cp, CHECK_VERIFY(this)); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1762 VerificationType throwable = |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1763 VerificationType::reference_type(vmSymbols::java_lang_Throwable()); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1764 bool is_subclass = throwable.is_assignable_from( |
18052 | 1765 catch_type, this, false, CHECK_VERIFY(this)); |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1766 if (!is_subclass) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1767 // 4286534: should throw VerifyError according to recent spec change |
6605 | 1768 verify_error(ErrorContext::bad_type(handler_pc, |
1769 TypeOrigin::cp(catch_type_index, catch_type), | |
1770 TypeOrigin::implicit(throwable)), | |
1771 "Catch type is not a subclass " | |
1772 "of Throwable in exception handler %d", handler_pc); | |
0 | 1773 return; |
1774 } | |
1775 } | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1776 if (start_pc < min) min = start_pc; |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1777 if (end_pc > max) max = end_pc; |
0 | 1778 } |
1779 } | |
1780 | |
1781 void ClassVerifier::verify_local_variable_table(u4 code_length, char* code_data, TRAPS) { | |
1782 int localvariable_table_length = _method()->localvariable_table_length(); | |
1783 if (localvariable_table_length > 0) { | |
1784 LocalVariableTableElement* table = _method()->localvariable_table_start(); | |
1785 for (int i = 0; i < localvariable_table_length; i++) { | |
1786 u2 start_bci = table[i].start_bci; | |
1787 u2 length = table[i].length; | |
1788 | |
1789 if (start_bci >= code_length || code_data[start_bci] == 0) { | |
1790 class_format_error( | |
1791 "Illegal local variable table start_pc %d", start_bci); | |
1792 return; | |
1793 } | |
1794 u4 end_bci = (u4)(start_bci + length); | |
1795 if (end_bci != code_length) { | |
1796 if (end_bci >= code_length || code_data[end_bci] == 0) { | |
1797 class_format_error( "Illegal local variable table length %d", length); | |
1798 return; | |
1799 } | |
1800 } | |
1801 } | |
1802 } | |
1803 } | |
1804 | |
1805 u2 ClassVerifier::verify_stackmap_table(u2 stackmap_index, u2 bci, | |
1806 StackMapFrame* current_frame, | |
1807 StackMapTable* stackmap_table, | |
1808 bool no_control_flow, TRAPS) { | |
1809 if (stackmap_index < stackmap_table->get_frame_count()) { | |
1810 u2 this_offset = stackmap_table->get_offset(stackmap_index); | |
1811 if (no_control_flow && this_offset > bci) { | |
6605 | 1812 verify_error(ErrorContext::missing_stackmap(bci), |
1813 "Expecting a stack map frame"); | |
0 | 1814 return 0; |
1815 } | |
1816 if (this_offset == bci) { | |
6605 | 1817 ErrorContext ctx; |
0 | 1818 // See if current stack map can be assigned to the frame in table. |
1819 // current_frame is the stackmap frame got from the last instruction. | |
1820 // If matched, current_frame will be updated by this method. | |
6605 | 1821 bool matches = stackmap_table->match_stackmap( |
0 | 1822 current_frame, this_offset, stackmap_index, |
20740
7c9925f21c25
8051012: Regression in verifier for <init> method call from inside of a branch
hseigel
parents:
18010
diff
changeset
|
1823 !no_control_flow, true, false, &ctx, CHECK_VERIFY_(this, 0)); |
6605 | 1824 if (!matches) { |
0 | 1825 // report type error |
6605 | 1826 verify_error(ctx, "Instruction type does not match stack map"); |
0 | 1827 return 0; |
1828 } | |
1829 stackmap_index++; | |
1830 } else if (this_offset < bci) { | |
1831 // current_offset should have met this_offset. | |
1832 class_format_error("Bad stack map offset %d", this_offset); | |
1833 return 0; | |
1834 } | |
1835 } else if (no_control_flow) { | |
6605 | 1836 verify_error(ErrorContext::bad_code(bci), "Expecting a stack map frame"); |
0 | 1837 return 0; |
1838 } | |
1839 return stackmap_index; | |
1840 } | |
1841 | |
1842 void ClassVerifier::verify_exception_handler_targets(u2 bci, bool this_uninit, StackMapFrame* current_frame, | |
1843 StackMapTable* stackmap_table, TRAPS) { | |
1844 constantPoolHandle cp (THREAD, _method->constants()); | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1845 ExceptionTable exhandlers(_method()); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1846 int exlength = exhandlers.length(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1847 for(int i = 0; i < exlength; i++) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1848 //reacquire the table in case a GC happened |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1849 ExceptionTable exhandlers(_method()); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1850 u2 start_pc = exhandlers.start_pc(i); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1851 u2 end_pc = exhandlers.end_pc(i); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1852 u2 handler_pc = exhandlers.handler_pc(i); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1853 int catch_type_index = exhandlers.catch_type_index(i); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1854 if(bci >= start_pc && bci < end_pc) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1855 u1 flags = current_frame->flags(); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1856 if (this_uninit) { flags |= FLAG_THIS_UNINIT; } |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1857 StackMapFrame* new_frame = current_frame->frame_in_exception_handler(flags); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1858 if (catch_type_index != 0) { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1859 // We know that this index refers to a subclass of Throwable |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1860 VerificationType catch_type = cp_index_to_type( |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1861 catch_type_index, cp, CHECK_VERIFY(this)); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1862 new_frame->push_stack(catch_type, CHECK_VERIFY(this)); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1863 } else { |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1864 VerificationType throwable = |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1865 VerificationType::reference_type(vmSymbols::java_lang_Throwable()); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1866 new_frame->push_stack(throwable, CHECK_VERIFY(this)); |
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1867 } |
6605 | 1868 ErrorContext ctx; |
1869 bool matches = stackmap_table->match_stackmap( | |
20740
7c9925f21c25
8051012: Regression in verifier for <init> method call from inside of a branch
hseigel
parents:
18010
diff
changeset
|
1870 new_frame, handler_pc, true, false, true, &ctx, CHECK_VERIFY(this)); |
6605 | 1871 if (!matches) { |
1872 verify_error(ctx, "Stack map does not match the one at " | |
1873 "exception handler %d", handler_pc); | |
6213
8150fa46d2ed
7178145: Change constMethodOop::_exception_table to optionally inlined u2 table.
jiangli
parents:
6118
diff
changeset
|
1874 return; |
0 | 1875 } |
1876 } | |
1877 } | |
1878 } | |
1879 | |
6605 | 1880 void ClassVerifier::verify_cp_index( |
1881 u2 bci, constantPoolHandle cp, int index, TRAPS) { | |
0 | 1882 int nconstants = cp->length(); |
1883 if ((index <= 0) || (index >= nconstants)) { | |
6605 | 1884 verify_error(ErrorContext::bad_cp_index(bci, index), |
1885 "Illegal constant pool index %d in class %s", | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6934
diff
changeset
|
1886 index, cp->pool_holder()->external_name()); |
0 | 1887 return; |
1888 } | |
1889 } | |
1890 | |
1891 void ClassVerifier::verify_cp_type( | |
6605 | 1892 u2 bci, int index, constantPoolHandle cp, unsigned int types, TRAPS) { |
0 | 1893 |
1894 // In some situations, bytecode rewriting may occur while we're verifying. | |
1895 // In this case, a constant pool cache exists and some indices refer to that | |
1570 | 1896 // instead. Be sure we don't pick up such indices by accident. |
1897 // We must check was_recursively_verified() before we get here. | |
1898 guarantee(cp->cache() == NULL, "not rewritten yet"); | |
0 | 1899 |
6605 | 1900 verify_cp_index(bci, cp, index, CHECK_VERIFY(this)); |
0 | 1901 unsigned int tag = cp->tag_at(index).value(); |
1902 if ((types & (1 << tag)) == 0) { | |
6605 | 1903 verify_error(ErrorContext::bad_cp_index(bci, index), |
0 | 1904 "Illegal type at constant pool entry %d in class %s", |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6934
diff
changeset
|
1905 index, cp->pool_holder()->external_name()); |
0 | 1906 return; |
1907 } | |
1908 } | |
1909 | |
1910 void ClassVerifier::verify_cp_class_type( | |
6605 | 1911 u2 bci, int index, constantPoolHandle cp, TRAPS) { |
1912 verify_cp_index(bci, cp, index, CHECK_VERIFY(this)); | |
0 | 1913 constantTag tag = cp->tag_at(index); |
1914 if (!tag.is_klass() && !tag.is_unresolved_klass()) { | |
6605 | 1915 verify_error(ErrorContext::bad_cp_index(bci, index), |
1916 "Illegal type at constant pool entry %d in class %s", | |
6940
18fb7da42534
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
6934
diff
changeset
|
1917 index, cp->pool_holder()->external_name()); |
0 | 1918 return; |
1919 } | |
1920 } | |
1921 | |
6605 | 1922 void ClassVerifier::verify_error(ErrorContext ctx, const char* msg, ...) { |
1923 stringStream ss; | |
0 | 1924 |
6605 | 1925 ctx.reset_frames(); |
0 | 1926 _exception_type = vmSymbols::java_lang_VerifyError(); |
6605 | 1927 _error_context = ctx; |
0 | 1928 va_list va; |
6605 | 1929 va_start(va, msg); |
1930 ss.vprint(msg, va); | |
0 | 1931 va_end(va); |
6605 | 1932 _message = ss.as_string(); |
1933 #ifdef ASSERT | |
1934 ResourceMark rm; | |
1935 const char* exception_name = _exception_type->as_C_string(); | |
1936 Exceptions::debug_check_abort(exception_name, NULL); | |
1937 #endif // ndef ASSERT | |
0 | 1938 } |
1939 | |
1940 void ClassVerifier::class_format_error(const char* msg, ...) { | |
6605 | 1941 stringStream ss; |
0 | 1942 _exception_type = vmSymbols::java_lang_ClassFormatError(); |
1943 va_list va; | |
1944 va_start(va, msg); | |
6605 | 1945 ss.vprint(msg, va); |
0 | 1946 va_end(va); |
6605 | 1947 if (!_method.is_null()) { |
1948 ss.print(" in method %s", _method->name_and_sig_as_C_string()); | |
1949 } | |
1950 _message = ss.as_string(); | |
0 | 1951 } |
1952 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
1953 Klass* ClassVerifier::load_class(Symbol* name, TRAPS) { |
0 | 1954 // Get current loader and protection domain first. |
1955 oop loader = current_class()->class_loader(); | |
1956 oop protection_domain = current_class()->protection_domain(); | |
1957 | |
1958 return SystemDictionary::resolve_or_fail( | |
1959 name, Handle(THREAD, loader), Handle(THREAD, protection_domain), | |
1960 true, CHECK_NULL); | |
1961 } | |
1962 | |
1963 bool ClassVerifier::is_protected_access(instanceKlassHandle this_class, | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
1964 Klass* target_class, |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
1965 Symbol* field_name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
1966 Symbol* field_sig, |
0 | 1967 bool is_method) { |
1968 No_Safepoint_Verifier nosafepoint; | |
1969 | |
1970 // If target class isn't a super class of this class, we don't worry about this case | |
1971 if (!this_class->is_subclass_of(target_class)) { | |
1972 return false; | |
1973 } | |
1974 // Check if the specified method or field is protected | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
1975 InstanceKlass* target_instance = InstanceKlass::cast(target_class); |
0 | 1976 fieldDescriptor fd; |
1977 if (is_method) { | |
17889
386dd1c71858
8033150: invokestatic: IncompatibleClassChangeError trying to invoke static method from a parent in presence of conflicting defaults.
lfoltan
parents:
13401
diff
changeset
|
1978 Method* m = target_instance->uncached_lookup_method(field_name, field_sig, Klass::normal); |
0 | 1979 if (m != NULL && m->is_protected()) { |
1980 if (!this_class->is_same_class_package(m->method_holder())) { | |
1981 return true; | |
1982 } | |
1983 } | |
1984 } else { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
1985 Klass* member_klass = target_instance->find_field(field_name, field_sig, &fd); |
6605 | 1986 if (member_klass != NULL && fd.is_protected()) { |
0 | 1987 if (!this_class->is_same_class_package(member_klass)) { |
1988 return true; | |
1989 } | |
1990 } | |
1991 } | |
1992 return false; | |
1993 } | |
1994 | |
1995 void ClassVerifier::verify_ldc( | |
6605 | 1996 int opcode, u2 index, StackMapFrame* current_frame, |
1997 constantPoolHandle cp, u2 bci, TRAPS) { | |
1998 verify_cp_index(bci, cp, index, CHECK_VERIFY(this)); | |
0 | 1999 constantTag tag = cp->tag_at(index); |
2000 unsigned int types; | |
2001 if (opcode == Bytecodes::_ldc || opcode == Bytecodes::_ldc_w) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
2002 if (!tag.is_unresolved_klass()) { |
0 | 2003 types = (1 << JVM_CONSTANT_Integer) | (1 << JVM_CONSTANT_Float) |
1602 | 2004 | (1 << JVM_CONSTANT_String) | (1 << JVM_CONSTANT_Class) |
2005 | (1 << JVM_CONSTANT_MethodHandle) | (1 << JVM_CONSTANT_MethodType); | |
2006 // Note: The class file parser already verified the legality of | |
2007 // MethodHandle and MethodType constants. | |
6605 | 2008 verify_cp_type(bci, index, cp, types, CHECK_VERIFY(this)); |
0 | 2009 } |
2010 } else { | |
2011 assert(opcode == Bytecodes::_ldc2_w, "must be ldc2_w"); | |
2012 types = (1 << JVM_CONSTANT_Double) | (1 << JVM_CONSTANT_Long); | |
6605 | 2013 verify_cp_type(bci, index, cp, types, CHECK_VERIFY(this)); |
0 | 2014 } |
431
a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
196
diff
changeset
|
2015 if (tag.is_string() && cp->is_pseudo_string_at(index)) { |
1955
1070423b51f3
6865028: Illegal instructions passing verification prior to 'invokespecial Object.<init>'
kamg
parents:
1678
diff
changeset
|
2016 current_frame->push_stack(object_type(), CHECK_VERIFY(this)); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
2017 } else if (tag.is_string()) { |
0 | 2018 current_frame->push_stack( |
2019 VerificationType::reference_type( | |
2020 vmSymbols::java_lang_String()), CHECK_VERIFY(this)); | |
2021 } else if (tag.is_klass() || tag.is_unresolved_klass()) { | |
2022 current_frame->push_stack( | |
2023 VerificationType::reference_type( | |
2024 vmSymbols::java_lang_Class()), CHECK_VERIFY(this)); | |
2025 } else if (tag.is_int()) { | |
2026 current_frame->push_stack( | |
2027 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
2028 } else if (tag.is_float()) { | |
2029 current_frame->push_stack( | |
2030 VerificationType::float_type(), CHECK_VERIFY(this)); | |
2031 } else if (tag.is_double()) { | |
2032 current_frame->push_stack_2( | |
2033 VerificationType::double_type(), | |
2034 VerificationType::double2_type(), CHECK_VERIFY(this)); | |
2035 } else if (tag.is_long()) { | |
2036 current_frame->push_stack_2( | |
2037 VerificationType::long_type(), | |
2038 VerificationType::long2_type(), CHECK_VERIFY(this)); | |
1602 | 2039 } else if (tag.is_method_handle()) { |
2040 current_frame->push_stack( | |
2041 VerificationType::reference_type( | |
2460 | 2042 vmSymbols::java_lang_invoke_MethodHandle()), CHECK_VERIFY(this)); |
1602 | 2043 } else if (tag.is_method_type()) { |
2044 current_frame->push_stack( | |
2045 VerificationType::reference_type( | |
2460 | 2046 vmSymbols::java_lang_invoke_MethodType()), CHECK_VERIFY(this)); |
0 | 2047 } else { |
6605 | 2048 /* Unreachable? verify_cp_type has already validated the cp type. */ |
2049 verify_error( | |
2050 ErrorContext::bad_cp_index(bci, index), "Invalid index in ldc"); | |
0 | 2051 return; |
2052 } | |
2053 } | |
2054 | |
2055 void ClassVerifier::verify_switch( | |
2056 RawBytecodeStream* bcs, u4 code_length, char* code_data, | |
2057 StackMapFrame* current_frame, StackMapTable* stackmap_table, TRAPS) { | |
2058 int bci = bcs->bci(); | |
2059 address bcp = bcs->bcp(); | |
2060 address aligned_bcp = (address) round_to((intptr_t)(bcp + 1), jintSize); | |
2061 | |
8816
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
2062 if (_klass->major_version() < NONZERO_PADDING_BYTES_IN_SWITCH_MAJOR_VERSION) { |
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
2063 // 4639449 & 4647081: padding bytes must be 0 |
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
2064 u2 padding_offset = 1; |
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
2065 while ((bcp + padding_offset) < aligned_bcp) { |
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
2066 if(*(bcp + padding_offset) != 0) { |
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
2067 verify_error(ErrorContext::bad_code(bci), |
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
2068 "Nonzero padding byte in lookswitch or tableswitch"); |
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
2069 return; |
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
2070 } |
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
2071 padding_offset++; |
0 | 2072 } |
2073 } | |
8816
729be16a470b
8010667: Non-zero padding is not allowed in splitverifier for tableswitch/lookupswitch instructions.
hseigel
parents:
8060
diff
changeset
|
2074 |
0 | 2075 int default_offset = (int) Bytes::get_Java_u4(aligned_bcp); |
2076 int keys, delta; | |
2077 current_frame->pop_stack( | |
2078 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
1565 | 2079 if (bcs->raw_code() == Bytecodes::_tableswitch) { |
0 | 2080 jint low = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize); |
2081 jint high = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize); | |
2082 if (low > high) { | |
6605 | 2083 verify_error(ErrorContext::bad_code(bci), |
2084 "low must be less than or equal to high in tableswitch"); | |
0 | 2085 return; |
2086 } | |
2087 keys = high - low + 1; | |
2088 if (keys < 0) { | |
6605 | 2089 verify_error(ErrorContext::bad_code(bci), "too many keys in tableswitch"); |
0 | 2090 return; |
2091 } | |
2092 delta = 1; | |
2093 } else { | |
2094 keys = (int)Bytes::get_Java_u4(aligned_bcp + jintSize); | |
2095 if (keys < 0) { | |
6605 | 2096 verify_error(ErrorContext::bad_code(bci), |
2097 "number of keys in lookupswitch less than 0"); | |
0 | 2098 return; |
2099 } | |
2100 delta = 2; | |
2101 // Make sure that the lookupswitch items are sorted | |
2102 for (int i = 0; i < (keys - 1); i++) { | |
2103 jint this_key = Bytes::get_Java_u4(aligned_bcp + (2+2*i)*jintSize); | |
2104 jint next_key = Bytes::get_Java_u4(aligned_bcp + (2+2*i+2)*jintSize); | |
2105 if (this_key >= next_key) { | |
6605 | 2106 verify_error(ErrorContext::bad_code(bci), |
2107 "Bad lookupswitch instruction"); | |
0 | 2108 return; |
2109 } | |
2110 } | |
2111 } | |
2112 int target = bci + default_offset; | |
2113 stackmap_table->check_jump_target(current_frame, target, CHECK_VERIFY(this)); | |
2114 for (int i = 0; i < keys; i++) { | |
6118 | 2115 // Because check_jump_target() may safepoint, the bytecode could have |
2116 // moved, which means 'aligned_bcp' is no good and needs to be recalculated. | |
2117 aligned_bcp = (address)round_to((intptr_t)(bcs->bcp() + 1), jintSize); | |
0 | 2118 target = bci + (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize); |
2119 stackmap_table->check_jump_target( | |
2120 current_frame, target, CHECK_VERIFY(this)); | |
2121 } | |
6118 | 2122 NOT_PRODUCT(aligned_bcp = NULL); // no longer valid at this point |
0 | 2123 } |
2124 | |
2125 bool ClassVerifier::name_in_supers( | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2126 Symbol* ref_name, instanceKlassHandle current) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
2127 Klass* super = current->super(); |
0 | 2128 while (super != NULL) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
2129 if (super->name() == ref_name) { |
0 | 2130 return true; |
2131 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
2132 super = super->super(); |
0 | 2133 } |
2134 return false; | |
2135 } | |
2136 | |
2137 void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs, | |
2138 StackMapFrame* current_frame, | |
2139 constantPoolHandle cp, | |
2140 TRAPS) { | |
1565 | 2141 u2 index = bcs->get_index_u2(); |
6605 | 2142 verify_cp_type(bcs->bci(), index, cp, |
2143 1 << JVM_CONSTANT_Fieldref, CHECK_VERIFY(this)); | |
0 | 2144 |
2145 // Get field name and signature | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2146 Symbol* field_name = cp->name_ref_at(index); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2147 Symbol* field_sig = cp->signature_ref_at(index); |
0 | 2148 |
2149 if (!SignatureVerifier::is_valid_type_signature(field_sig)) { | |
2150 class_format_error( | |
2151 "Invalid signature for field in class %s referenced " | |
2152 "from constant pool index %d", _klass->external_name(), index); | |
2153 return; | |
2154 } | |
2155 | |
2156 // Get referenced class type | |
2157 VerificationType ref_class_type = cp_ref_index_to_type( | |
2158 index, cp, CHECK_VERIFY(this)); | |
2159 if (!ref_class_type.is_object()) { | |
6605 | 2160 /* Unreachable? Class file parser verifies Fieldref contents */ |
2161 verify_error(ErrorContext::bad_type(bcs->bci(), | |
2162 TypeOrigin::cp(index, ref_class_type)), | |
2163 "Expecting reference to class in class %s at constant pool index %d", | |
2164 _klass->external_name(), index); | |
0 | 2165 return; |
2166 } | |
2167 VerificationType target_class_type = ref_class_type; | |
2168 | |
2169 assert(sizeof(VerificationType) == sizeof(uintptr_t), | |
2170 "buffer type must match VerificationType size"); | |
2171 uintptr_t field_type_buffer[2]; | |
2172 VerificationType* field_type = (VerificationType*)field_type_buffer; | |
2173 // If we make a VerificationType[2] array directly, the compiler calls | |
2174 // to the c-runtime library to do the allocation instead of just | |
2175 // stack allocating it. Plus it would run constructors. This shows up | |
2176 // in performance profiles. | |
2177 | |
2178 SignatureStream sig_stream(field_sig, false); | |
2179 VerificationType stack_object_type; | |
2180 int n = change_sig_to_verificationType( | |
2181 &sig_stream, field_type, CHECK_VERIFY(this)); | |
2182 u2 bci = bcs->bci(); | |
2183 bool is_assignable; | |
1565 | 2184 switch (bcs->raw_code()) { |
0 | 2185 case Bytecodes::_getstatic: { |
2186 for (int i = 0; i < n; i++) { | |
2187 current_frame->push_stack(field_type[i], CHECK_VERIFY(this)); | |
2188 } | |
2189 break; | |
2190 } | |
2191 case Bytecodes::_putstatic: { | |
2192 for (int i = n - 1; i >= 0; i--) { | |
2193 current_frame->pop_stack(field_type[i], CHECK_VERIFY(this)); | |
2194 } | |
2195 break; | |
2196 } | |
2197 case Bytecodes::_getfield: { | |
2198 stack_object_type = current_frame->pop_stack( | |
2199 target_class_type, CHECK_VERIFY(this)); | |
2200 for (int i = 0; i < n; i++) { | |
2201 current_frame->push_stack(field_type[i], CHECK_VERIFY(this)); | |
2202 } | |
2203 goto check_protected; | |
2204 } | |
2205 case Bytecodes::_putfield: { | |
2206 for (int i = n - 1; i >= 0; i--) { | |
2207 current_frame->pop_stack(field_type[i], CHECK_VERIFY(this)); | |
2208 } | |
2209 stack_object_type = current_frame->pop_stack(CHECK_VERIFY(this)); | |
2210 | |
2211 // The JVMS 2nd edition allows field initialization before the superclass | |
2212 // initializer, if the field is defined within the current class. | |
2213 fieldDescriptor fd; | |
2214 if (stack_object_type == VerificationType::uninitialized_this_type() && | |
2215 target_class_type.equals(current_type()) && | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2216 _klass->find_local_field(field_name, field_sig, &fd)) { |
0 | 2217 stack_object_type = current_type(); |
2218 } | |
2219 is_assignable = target_class_type.is_assignable_from( | |
18052 | 2220 stack_object_type, this, false, CHECK_VERIFY(this)); |
0 | 2221 if (!is_assignable) { |
6605 | 2222 verify_error(ErrorContext::bad_type(bci, |
2223 current_frame->stack_top_ctx(), | |
2224 TypeOrigin::cp(index, target_class_type)), | |
2225 "Bad type on operand stack in putfield"); | |
0 | 2226 return; |
2227 } | |
2228 } | |
2229 check_protected: { | |
2230 if (_this_type == stack_object_type) | |
2231 break; // stack_object_type must be assignable to _current_class_type | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2232 Symbol* ref_class_name = |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2233 cp->klass_name_at(cp->klass_ref_index_at(index)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2234 if (!name_in_supers(ref_class_name, current_class())) |
0 | 2235 // stack_object_type must be assignable to _current_class_type since: |
2236 // 1. stack_object_type must be assignable to ref_class. | |
2237 // 2. ref_class must be _current_class or a subclass of it. It can't | |
2238 // be a superclass of it. See revised JVMS 5.4.4. | |
2239 break; | |
2240 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
2241 Klass* ref_class_oop = load_class(ref_class_name, CHECK); |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2242 if (is_protected_access(current_class(), ref_class_oop, field_name, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2243 field_sig, false)) { |
0 | 2244 // It's protected access, check if stack object is assignable to |
2245 // current class. | |
2246 is_assignable = current_type().is_assignable_from( | |
18052 | 2247 stack_object_type, this, true, CHECK_VERIFY(this)); |
0 | 2248 if (!is_assignable) { |
6605 | 2249 verify_error(ErrorContext::bad_type(bci, |
2250 current_frame->stack_top_ctx(), | |
2251 TypeOrigin::implicit(current_type())), | |
2252 "Bad access to protected data in getfield"); | |
0 | 2253 return; |
2254 } | |
2255 } | |
2256 break; | |
2257 } | |
2258 default: ShouldNotReachHere(); | |
2259 } | |
2260 } | |
2261 | |
18099
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2262 // Look at the method's handlers. If the bci is in the handler's try block |
22893
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2263 // then check if the handler_pc is already on the stack. If not, push it |
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2264 // unless the handler has already been scanned. |
18099
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2265 void ClassVerifier::push_handlers(ExceptionTable* exhandlers, |
22893
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2266 GrowableArray<u4>* handler_list, |
18099
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2267 GrowableArray<u4>* handler_stack, |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2268 u4 bci) { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2269 int exlength = exhandlers->length(); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2270 for(int x = 0; x < exlength; x++) { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2271 if (bci >= exhandlers->start_pc(x) && bci < exhandlers->end_pc(x)) { |
22893
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2272 u4 exhandler_pc = exhandlers->handler_pc(x); |
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2273 if (!handler_list->contains(exhandler_pc)) { |
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2274 handler_stack->append_if_missing(exhandler_pc); |
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2275 handler_list->append(exhandler_pc); |
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2276 } |
18099
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2277 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2278 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2279 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2280 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2281 // Return TRUE if all code paths starting with start_bc_offset end in |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2282 // bytecode athrow or loop. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2283 bool ClassVerifier::ends_in_athrow(u4 start_bc_offset) { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2284 ResourceMark rm; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2285 // Create bytecode stream. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2286 RawBytecodeStream bcs(method()); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2287 u4 code_length = method()->code_size(); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2288 bcs.set_start(start_bc_offset); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2289 u4 target; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2290 // Create stack for storing bytecode start offsets for if* and *switch. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2291 GrowableArray<u4>* bci_stack = new GrowableArray<u4>(30); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2292 // Create stack for handlers for try blocks containing this handler. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2293 GrowableArray<u4>* handler_stack = new GrowableArray<u4>(30); |
22893
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2294 // Create list of handlers that have been pushed onto the handler_stack |
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2295 // so that handlers embedded inside of their own TRY blocks only get |
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2296 // scanned once. |
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2297 GrowableArray<u4>* handler_list = new GrowableArray<u4>(30); |
18099
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2298 // Create list of visited branch opcodes (goto* and if*). |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2299 GrowableArray<u4>* visited_branches = new GrowableArray<u4>(30); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2300 ExceptionTable exhandlers(_method()); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2301 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2302 while (true) { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2303 if (bcs.is_last_bytecode()) { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2304 // if no more starting offsets to parse or if at the end of the |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2305 // method then return false. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2306 if ((bci_stack->is_empty()) || ((u4)bcs.end_bci() == code_length)) |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2307 return false; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2308 // Pop a bytecode starting offset and scan from there. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2309 bcs.set_start(bci_stack->pop()); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2310 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2311 Bytecodes::Code opcode = bcs.raw_next(); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2312 u4 bci = bcs.bci(); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2313 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2314 // If the bytecode is in a TRY block, push its handlers so they |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2315 // will get parsed. |
22893
695017a614d5
8075118: JVM stuck in infinite loop during verification
hseigel
parents:
22847
diff
changeset
|
2316 push_handlers(&exhandlers, handler_list, handler_stack, bci); |
18099
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2317 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2318 switch (opcode) { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2319 case Bytecodes::_if_icmpeq: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2320 case Bytecodes::_if_icmpne: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2321 case Bytecodes::_if_icmplt: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2322 case Bytecodes::_if_icmpge: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2323 case Bytecodes::_if_icmpgt: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2324 case Bytecodes::_if_icmple: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2325 case Bytecodes::_ifeq: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2326 case Bytecodes::_ifne: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2327 case Bytecodes::_iflt: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2328 case Bytecodes::_ifge: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2329 case Bytecodes::_ifgt: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2330 case Bytecodes::_ifle: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2331 case Bytecodes::_if_acmpeq: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2332 case Bytecodes::_if_acmpne: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2333 case Bytecodes::_ifnull: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2334 case Bytecodes::_ifnonnull: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2335 target = bcs.dest(); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2336 if (visited_branches->contains(bci)) { |
23921 | 2337 if (bci_stack->is_empty()) { |
2338 if (handler_stack->is_empty()) { | |
2339 return true; | |
2340 } else { | |
2341 // Parse the catch handlers for try blocks containing athrow. | |
2342 bcs.set_start(handler_stack->pop()); | |
2343 } | |
2344 } else { | |
2345 // Pop a bytecode starting offset and scan from there. | |
2346 bcs.set_start(bci_stack->pop()); | |
2347 } | |
18099
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2348 } else { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2349 if (target > bci) { // forward branch |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2350 if (target >= code_length) return false; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2351 // Push the branch target onto the stack. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2352 bci_stack->push(target); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2353 // then, scan bytecodes starting with next. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2354 bcs.set_start(bcs.next_bci()); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2355 } else { // backward branch |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2356 // Push bytecode offset following backward branch onto the stack. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2357 bci_stack->push(bcs.next_bci()); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2358 // Check bytecodes starting with branch target. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2359 bcs.set_start(target); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2360 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2361 // Record target so we don't branch here again. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2362 visited_branches->append(bci); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2363 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2364 break; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2365 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2366 case Bytecodes::_goto: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2367 case Bytecodes::_goto_w: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2368 target = (opcode == Bytecodes::_goto ? bcs.dest() : bcs.dest_w()); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2369 if (visited_branches->contains(bci)) { |
23921 | 2370 if (bci_stack->is_empty()) { |
2371 if (handler_stack->is_empty()) { | |
2372 return true; | |
2373 } else { | |
2374 // Parse the catch handlers for try blocks containing athrow. | |
2375 bcs.set_start(handler_stack->pop()); | |
2376 } | |
2377 } else { | |
2378 // Been here before, pop new starting offset from stack. | |
2379 bcs.set_start(bci_stack->pop()); | |
2380 } | |
18099
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2381 } else { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2382 if (target >= code_length) return false; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2383 // Continue scanning from the target onward. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2384 bcs.set_start(target); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2385 // Record target so we don't branch here again. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2386 visited_branches->append(bci); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2387 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2388 break; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2389 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2390 // Check that all switch alternatives end in 'athrow' bytecodes. Since it |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2391 // is difficult to determine where each switch alternative ends, parse |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2392 // each switch alternative until either hit a 'return', 'athrow', or reach |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2393 // the end of the method's bytecodes. This is gross but should be okay |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2394 // because: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2395 // 1. tableswitch and lookupswitch byte codes in handlers for ctor explicit |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2396 // constructor invocations should be rare. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2397 // 2. if each switch alternative ends in an athrow then the parsing should be |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2398 // short. If there is no athrow then it is bogus code, anyway. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2399 case Bytecodes::_lookupswitch: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2400 case Bytecodes::_tableswitch: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2401 { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2402 address aligned_bcp = (address) round_to((intptr_t)(bcs.bcp() + 1), jintSize); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2403 u4 default_offset = Bytes::get_Java_u4(aligned_bcp) + bci; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2404 int keys, delta; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2405 if (opcode == Bytecodes::_tableswitch) { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2406 jint low = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2407 jint high = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2408 // This is invalid, but let the regular bytecode verifier |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2409 // report this because the user will get a better error message. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2410 if (low > high) return true; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2411 keys = high - low + 1; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2412 delta = 1; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2413 } else { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2414 keys = (int)Bytes::get_Java_u4(aligned_bcp + jintSize); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2415 delta = 2; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2416 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2417 // Invalid, let the regular bytecode verifier deal with it. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2418 if (keys < 0) return true; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2419 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2420 // Push the offset of the next bytecode onto the stack. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2421 bci_stack->push(bcs.next_bci()); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2422 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2423 // Push the switch alternatives onto the stack. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2424 for (int i = 0; i < keys; i++) { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2425 u4 target = bci + (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2426 if (target > code_length) return false; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2427 bci_stack->push(target); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2428 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2429 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2430 // Start bytecode parsing for the switch at the default alternative. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2431 if (default_offset > code_length) return false; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2432 bcs.set_start(default_offset); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2433 break; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2434 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2435 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2436 case Bytecodes::_return: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2437 return false; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2438 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2439 case Bytecodes::_athrow: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2440 { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2441 if (bci_stack->is_empty()) { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2442 if (handler_stack->is_empty()) { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2443 return true; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2444 } else { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2445 // Parse the catch handlers for try blocks containing athrow. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2446 bcs.set_start(handler_stack->pop()); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2447 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2448 } else { |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2449 // Pop a bytecode offset and starting scanning from there. |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2450 bcs.set_start(bci_stack->pop()); |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2451 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2452 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2453 break; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2454 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2455 default: |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2456 ; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2457 } // end switch |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2458 } // end while loop |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2459 |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2460 return false; |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2461 } |
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2462 |
0 | 2463 void ClassVerifier::verify_invoke_init( |
6605 | 2464 RawBytecodeStream* bcs, u2 ref_class_index, VerificationType ref_class_type, |
20759
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2465 StackMapFrame* current_frame, u4 code_length, bool in_try_block, |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2466 bool *this_uninit, constantPoolHandle cp, StackMapTable* stackmap_table, |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2467 TRAPS) { |
0 | 2468 u2 bci = bcs->bci(); |
2469 VerificationType type = current_frame->pop_stack( | |
2470 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
2471 if (type == VerificationType::uninitialized_this_type()) { | |
6155 | 2472 // The method must be an <init> method of this class or its superclass |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
2473 Klass* superk = current_class()->super(); |
1677 | 2474 if (ref_class_type.name() != current_class()->name() && |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
2475 ref_class_type.name() != superk->name()) { |
6605 | 2476 verify_error(ErrorContext::bad_type(bci, |
2477 TypeOrigin::implicit(ref_class_type), | |
2478 TypeOrigin::implicit(current_type())), | |
2479 "Bad <init> method call"); | |
0 | 2480 return; |
2481 } | |
17573 | 2482 |
20759
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2483 // If this invokespecial call is done from inside of a TRY block then make |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2484 // sure that all catch clause paths end in a throw. Otherwise, this can |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2485 // result in returning an incomplete object. |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2486 if (in_try_block) { |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2487 ExceptionTable exhandlers(_method()); |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2488 int exlength = exhandlers.length(); |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2489 for(int i = 0; i < exlength; i++) { |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2490 u2 start_pc = exhandlers.start_pc(i); |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2491 u2 end_pc = exhandlers.end_pc(i); |
18099
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2492 |
20759
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2493 if (bci >= start_pc && bci < end_pc) { |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2494 if (!ends_in_athrow(exhandlers.handler_pc(i))) { |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2495 verify_error(ErrorContext::bad_code(bci), |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2496 "Bad <init> method call from after the start of a try block"); |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2497 return; |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2498 } else if (VerboseVerification) { |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2499 ResourceMark rm; |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2500 tty->print_cr( |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2501 "Survived call to ends_in_athrow(): %s", |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2502 current_class()->name()->as_C_string()); |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2503 } |
18099
077483254bf6
8050485: super() in a try block in a ctor causes VerifyError
hseigel
parents:
18094
diff
changeset
|
2504 } |
17573 | 2505 } |
20759
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2506 |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2507 // Check the exception handler target stackmaps with the locals from the |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2508 // incoming stackmap (before initialize_object() changes them to outgoing |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2509 // state). |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2510 verify_exception_handler_targets(bci, true, current_frame, |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2511 stackmap_table, CHECK_VERIFY(this)); |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2512 } // in_try_block |
17573 | 2513 |
0 | 2514 current_frame->initialize_object(type, current_type()); |
2515 *this_uninit = true; | |
2516 } else if (type.is_uninitialized()) { | |
2517 u2 new_offset = type.bci(); | |
2518 address new_bcp = bcs->bcp() - bci + new_offset; | |
2519 if (new_offset > (code_length - 3) || (*new_bcp) != Bytecodes::_new) { | |
6605 | 2520 /* Unreachable? Stack map parsing ensures valid type and new |
2521 * instructions have a valid BCI. */ | |
2522 verify_error(ErrorContext::bad_code(new_offset), | |
2523 "Expecting new instruction"); | |
0 | 2524 return; |
2525 } | |
2526 u2 new_class_index = Bytes::get_Java_u2(new_bcp + 1); | |
6605 | 2527 verify_cp_class_type(bci, new_class_index, cp, CHECK_VERIFY(this)); |
0 | 2528 |
2529 // The method must be an <init> method of the indicated class | |
2530 VerificationType new_class_type = cp_index_to_type( | |
2531 new_class_index, cp, CHECK_VERIFY(this)); | |
2532 if (!new_class_type.equals(ref_class_type)) { | |
6605 | 2533 verify_error(ErrorContext::bad_type(bci, |
2534 TypeOrigin::cp(new_class_index, new_class_type), | |
2535 TypeOrigin::cp(ref_class_index, ref_class_type)), | |
2536 "Call to wrong <init> method"); | |
0 | 2537 return; |
2538 } | |
2539 // According to the VM spec, if the referent class is a superclass of the | |
2540 // current class, and is in a different runtime package, and the method is | |
2541 // protected, then the objectref must be the current class or a subclass | |
2542 // of the current class. | |
2543 VerificationType objectref_type = new_class_type; | |
2544 if (name_in_supers(ref_class_type.name(), current_class())) { | |
22847
ecdf1e03db40
8064335: Null pointer dereference in hotspot/src/share/vm/classfile/verifier.cpp
hseigel
parents:
20762
diff
changeset
|
2545 Klass* ref_klass = load_class(ref_class_type.name(), CHECK); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
2546 Method* m = InstanceKlass::cast(ref_klass)->uncached_lookup_method( |
0 | 2547 vmSymbols::object_initializer_name(), |
18007 | 2548 cp->signature_ref_at(bcs->get_index_u2()), Klass::normal); |
17593
e6b738407432
8043454: Test case for 8037157 should not throw a VerifyError
hseigel
parents:
17583
diff
changeset
|
2549 // Do nothing if method is not found. Let resolution detect the error. |
e6b738407432
8043454: Test case for 8037157 should not throw a VerifyError
hseigel
parents:
17583
diff
changeset
|
2550 if (m != NULL) { |
e6b738407432
8043454: Test case for 8037157 should not throw a VerifyError
hseigel
parents:
17583
diff
changeset
|
2551 instanceKlassHandle mh(THREAD, m->method_holder()); |
e6b738407432
8043454: Test case for 8037157 should not throw a VerifyError
hseigel
parents:
17583
diff
changeset
|
2552 if (m->is_protected() && !mh->is_same_class_package(_klass())) { |
e6b738407432
8043454: Test case for 8037157 should not throw a VerifyError
hseigel
parents:
17583
diff
changeset
|
2553 bool assignable = current_type().is_assignable_from( |
18060 | 2554 objectref_type, this, true, CHECK_VERIFY(this)); |
17593
e6b738407432
8043454: Test case for 8037157 should not throw a VerifyError
hseigel
parents:
17583
diff
changeset
|
2555 if (!assignable) { |
e6b738407432
8043454: Test case for 8037157 should not throw a VerifyError
hseigel
parents:
17583
diff
changeset
|
2556 verify_error(ErrorContext::bad_type(bci, |
e6b738407432
8043454: Test case for 8037157 should not throw a VerifyError
hseigel
parents:
17583
diff
changeset
|
2557 TypeOrigin::cp(new_class_index, objectref_type), |
e6b738407432
8043454: Test case for 8037157 should not throw a VerifyError
hseigel
parents:
17583
diff
changeset
|
2558 TypeOrigin::implicit(current_type())), |
e6b738407432
8043454: Test case for 8037157 should not throw a VerifyError
hseigel
parents:
17583
diff
changeset
|
2559 "Bad access to protected <init> method"); |
e6b738407432
8043454: Test case for 8037157 should not throw a VerifyError
hseigel
parents:
17583
diff
changeset
|
2560 return; |
e6b738407432
8043454: Test case for 8037157 should not throw a VerifyError
hseigel
parents:
17583
diff
changeset
|
2561 } |
0 | 2562 } |
2563 } | |
2564 } | |
20759
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2565 // Check the exception handler target stackmaps with the locals from the |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2566 // incoming stackmap (before initialize_object() changes them to outgoing |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2567 // state). |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2568 if (in_try_block) { |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2569 verify_exception_handler_targets(bci, *this_uninit, current_frame, |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2570 stackmap_table, CHECK_VERIFY(this)); |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2571 } |
0 | 2572 current_frame->initialize_object(type, new_class_type); |
2573 } else { | |
6605 | 2574 verify_error(ErrorContext::bad_type(bci, current_frame->stack_top_ctx()), |
2575 "Bad operand type when invoking <init>"); | |
0 | 2576 return; |
2577 } | |
2578 } | |
2579 | |
13401
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2580 bool ClassVerifier::is_same_or_direct_interface( |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2581 instanceKlassHandle klass, |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2582 VerificationType klass_type, |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2583 VerificationType ref_class_type) { |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2584 if (ref_class_type.equals(klass_type)) return true; |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2585 Array<Klass*>* local_interfaces = klass->local_interfaces(); |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2586 if (local_interfaces != NULL) { |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2587 for (int x = 0; x < local_interfaces->length(); x++) { |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2588 Klass* k = local_interfaces->at(x); |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2589 assert (k != NULL && k->is_interface(), "invalid interface"); |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2590 if (ref_class_type.equals(VerificationType::reference_type(k->name()))) { |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2591 return true; |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2592 } |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2593 } |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2594 } |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2595 return false; |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2596 } |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2597 |
0 | 2598 void ClassVerifier::verify_invoke_instructions( |
2599 RawBytecodeStream* bcs, u4 code_length, StackMapFrame* current_frame, | |
20759
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2600 bool in_try_block, bool *this_uninit, VerificationType return_type, |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2601 constantPoolHandle cp, StackMapTable* stackmap_table, TRAPS) { |
0 | 2602 // Make sure the constant pool item is the right type |
1565 | 2603 u2 index = bcs->get_index_u2(); |
2604 Bytecodes::Code opcode = bcs->raw_code(); | |
6934 | 2605 unsigned int types; |
2606 switch (opcode) { | |
2607 case Bytecodes::_invokeinterface: | |
2608 types = 1 << JVM_CONSTANT_InterfaceMethodref; | |
2609 break; | |
2610 case Bytecodes::_invokedynamic: | |
2611 types = 1 << JVM_CONSTANT_InvokeDynamic; | |
2612 break; | |
2613 case Bytecodes::_invokespecial: | |
9066
09b0d3e9ba6c
8011671: JCK tests on static interface methods fail under b84: Illegal type at constant pool entry 5
bharadwaj
parents:
8819
diff
changeset
|
2614 case Bytecodes::_invokestatic: |
09b0d3e9ba6c
8011671: JCK tests on static interface methods fail under b84: Illegal type at constant pool entry 5
bharadwaj
parents:
8819
diff
changeset
|
2615 types = (_klass->major_version() < STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION) ? |
09b0d3e9ba6c
8011671: JCK tests on static interface methods fail under b84: Illegal type at constant pool entry 5
bharadwaj
parents:
8819
diff
changeset
|
2616 (1 << JVM_CONSTANT_Methodref) : |
09b0d3e9ba6c
8011671: JCK tests on static interface methods fail under b84: Illegal type at constant pool entry 5
bharadwaj
parents:
8819
diff
changeset
|
2617 ((1 << JVM_CONSTANT_InterfaceMethodref) | (1 << JVM_CONSTANT_Methodref)); |
09b0d3e9ba6c
8011671: JCK tests on static interface methods fail under b84: Illegal type at constant pool entry 5
bharadwaj
parents:
8819
diff
changeset
|
2618 break; |
6934 | 2619 default: |
2620 types = 1 << JVM_CONSTANT_Methodref; | |
2621 } | |
6605 | 2622 verify_cp_type(bcs->bci(), index, cp, types, CHECK_VERIFY(this)); |
0 | 2623 |
2624 // Get method name and signature | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2625 Symbol* method_name = cp->name_ref_at(index); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2626 Symbol* method_sig = cp->signature_ref_at(index); |
0 | 2627 |
2628 if (!SignatureVerifier::is_valid_method_signature(method_sig)) { | |
2629 class_format_error( | |
2630 "Invalid method signature in class %s referenced " | |
2631 "from constant pool index %d", _klass->external_name(), index); | |
2632 return; | |
2633 } | |
2634 | |
2635 // Get referenced class type | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2636 VerificationType ref_class_type; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2637 if (opcode == Bytecodes::_invokedynamic) { |
1602 | 2638 if (!EnableInvokeDynamic || |
2639 _klass->major_version() < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) { | |
17937
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
2640 if (!EnableInvokeDynamic) { |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
2641 class_format_error("invokedynamic instructions not enabled in this JVM"); |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
2642 } else { |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
2643 class_format_error("invokedynamic instructions not supported by this class file version (%d), class %s", |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
2644 _klass->major_version(), _klass->external_name()); |
78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
17889
diff
changeset
|
2645 } |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2646 return; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2647 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2648 } else { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2649 ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this)); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2650 } |
0 | 2651 |
2652 // For a small signature length, we just allocate 128 bytes instead | |
2653 // of parsing the signature once to find its size. | |
2654 // -3 is for '(', ')' and return descriptor; multiply by 2 is for | |
2655 // longs/doubles to be consertive. | |
2656 assert(sizeof(VerificationType) == sizeof(uintptr_t), | |
2657 "buffer type must match VerificationType size"); | |
2658 uintptr_t on_stack_sig_types_buffer[128]; | |
2659 // If we make a VerificationType[128] array directly, the compiler calls | |
2660 // to the c-runtime library to do the allocation instead of just | |
2661 // stack allocating it. Plus it would run constructors. This shows up | |
2662 // in performance profiles. | |
2663 | |
2664 VerificationType* sig_types; | |
2665 int size = (method_sig->utf8_length() - 3) * 2; | |
2666 if (size > 128) { | |
2667 // Long and double occupies two slots here. | |
2668 ArgumentSizeComputer size_it(method_sig); | |
2669 size = size_it.size(); | |
2670 sig_types = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, VerificationType, size); | |
2671 } else{ | |
2672 sig_types = (VerificationType*)on_stack_sig_types_buffer; | |
2673 } | |
2674 SignatureStream sig_stream(method_sig); | |
2675 int sig_i = 0; | |
2676 while (!sig_stream.at_return_type()) { | |
2677 sig_i += change_sig_to_verificationType( | |
2678 &sig_stream, &sig_types[sig_i], CHECK_VERIFY(this)); | |
2679 sig_stream.next(); | |
2680 } | |
2681 int nargs = sig_i; | |
2682 | |
2683 #ifdef ASSERT | |
2684 { | |
2685 ArgumentSizeComputer size_it(method_sig); | |
2686 assert(nargs == size_it.size(), "Argument sizes do not match"); | |
2687 assert(nargs <= (method_sig->utf8_length() - 3) * 2, "estimate of max size isn't conservative enough"); | |
2688 } | |
2689 #endif | |
2690 | |
2691 // Check instruction operands | |
2692 u2 bci = bcs->bci(); | |
2693 if (opcode == Bytecodes::_invokeinterface) { | |
2694 address bcp = bcs->bcp(); | |
2695 // 4905268: count operand in invokeinterface should be nargs+1, not nargs. | |
2696 // JSR202 spec: The count operand of an invokeinterface instruction is valid if it is | |
2697 // the difference between the size of the operand stack before and after the instruction | |
2698 // executes. | |
2699 if (*(bcp+3) != (nargs+1)) { | |
6605 | 2700 verify_error(ErrorContext::bad_code(bci), |
2701 "Inconsistent args count operand in invokeinterface"); | |
0 | 2702 return; |
2703 } | |
2704 if (*(bcp+4) != 0) { | |
6605 | 2705 verify_error(ErrorContext::bad_code(bci), |
2706 "Fourth operand byte of invokeinterface must be zero"); | |
0 | 2707 return; |
2708 } | |
2709 } | |
2710 | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2711 if (opcode == Bytecodes::_invokedynamic) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2712 address bcp = bcs->bcp(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2713 if (*(bcp+3) != 0 || *(bcp+4) != 0) { |
6605 | 2714 verify_error(ErrorContext::bad_code(bci), |
2715 "Third and fourth operand bytes of invokedynamic must be zero"); | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2716 return; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2717 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2718 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2719 |
0 | 2720 if (method_name->byte_at(0) == '<') { |
2721 // Make sure <init> can only be invoked by invokespecial | |
2722 if (opcode != Bytecodes::_invokespecial || | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2723 method_name != vmSymbols::object_initializer_name()) { |
6605 | 2724 verify_error(ErrorContext::bad_code(bci), |
2725 "Illegal call to internal method"); | |
0 | 2726 return; |
2727 } | |
2728 } else if (opcode == Bytecodes::_invokespecial | |
13401
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2729 && !is_same_or_direct_interface(current_class(), current_type(), ref_class_type) |
0 | 2730 && !ref_class_type.equals(VerificationType::reference_type( |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
2731 current_class()->super()->name()))) { |
12891
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2732 bool subtype = false; |
13401
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2733 bool have_imr_indirect = cp->tag_at(index).value() == JVM_CONSTANT_InterfaceMethodref; |
12891
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2734 if (!current_class()->is_anonymous()) { |
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2735 subtype = ref_class_type.is_assignable_from( |
18052 | 2736 current_type(), this, false, CHECK_VERIFY(this)); |
12891
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2737 } else { |
13401
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2738 VerificationType host_klass_type = |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2739 VerificationType::reference_type(current_class()->host_klass()->name()); |
18052 | 2740 subtype = ref_class_type.is_assignable_from(host_klass_type, this, false, CHECK_VERIFY(this)); |
13401
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2741 |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2742 // If invokespecial of IMR, need to recheck for same or |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2743 // direct interface relative to the host class |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2744 have_imr_indirect = (have_imr_indirect && |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2745 !is_same_or_direct_interface( |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2746 InstanceKlass::cast(current_class()->host_klass()), |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2747 host_klass_type, ref_class_type)); |
12891
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2748 } |
0 | 2749 if (!subtype) { |
12891
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2750 verify_error(ErrorContext::bad_code(bci), |
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2751 "Bad invokespecial instruction: " |
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2752 "current class isn't assignable to reference class."); |
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2753 return; |
13401
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2754 } else if (have_imr_indirect) { |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2755 verify_error(ErrorContext::bad_code(bci), |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2756 "Bad invokespecial instruction: " |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2757 "interface method reference is in an indirect superinterface."); |
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2758 return; |
0 | 2759 } |
13401
22eaa15b7960
8026065: InterfaceMethodref for invokespecial must name a direct superinterface
hseigel
parents:
13385
diff
changeset
|
2760 |
0 | 2761 } |
2762 // Match method descriptor with operand stack | |
2763 for (int i = nargs - 1; i >= 0; i--) { // Run backwards | |
2764 current_frame->pop_stack(sig_types[i], CHECK_VERIFY(this)); | |
2765 } | |
2766 // Check objectref on operand stack | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2767 if (opcode != Bytecodes::_invokestatic && |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
431
diff
changeset
|
2768 opcode != Bytecodes::_invokedynamic) { |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2769 if (method_name == vmSymbols::object_initializer_name()) { // <init> method |
6605 | 2770 verify_invoke_init(bcs, index, ref_class_type, current_frame, |
20759
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2771 code_length, in_try_block, this_uninit, cp, stackmap_table, |
4b26b980ec8d
8058982: Better verification of an exceptional invokespecial
hseigel
parents:
20742
diff
changeset
|
2772 CHECK_VERIFY(this)); |
0 | 2773 } else { // other methods |
2774 // Ensures that target class is assignable to method class. | |
2775 if (opcode == Bytecodes::_invokespecial) { | |
12827
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2776 if (!current_class()->is_anonymous()) { |
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2777 current_frame->pop_stack(current_type(), CHECK_VERIFY(this)); |
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2778 } else { |
12891
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2779 // anonymous class invokespecial calls: check if the |
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2780 // objectref is a subtype of the host_klass of the current class |
12827
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2781 // to allow an anonymous class to reference methods in the host_klass |
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2782 VerificationType top = current_frame->pop_stack(CHECK_VERIFY(this)); |
12891
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2783 VerificationType hosttype = |
7114c4597ae3
8026365: NoClassDefinitionFound for anonymous class invokespecial.
acorn
parents:
12827
diff
changeset
|
2784 VerificationType::reference_type(current_class()->host_klass()->name()); |
18052 | 2785 bool subtype = hosttype.is_assignable_from(top, this, false, CHECK_VERIFY(this)); |
12827
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2786 if (!subtype) { |
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2787 verify_error( ErrorContext::bad_type(current_frame->offset(), |
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2788 current_frame->stack_top_ctx(), |
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2789 TypeOrigin::implicit(top)), |
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2790 "Bad type on operand stack"); |
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2791 return; |
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2792 } |
c72075c2883e
8026022: Verifier: allow anon classes to invokespecial host class/intf methods.
acorn
parents:
12154
diff
changeset
|
2793 } |
0 | 2794 } else if (opcode == Bytecodes::_invokevirtual) { |
2795 VerificationType stack_object_type = | |
2796 current_frame->pop_stack(ref_class_type, CHECK_VERIFY(this)); | |
2797 if (current_type() != stack_object_type) { | |
2798 assert(cp->cache() == NULL, "not rewritten yet"); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2799 Symbol* ref_class_name = |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2800 cp->klass_name_at(cp->klass_ref_index_at(index)); |
0 | 2801 // See the comments in verify_field_instructions() for |
2802 // the rationale behind this. | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2803 if (name_in_supers(ref_class_name, current_class())) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6608
diff
changeset
|
2804 Klass* ref_class = load_class(ref_class_name, CHECK); |
0 | 2805 if (is_protected_access( |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2806 _klass, ref_class, method_name, method_sig, true)) { |
0 | 2807 // It's protected access, check if stack object is |
2808 // assignable to current class. | |
2809 bool is_assignable = current_type().is_assignable_from( | |
18052 | 2810 stack_object_type, this, true, CHECK_VERIFY(this)); |
0 | 2811 if (!is_assignable) { |
2812 if (ref_class_type.name() == vmSymbols::java_lang_Object() | |
2813 && stack_object_type.is_array() | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2814 && method_name == vmSymbols::clone_name()) { |
0 | 2815 // Special case: arrays pretend to implement public Object |
2816 // clone(). | |
2817 } else { | |
6605 | 2818 verify_error(ErrorContext::bad_type(bci, |
2819 current_frame->stack_top_ctx(), | |
2820 TypeOrigin::implicit(current_type())), | |
2821 "Bad access to protected data in invokevirtual"); | |
0 | 2822 return; |
2823 } | |
2824 } | |
2825 } | |
2826 } | |
2827 } | |
2828 } else { | |
2829 assert(opcode == Bytecodes::_invokeinterface, "Unexpected opcode encountered"); | |
2830 current_frame->pop_stack(ref_class_type, CHECK_VERIFY(this)); | |
2831 } | |
2832 } | |
2833 } | |
2834 // Push the result type. | |
2835 if (sig_stream.type() != T_VOID) { | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2836 if (method_name == vmSymbols::object_initializer_name()) { |
0 | 2837 // <init> method must have a void return type |
6605 | 2838 /* Unreachable? Class file parser verifies that methods with '<' have |
2839 * void return */ | |
2840 verify_error(ErrorContext::bad_code(bci), | |
2841 "Return type must be void in <init> method"); | |
0 | 2842 return; |
2843 } | |
2844 VerificationType return_type[2]; | |
2845 int n = change_sig_to_verificationType( | |
2846 &sig_stream, return_type, CHECK_VERIFY(this)); | |
2847 for (int i = 0; i < n; i++) { | |
2848 current_frame->push_stack(return_type[i], CHECK_VERIFY(this)); // push types backwards | |
2849 } | |
2850 } | |
2851 } | |
2852 | |
2853 VerificationType ClassVerifier::get_newarray_type( | |
2854 u2 index, u2 bci, TRAPS) { | |
2855 const char* from_bt[] = { | |
2856 NULL, NULL, NULL, NULL, "[Z", "[C", "[F", "[D", "[B", "[S", "[I", "[J", | |
2857 }; | |
2858 if (index < T_BOOLEAN || index > T_LONG) { | |
6605 | 2859 verify_error(ErrorContext::bad_code(bci), "Illegal newarray instruction"); |
0 | 2860 return VerificationType::bogus_type(); |
2861 } | |
2862 | |
2863 // from_bt[index] contains the array signature which has a length of 2 | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2864 Symbol* sig = create_temporary_symbol( |
0 | 2865 from_bt[index], 2, CHECK_(VerificationType::bogus_type())); |
2866 return VerificationType::reference_type(sig); | |
2867 } | |
2868 | |
2869 void ClassVerifier::verify_anewarray( | |
6605 | 2870 u2 bci, u2 index, constantPoolHandle cp, |
2871 StackMapFrame* current_frame, TRAPS) { | |
2872 verify_cp_class_type(bci, index, cp, CHECK_VERIFY(this)); | |
0 | 2873 current_frame->pop_stack( |
2874 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
2875 | |
2876 VerificationType component_type = | |
2877 cp_index_to_type(index, cp, CHECK_VERIFY(this)); | |
2878 int length; | |
2879 char* arr_sig_str; | |
2880 if (component_type.is_array()) { // it's an array | |
2881 const char* component_name = component_type.name()->as_utf8(); | |
2882 // add one dimension to component | |
2883 length = (int)strlen(component_name) + 1; | |
2884 arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length); | |
2885 arr_sig_str[0] = '['; | |
2886 strncpy(&arr_sig_str[1], component_name, length - 1); | |
2887 } else { // it's an object or interface | |
2888 const char* component_name = component_type.name()->as_utf8(); | |
2889 // add one dimension to component with 'L' prepended and ';' postpended. | |
2890 length = (int)strlen(component_name) + 3; | |
2891 arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length); | |
2892 arr_sig_str[0] = '['; | |
2893 arr_sig_str[1] = 'L'; | |
2894 strncpy(&arr_sig_str[2], component_name, length - 2); | |
2895 arr_sig_str[length - 1] = ';'; | |
2896 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
2897 Symbol* arr_sig = create_temporary_symbol( |
0 | 2898 arr_sig_str, length, CHECK_VERIFY(this)); |
2899 VerificationType new_array_type = VerificationType::reference_type(arr_sig); | |
2900 current_frame->push_stack(new_array_type, CHECK_VERIFY(this)); | |
2901 } | |
2902 | |
2903 void ClassVerifier::verify_iload(u2 index, StackMapFrame* current_frame, TRAPS) { | |
2904 current_frame->get_local( | |
2905 index, VerificationType::integer_type(), CHECK_VERIFY(this)); | |
2906 current_frame->push_stack( | |
2907 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
2908 } | |
2909 | |
2910 void ClassVerifier::verify_lload(u2 index, StackMapFrame* current_frame, TRAPS) { | |
2911 current_frame->get_local_2( | |
2912 index, VerificationType::long_type(), | |
2913 VerificationType::long2_type(), CHECK_VERIFY(this)); | |
2914 current_frame->push_stack_2( | |
2915 VerificationType::long_type(), | |
2916 VerificationType::long2_type(), CHECK_VERIFY(this)); | |
2917 } | |
2918 | |
2919 void ClassVerifier::verify_fload(u2 index, StackMapFrame* current_frame, TRAPS) { | |
2920 current_frame->get_local( | |
2921 index, VerificationType::float_type(), CHECK_VERIFY(this)); | |
2922 current_frame->push_stack( | |
2923 VerificationType::float_type(), CHECK_VERIFY(this)); | |
2924 } | |
2925 | |
2926 void ClassVerifier::verify_dload(u2 index, StackMapFrame* current_frame, TRAPS) { | |
2927 current_frame->get_local_2( | |
2928 index, VerificationType::double_type(), | |
2929 VerificationType::double2_type(), CHECK_VERIFY(this)); | |
2930 current_frame->push_stack_2( | |
2931 VerificationType::double_type(), | |
2932 VerificationType::double2_type(), CHECK_VERIFY(this)); | |
2933 } | |
2934 | |
2935 void ClassVerifier::verify_aload(u2 index, StackMapFrame* current_frame, TRAPS) { | |
2936 VerificationType type = current_frame->get_local( | |
2937 index, VerificationType::reference_check(), CHECK_VERIFY(this)); | |
2938 current_frame->push_stack(type, CHECK_VERIFY(this)); | |
2939 } | |
2940 | |
2941 void ClassVerifier::verify_istore(u2 index, StackMapFrame* current_frame, TRAPS) { | |
2942 current_frame->pop_stack( | |
2943 VerificationType::integer_type(), CHECK_VERIFY(this)); | |
2944 current_frame->set_local( | |
2945 index, VerificationType::integer_type(), CHECK_VERIFY(this)); | |
2946 } | |
2947 | |
2948 void ClassVerifier::verify_lstore(u2 index, StackMapFrame* current_frame, TRAPS) { | |
2949 current_frame->pop_stack_2( | |
2950 VerificationType::long2_type(), | |
2951 VerificationType::long_type(), CHECK_VERIFY(this)); | |
2952 current_frame->set_local_2( | |
2953 index, VerificationType::long_type(), | |
2954 VerificationType::long2_type(), CHECK_VERIFY(this)); | |
2955 } | |
2956 | |
2957 void ClassVerifier::verify_fstore(u2 index, StackMapFrame* current_frame, TRAPS) { | |
2958 current_frame->pop_stack(VerificationType::float_type(), CHECK_VERIFY(this)); | |
2959 current_frame->set_local( | |
2960 index, VerificationType::float_type(), CHECK_VERIFY(this)); | |
2961 } | |
2962 | |
2963 void ClassVerifier::verify_dstore(u2 index, StackMapFrame* current_frame, TRAPS) { | |
2964 current_frame->pop_stack_2( | |
2965 VerificationType::double2_type(), | |
2966 VerificationType::double_type(), CHECK_VERIFY(this)); | |
2967 current_frame->set_local_2( | |
2968 index, VerificationType::double_type(), | |
2969 VerificationType::double2_type(), CHECK_VERIFY(this)); | |
2970 } | |
2971 | |
2972 void ClassVerifier::verify_astore(u2 index, StackMapFrame* current_frame, TRAPS) { | |
2973 VerificationType type = current_frame->pop_stack( | |
2974 VerificationType::reference_check(), CHECK_VERIFY(this)); | |
2975 current_frame->set_local(index, type, CHECK_VERIFY(this)); | |
2976 } | |
2977 | |
2978 void ClassVerifier::verify_iinc(u2 index, StackMapFrame* current_frame, TRAPS) { | |
2979 VerificationType type = current_frame->get_local( | |
2980 index, VerificationType::integer_type(), CHECK_VERIFY(this)); | |
2981 current_frame->set_local(index, type, CHECK_VERIFY(this)); | |
2982 } | |
2983 | |
2984 void ClassVerifier::verify_return_value( | |
6605 | 2985 VerificationType return_type, VerificationType type, u2 bci, |
2986 StackMapFrame* current_frame, TRAPS) { | |
0 | 2987 if (return_type == VerificationType::bogus_type()) { |
6605 | 2988 verify_error(ErrorContext::bad_type(bci, |
2989 current_frame->stack_top_ctx(), TypeOrigin::signature(return_type)), | |
2990 "Method expects a return value"); | |
0 | 2991 return; |
2992 } | |
18052 | 2993 bool match = return_type.is_assignable_from(type, this, false, CHECK_VERIFY(this)); |
0 | 2994 if (!match) { |
6605 | 2995 verify_error(ErrorContext::bad_type(bci, |
2996 current_frame->stack_top_ctx(), TypeOrigin::signature(return_type)), | |
2997 "Bad return type"); | |
0 | 2998 return; |
2999 } | |
3000 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3001 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3002 // The verifier creates symbols which are substrings of Symbols. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3003 // These are stored in the verifier until the end of verification so that |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3004 // they can be reference counted. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3005 Symbol* ClassVerifier::create_temporary_symbol(const Symbol *s, int begin, |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3006 int end, TRAPS) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3007 Symbol* sym = SymbolTable::new_symbol(s, begin, end, CHECK_NULL); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3008 _symbols->push(sym); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3009 return sym; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3010 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3011 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3012 Symbol* ClassVerifier::create_temporary_symbol(const char *s, int length, TRAPS) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3013 Symbol* sym = SymbolTable::new_symbol(s, length, CHECK_NULL); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3014 _symbols->push(sym); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3015 return sym; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1980
diff
changeset
|
3016 } |