< prev index next >

src/hotspot/share/classfile/verifier.cpp

Print this page

        

*** 239,249 **** return (should_verify_for(klass->class_loader(), should_verify_class) && // return if the class is a bootstrapping class // or defineClass specified not to verify by default (flags override passed arg) // We need to skip the following few for bootstrapping name != vmSymbols::java_lang_Object() && - name != vmSymbols::java_lang____Value() && name != vmSymbols::java_lang_Class() && name != vmSymbols::java_lang_String() && name != vmSymbols::java_lang_Throwable() && // Can not verify the bytecodes for shared classes because they have --- 239,248 ----
*** 588,601 **** VerificationType ClassVerifier::object_type() const { return VerificationType::reference_type(vmSymbols::java_lang_Object()); } - VerificationType ClassVerifier::__value_type() const { - return VerificationType::valuetype_type(vmSymbols::java_lang____Value()); - } - TypeOrigin ClassVerifier::ref_ctx(const char* sig, TRAPS) { VerificationType vt = VerificationType::reference_type( create_temporary_symbol(sig, (int)strlen(sig), THREAD)); return TypeOrigin::implicit(vt); } --- 587,596 ----
*** 746,757 **** if (opcode != Bytecodes::_iinc && opcode != Bytecodes::_iload && opcode != Bytecodes::_aload && opcode != Bytecodes::_lload && opcode != Bytecodes::_istore && opcode != Bytecodes::_astore && opcode != Bytecodes::_lstore && opcode != Bytecodes::_fload && opcode != Bytecodes::_dload && opcode != Bytecodes::_fstore && ! opcode != Bytecodes::_dstore && opcode != Bytecodes::_vstore && ! opcode != Bytecodes::_vload) { /* Unreachable? RawBytecodeStream's raw_next() returns 'illegal' * if we encounter a wide instruction that modifies an invalid * opcode (not one of the ones listed above) */ verify_error(ErrorContext::bad_code(bci), "Bad wide instruction"); return; --- 741,751 ---- if (opcode != Bytecodes::_iinc && opcode != Bytecodes::_iload && opcode != Bytecodes::_aload && opcode != Bytecodes::_lload && opcode != Bytecodes::_istore && opcode != Bytecodes::_astore && opcode != Bytecodes::_lstore && opcode != Bytecodes::_fload && opcode != Bytecodes::_dload && opcode != Bytecodes::_fstore && ! opcode != Bytecodes::_dstore) { /* Unreachable? RawBytecodeStream's raw_next() returns 'illegal' * if we encounter a wide instruction that modifies an invalid * opcode (not one of the ones listed above) */ verify_error(ErrorContext::bad_code(bci), "Bad wide instruction"); return;
*** 862,880 **** case Bytecodes::_dload_2 : case Bytecodes::_dload_3 : index = opcode - Bytecodes::_dload_0; verify_dload(index, &current_frame, CHECK_VERIFY(this)); no_control_flow = false; break; - case Bytecodes::_vload : - if (!vbytecodes_allowed) { - class_format_error( - "vload not supported by this class file version (%d.%d), class %s", - _klass->major_version(), _klass->minor_version(), _klass->external_name()); - return; - } - verify_vload(bcs.get_index(), &current_frame, CHECK_VERIFY(this)); - no_control_flow = false; break; case Bytecodes::_aload : verify_aload(bcs.get_index(), &current_frame, CHECK_VERIFY(this)); no_control_flow = false; break; case Bytecodes::_aload_0 : case Bytecodes::_aload_1 : --- 856,865 ----
*** 1003,1043 **** atype.get_component(this, CHECK_VERIFY(this)); current_frame.push_stack(component, CHECK_VERIFY(this)); } no_control_flow = false; break; } ! case Bytecodes::_vaload : { ! if (!vbytecodes_allowed) { ! class_format_error( ! "vaload not supported by this class file version (%d.%d), class %s", ! _klass->major_version(), _klass->minor_version(), _klass->external_name()); ! return; ! } ! type = current_frame.pop_stack( ! VerificationType::integer_type(), CHECK_VERIFY(this)); ! atype = current_frame.pop_stack( ! VerificationType::reference_check(), CHECK_VERIFY(this)); ! // The null check is strictly not be necessary, left in for future proofing. ! // Will be reconsidered if type indexes are removed. ! if (atype.is_null() || !atype.is_value_array()) { ! verify_error(ErrorContext::bad_type(bci, ! current_frame.stack_top_ctx(), ! TypeOrigin::implicit(VerificationType::reference_check())), ! bad_type_msg, "vaload"); ! return; ! } ! VerificationType component = atype.get_component(this, CHECK_VERIFY(this)); ! if (!component.is_valuetype()) { ! verify_error(ErrorContext::bad_type(bci, ! current_frame.stack_top_ctx(), ! TypeOrigin::implicit(VerificationType::valuetype_check())), ! bad_type_msg, "vaload"); ! return; ! } ! current_frame.push_stack(component, CHECK_VERIFY(this)); ! no_control_flow = false; break; ! } case Bytecodes::_istore : verify_istore(bcs.get_index(), &current_frame, CHECK_VERIFY(this)); no_control_flow = false; break; case Bytecodes::_istore_0 : case Bytecodes::_istore_1 : --- 988,1028 ---- atype.get_component(this, CHECK_VERIFY(this)); current_frame.push_stack(component, CHECK_VERIFY(this)); } no_control_flow = false; break; } ! // case Bytecodes::_vaload : { ! // if (!vbytecodes_allowed) { ! // class_format_error( ! // "vaload not supported by this class file version (%d.%d), class %s", ! // _klass->major_version(), _klass->minor_version(), _klass->external_name()); ! // return; ! // } ! // type = current_frame.pop_stack( ! // VerificationType::integer_type(), CHECK_VERIFY(this)); ! // atype = current_frame.pop_stack( ! // VerificationType::reference_check(), CHECK_VERIFY(this)); ! // // The null check is strictly not be necessary, left in for future proofing. ! // // Will be reconsidered if type indexes are removed. ! // if (atype.is_null() || !atype.is_value_array()) { ! // verify_error(ErrorContext::bad_type(bci, ! // current_frame.stack_top_ctx(), ! // TypeOrigin::implicit(VerificationType::reference_check())), ! // bad_type_msg, "vaload"); ! // return; ! // } ! // VerificationType component = atype.get_component(this, CHECK_VERIFY(this)); ! // if (!component.is_valuetype()) { ! // verify_error(ErrorContext::bad_type(bci, ! // current_frame.stack_top_ctx(), ! // TypeOrigin::implicit(VerificationType::valuetype_check())), ! // bad_type_msg, "vaload"); ! // return; ! // } ! // current_frame.push_stack(component, CHECK_VERIFY(this)); ! // no_control_flow = false; break; ! // } case Bytecodes::_istore : verify_istore(bcs.get_index(), &current_frame, CHECK_VERIFY(this)); no_control_flow = false; break; case Bytecodes::_istore_0 : case Bytecodes::_istore_1 :
*** 1074,1092 **** case Bytecodes::_dstore_2 : case Bytecodes::_dstore_3 : index = opcode - Bytecodes::_dstore_0; verify_dstore(index, &current_frame, CHECK_VERIFY(this)); no_control_flow = false; break; - case Bytecodes::_vstore : - if (!vbytecodes_allowed) { - class_format_error( - "vstore not supported by this class file version (%d.%d), class %s", - _klass->major_version(), _klass->minor_version(), _klass->external_name()); - return; - } - verify_vstore(bcs.get_index(), &current_frame, CHECK_VERIFY(this)); - no_control_flow = false; break; case Bytecodes::_astore : verify_astore(bcs.get_index(), &current_frame, CHECK_VERIFY(this)); no_control_flow = false; break; case Bytecodes::_astore_0 : case Bytecodes::_astore_1 : --- 1059,1068 ----
*** 1209,1240 **** bad_type_msg, "aastore"); return; } // 4938384: relaxed constraint in JVMS 3nd edition. no_control_flow = false; break; ! case Bytecodes::_vastore : ! if (!vbytecodes_allowed) { ! class_format_error( ! "vastore not supported by this class file version (%d.%d), class %s", ! _klass->major_version(), _klass->minor_version(), _klass->external_name()); ! return; ! } ! type = current_frame.pop_stack(__value_type(), CHECK_VERIFY(this)); ! type2 = current_frame.pop_stack( ! VerificationType::integer_type(), CHECK_VERIFY(this)); ! atype = current_frame.pop_stack( ! VerificationType::reference_check(), CHECK_VERIFY(this)); ! // The null check is strictly not be necessary, left in for future proofing. ! // Will be reconsidered if type indexes are removed. ! if (atype.is_null() || !atype.is_value_array()) { ! verify_error(ErrorContext::bad_type(bci, ! current_frame.stack_top_ctx(), ! TypeOrigin::implicit(VerificationType::reference_check())), ! bad_type_msg, "vastore"); ! return; ! } ! no_control_flow = false; break; case Bytecodes::_pop : current_frame.pop_stack( VerificationType::category1_check(), CHECK_VERIFY(this)); no_control_flow = false; break; case Bytecodes::_pop2 : --- 1185,1216 ---- bad_type_msg, "aastore"); return; } // 4938384: relaxed constraint in JVMS 3nd edition. no_control_flow = false; break; ! // case Bytecodes::_vastore : ! // if (!vbytecodes_allowed) { ! // class_format_error( ! // "vastore not supported by this class file version (%d.%d), class %s", ! // _klass->major_version(), _klass->minor_version(), _klass->external_name()); ! // return; ! // } ! // type = current_frame.pop_stack(__value_type(), CHECK_VERIFY(this)); ! // type2 = current_frame.pop_stack( ! // VerificationType::integer_type(), CHECK_VERIFY(this)); ! // atype = current_frame.pop_stack( ! // VerificationType::reference_check(), CHECK_VERIFY(this)); ! // // The null check is strictly not be necessary, left in for future proofing. ! // // Will be reconsidered if type indexes are removed. ! // if (atype.is_null() || !atype.is_value_array()) { ! // verify_error(ErrorContext::bad_type(bci, ! // current_frame.stack_top_ctx(), ! // TypeOrigin::implicit(VerificationType::reference_check())), ! // bad_type_msg, "vastore"); ! // return; ! // } ! // no_control_flow = false; break; case Bytecodes::_pop : current_frame.pop_stack( VerificationType::category1_check(), CHECK_VERIFY(this)); no_control_flow = false; break; case Bytecodes::_pop2 :
*** 1682,1703 **** type = current_frame.pop_stack( VerificationType::reference_check(), CHECK_VERIFY(this)); verify_return_value(return_type, type, bci, &current_frame, CHECK_VERIFY(this)); no_control_flow = true; break; ! case Bytecodes::_vreturn : ! if (!vbytecodes_allowed) { ! class_format_error( ! "vreturn not supported by this class file version (%d.%d), class %s", ! _klass->major_version(), _klass->minor_version(), _klass->external_name()); ! return; ! } ! type = current_frame.pop_stack( ! VerificationType::valuetype_check(), CHECK_VERIFY(this)); ! verify_return_value(return_type, type, bci, ! &current_frame, CHECK_VERIFY(this)); ! no_control_flow = true; break; case Bytecodes::_return : if (return_type != VerificationType::bogus_type()) { verify_error(ErrorContext::bad_code(bci), "Method expects a return value"); return; --- 1658,1679 ---- type = current_frame.pop_stack( VerificationType::reference_check(), CHECK_VERIFY(this)); verify_return_value(return_type, type, bci, &current_frame, CHECK_VERIFY(this)); no_control_flow = true; break; ! // case Bytecodes::_vreturn : ! // if (!vbytecodes_allowed) { ! // class_format_error( ! // "vreturn not supported by this class file version (%d.%d), class %s", ! // _klass->major_version(), _klass->minor_version(), _klass->external_name()); ! // return; ! // } ! // type = current_frame.pop_stack( ! // VerificationType::valuetype_check(), CHECK_VERIFY(this)); ! // verify_return_value(return_type, type, bci, ! // &current_frame, CHECK_VERIFY(this)); ! // no_control_flow = true; break; case Bytecodes::_return : if (return_type != VerificationType::bogus_type()) { verify_error(ErrorContext::bad_code(bci), "Method expects a return value"); return;
*** 1722,1732 **** case Bytecodes::_putfield : // pass FALSE, operand can't be an array type for getfield/putfield. verify_field_instructions( &bcs, &current_frame, cp, false, CHECK_VERIFY(this)); no_control_flow = false; break; ! case Bytecodes::_vwithfield : if (!vbytecodes_allowed) { class_format_error( "vwithfield not supported by this class file version (%d.%d), class %s", _klass->major_version(), _klass->minor_version(), _klass->external_name()); return; --- 1698,1708 ---- case Bytecodes::_putfield : // pass FALSE, operand can't be an array type for getfield/putfield. verify_field_instructions( &bcs, &current_frame, cp, false, CHECK_VERIFY(this)); no_control_flow = false; break; ! case Bytecodes::_withfield : if (!vbytecodes_allowed) { class_format_error( "vwithfield not supported by this class file version (%d.%d), class %s", _klass->major_version(), _klass->minor_version(), _klass->external_name()); return;
*** 1760,1770 **** } type = VerificationType::uninitialized_type(bci); current_frame.push_stack(type, CHECK_VERIFY(this)); no_control_flow = false; break; } ! case Bytecodes::_vdefault : { if (!vbytecodes_allowed) { class_format_error( "vdefault not supported by this class file version (%d.%d), class %s", _klass->major_version(), _klass->minor_version(), _klass->external_name()); --- 1736,1746 ---- } type = VerificationType::uninitialized_type(bci); current_frame.push_stack(type, CHECK_VERIFY(this)); no_control_flow = false; break; } ! case Bytecodes::_defaultvalue : { if (!vbytecodes_allowed) { class_format_error( "vdefault not supported by this class file version (%d.%d), class %s", _klass->major_version(), _klass->minor_version(), _klass->external_name());
*** 1820,1859 **** current_frame.pop_stack(object_type(), CHECK_VERIFY(this)); current_frame.push_stack( VerificationType::integer_type(), CHECK_VERIFY(this)); no_control_flow = false; break; } - case Bytecodes::_vbox : { - if (!EnableMVT || !vbytecodes_allowed) { - class_format_error( - "vbox not supported by this class file version (%d.%d), class %s", - _klass->major_version(), _klass->minor_version(), _klass->external_name()); - return; - } - index = bcs.get_index_u2(); - verify_cp_class_type(bci, index, cp, CHECK_VERIFY(this)); - current_frame.pop_stack(VerificationType::valuetype_check(), CHECK_VERIFY(this)); - VerificationType klass_type = cp_index_to_reference_type( - index, cp, CHECK_VERIFY(this)); - current_frame.push_stack(klass_type, CHECK_VERIFY(this)); - no_control_flow = false; break; - } - case Bytecodes::_vunbox : { - if (!EnableMVT || !vbytecodes_allowed) { - class_format_error( - "vunbox not supported by this class file version (%d.%d), class %s", - _klass->major_version(), _klass->minor_version(), _klass->external_name()); - return; - } - index = bcs.get_index_u2(); - verify_cp_value_type(bci, index, cp, CHECK_VERIFY(this)); - current_frame.pop_stack(object_type(), CHECK_VERIFY(this)); - VerificationType value_type = cp_index_to_valuetype( - index, cp, CHECK_VERIFY(this)); - current_frame.push_stack(value_type, CHECK_VERIFY(this)); - no_control_flow = false; break; - } case Bytecodes::_monitorenter : case Bytecodes::_monitorexit : current_frame.pop_stack( VerificationType::reference_check(), CHECK_VERIFY(this)); no_control_flow = false; break; --- 1796,1805 ----
*** 3331,3346 **** VerificationType type = current_frame->get_local( index, VerificationType::reference_check(), CHECK_VERIFY(this)); current_frame->push_stack(type, CHECK_VERIFY(this)); } - void ClassVerifier::verify_vload(u2 index, StackMapFrame* current_frame, TRAPS) { - VerificationType type = current_frame->get_local( - index, VerificationType::valuetype_check(), CHECK_VERIFY(this)); - current_frame->push_stack(type, CHECK_VERIFY(this)); - } - void ClassVerifier::verify_istore(u2 index, StackMapFrame* current_frame, TRAPS) { current_frame->pop_stack( VerificationType::integer_type(), CHECK_VERIFY(this)); current_frame->set_local( index, VerificationType::integer_type(), CHECK_VERIFY(this)); --- 3277,3286 ----
*** 3374,3389 **** VerificationType type = current_frame->pop_stack( VerificationType::reference_check(), CHECK_VERIFY(this)); current_frame->set_local(index, type, CHECK_VERIFY(this)); } - void ClassVerifier::verify_vstore(u2 index, StackMapFrame* current_frame, TRAPS) { - VerificationType type = current_frame->pop_stack( - VerificationType::valuetype_check(), CHECK_VERIFY(this)); - current_frame->set_local(index, type, CHECK_VERIFY(this)); - } - void ClassVerifier::verify_iinc(u2 index, StackMapFrame* current_frame, TRAPS) { VerificationType type = current_frame->get_local( index, VerificationType::integer_type(), CHECK_VERIFY(this)); current_frame->set_local(index, type, CHECK_VERIFY(this)); } --- 3314,3323 ----
< prev index next >