Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/verifier.cpp @ 14422:2b8e28fdf503
Merge
author | kvn |
---|---|
date | Tue, 05 Nov 2013 17:38:04 -0800 |
parents | 7114c4597ae3 |
children | cdf20166ec45 |
comparison
equal
deleted
inserted
replaced
14421:3068270ba476 | 14422:2b8e28fdf503 |
---|---|
186 } | 186 } |
187 | 187 |
188 bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class) { | 188 bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class) { |
189 Symbol* name = klass->name(); | 189 Symbol* name = klass->name(); |
190 Klass* refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass(); | 190 Klass* refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass(); |
191 Klass* lambda_magic_klass = SystemDictionary::lambda_MagicLambdaImpl_klass(); | |
192 | |
193 bool is_reflect = refl_magic_klass != NULL && klass->is_subtype_of(refl_magic_klass); | |
194 bool is_lambda = lambda_magic_klass != NULL && klass->is_subtype_of(lambda_magic_klass); | |
191 | 195 |
192 return (should_verify_for(klass->class_loader(), should_verify_class) && | 196 return (should_verify_for(klass->class_loader(), should_verify_class) && |
193 // return if the class is a bootstrapping class | 197 // return if the class is a bootstrapping class |
194 // or defineClass specified not to verify by default (flags override passed arg) | 198 // or defineClass specified not to verify by default (flags override passed arg) |
195 // We need to skip the following four for bootstraping | 199 // We need to skip the following four for bootstraping |
208 // dynamically-generated bytecodes associated with the 1.4 | 212 // dynamically-generated bytecodes associated with the 1.4 |
209 // reflection implementation, not just those associated with | 213 // reflection implementation, not just those associated with |
210 // sun/reflect/SerializationConstructorAccessor. | 214 // sun/reflect/SerializationConstructorAccessor. |
211 // NOTE: this is called too early in the bootstrapping process to be | 215 // NOTE: this is called too early in the bootstrapping process to be |
212 // guarded by Universe::is_gte_jdk14x_version()/UseNewReflection. | 216 // guarded by Universe::is_gte_jdk14x_version()/UseNewReflection. |
213 (refl_magic_klass == NULL || | 217 // Also for lambda generated code, gte jdk8 |
214 !klass->is_subtype_of(refl_magic_klass) || | 218 (!is_reflect || VerifyReflectionBytecodes) && |
215 VerifyReflectionBytecodes) | 219 (!is_lambda || VerifyLambdaBytecodes) |
216 ); | 220 ); |
217 } | 221 } |
218 | 222 |
219 Symbol* Verifier::inference_verify( | 223 Symbol* Verifier::inference_verify( |
220 instanceKlassHandle klass, char* message, size_t message_len, TRAPS) { | 224 instanceKlassHandle klass, char* message, size_t message_len, TRAPS) { |
2316 break; | 2320 break; |
2317 case Bytecodes::_invokedynamic: | 2321 case Bytecodes::_invokedynamic: |
2318 types = 1 << JVM_CONSTANT_InvokeDynamic; | 2322 types = 1 << JVM_CONSTANT_InvokeDynamic; |
2319 break; | 2323 break; |
2320 case Bytecodes::_invokespecial: | 2324 case Bytecodes::_invokespecial: |
2321 types = (1 << JVM_CONSTANT_InterfaceMethodref) | | |
2322 (1 << JVM_CONSTANT_Methodref); | |
2323 break; | |
2324 case Bytecodes::_invokestatic: | 2325 case Bytecodes::_invokestatic: |
2325 types = (_klass->major_version() < STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION) ? | 2326 types = (_klass->major_version() < STATIC_METHOD_IN_INTERFACE_MAJOR_VERSION) ? |
2326 (1 << JVM_CONSTANT_Methodref) : | 2327 (1 << JVM_CONSTANT_Methodref) : |
2327 ((1 << JVM_CONSTANT_InterfaceMethodref) | (1 << JVM_CONSTANT_Methodref)); | 2328 ((1 << JVM_CONSTANT_InterfaceMethodref) | (1 << JVM_CONSTANT_Methodref)); |
2328 break; | 2329 break; |
2436 } | 2437 } |
2437 } else if (opcode == Bytecodes::_invokespecial | 2438 } else if (opcode == Bytecodes::_invokespecial |
2438 && !ref_class_type.equals(current_type()) | 2439 && !ref_class_type.equals(current_type()) |
2439 && !ref_class_type.equals(VerificationType::reference_type( | 2440 && !ref_class_type.equals(VerificationType::reference_type( |
2440 current_class()->super()->name()))) { | 2441 current_class()->super()->name()))) { |
2441 bool subtype = ref_class_type.is_assignable_from( | 2442 bool subtype = false; |
2442 current_type(), this, CHECK_VERIFY(this)); | 2443 if (!current_class()->is_anonymous()) { |
2444 subtype = ref_class_type.is_assignable_from( | |
2445 current_type(), this, CHECK_VERIFY(this)); | |
2446 } else { | |
2447 subtype = ref_class_type.is_assignable_from(VerificationType::reference_type( | |
2448 current_class()->host_klass()->name()), this, CHECK_VERIFY(this)); | |
2449 } | |
2443 if (!subtype) { | 2450 if (!subtype) { |
2444 verify_error(ErrorContext::bad_code(bci), | 2451 verify_error(ErrorContext::bad_code(bci), |
2445 "Bad invokespecial instruction: " | 2452 "Bad invokespecial instruction: " |
2446 "current class isn't assignable to reference class."); | 2453 "current class isn't assignable to reference class."); |
2447 return; | 2454 return; |
2458 verify_invoke_init(bcs, index, ref_class_type, current_frame, | 2465 verify_invoke_init(bcs, index, ref_class_type, current_frame, |
2459 code_length, this_uninit, cp, CHECK_VERIFY(this)); | 2466 code_length, this_uninit, cp, CHECK_VERIFY(this)); |
2460 } else { // other methods | 2467 } else { // other methods |
2461 // Ensures that target class is assignable to method class. | 2468 // Ensures that target class is assignable to method class. |
2462 if (opcode == Bytecodes::_invokespecial) { | 2469 if (opcode == Bytecodes::_invokespecial) { |
2463 current_frame->pop_stack(current_type(), CHECK_VERIFY(this)); | 2470 if (!current_class()->is_anonymous()) { |
2471 current_frame->pop_stack(current_type(), CHECK_VERIFY(this)); | |
2472 } else { | |
2473 // anonymous class invokespecial calls: check if the | |
2474 // objectref is a subtype of the host_klass of the current class | |
2475 // to allow an anonymous class to reference methods in the host_klass | |
2476 VerificationType top = current_frame->pop_stack(CHECK_VERIFY(this)); | |
2477 VerificationType hosttype = | |
2478 VerificationType::reference_type(current_class()->host_klass()->name()); | |
2479 bool subtype = hosttype.is_assignable_from(top, this, CHECK_VERIFY(this)); | |
2480 if (!subtype) { | |
2481 verify_error( ErrorContext::bad_type(current_frame->offset(), | |
2482 current_frame->stack_top_ctx(), | |
2483 TypeOrigin::implicit(top)), | |
2484 "Bad type on operand stack"); | |
2485 return; | |
2486 } | |
2487 } | |
2464 } else if (opcode == Bytecodes::_invokevirtual) { | 2488 } else if (opcode == Bytecodes::_invokevirtual) { |
2465 VerificationType stack_object_type = | 2489 VerificationType stack_object_type = |
2466 current_frame->pop_stack(ref_class_type, CHECK_VERIFY(this)); | 2490 current_frame->pop_stack(ref_class_type, CHECK_VERIFY(this)); |
2467 if (current_type() != stack_object_type) { | 2491 if (current_type() != stack_object_type) { |
2468 assert(cp->cache() == NULL, "not rewritten yet"); | 2492 assert(cp->cache() == NULL, "not rewritten yet"); |