src/share/vm/classfile/verifier.cpp

Tue, 01 Jun 2010 11:48:33 -0700

author
trims
date
Tue, 01 Jun 2010 11:48:33 -0700
changeset 1917
dfe27f03244a
parent 1907
c18cbe5936b8
parent 1915
e40a3601bc1f
child 1934
e9ff18c4ace7
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved.
     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  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 # include "incls/_precompiled.incl"
    26 # include "incls/_verifier.cpp.incl"
    28 #define NOFAILOVER_MAJOR_VERSION 51
    30 // Access to external entry for VerifyClassCodes - old byte code verifier
    32 extern "C" {
    33   typedef jboolean (*verify_byte_codes_fn_t)(JNIEnv *, jclass, char *, jint);
    34   typedef jboolean (*verify_byte_codes_fn_new_t)(JNIEnv *, jclass, char *, jint, jint);
    35 }
    37 static void* volatile _verify_byte_codes_fn = NULL;
    39 static volatile jint _is_new_verify_byte_codes_fn = (jint) true;
    41 static void* verify_byte_codes_fn() {
    42   if (_verify_byte_codes_fn == NULL) {
    43     void *lib_handle = os::native_java_library();
    44     void *func = hpi::dll_lookup(lib_handle, "VerifyClassCodesForMajorVersion");
    45     OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func);
    46     if (func == NULL) {
    47       OrderAccess::release_store(&_is_new_verify_byte_codes_fn, false);
    48       func = hpi::dll_lookup(lib_handle, "VerifyClassCodes");
    49       OrderAccess::release_store_ptr(&_verify_byte_codes_fn, func);
    50     }
    51   }
    52   return (void*)_verify_byte_codes_fn;
    53 }
    56 // Methods in Verifier
    58 bool Verifier::should_verify_for(oop class_loader, bool should_verify_class) {
    59   return (class_loader == NULL || !should_verify_class) ?
    60     BytecodeVerificationLocal : BytecodeVerificationRemote;
    61 }
    63 bool Verifier::relax_verify_for(oop loader) {
    64   bool trusted = java_lang_ClassLoader::is_trusted_loader(loader);
    65   bool need_verify =
    66     // verifyAll
    67     (BytecodeVerificationLocal && BytecodeVerificationRemote) ||
    68     // verifyRemote
    69     (!BytecodeVerificationLocal && BytecodeVerificationRemote && !trusted);
    70   return !need_verify;
    71 }
    73 bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool should_verify_class, TRAPS) {
    74   ResourceMark rm(THREAD);
    75   HandleMark hm;
    77   symbolHandle exception_name;
    78   const size_t message_buffer_len = klass->name()->utf8_length() + 1024;
    79   char* message_buffer = NEW_RESOURCE_ARRAY(char, message_buffer_len);
    81   const char* klassName = klass->external_name();
    83   // If the class should be verified, first see if we can use the split
    84   // verifier.  If not, or if verification fails and FailOverToOldVerifier
    85   // is set, then call the inference verifier.
    86   if (is_eligible_for_verification(klass, should_verify_class)) {
    87     if (TraceClassInitialization) {
    88       tty->print_cr("Start class verification for: %s", klassName);
    89     }
    90     if (UseSplitVerifier &&
    91         klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) {
    92         ClassVerifier split_verifier(
    93           klass, message_buffer, message_buffer_len, THREAD);
    94         split_verifier.verify_class(THREAD);
    95         exception_name = split_verifier.result();
    96       if (klass->major_version() < NOFAILOVER_MAJOR_VERSION &&
    97           FailOverToOldVerifier && !HAS_PENDING_EXCEPTION &&
    98           (exception_name == vmSymbols::java_lang_VerifyError() ||
    99            exception_name == vmSymbols::java_lang_ClassFormatError())) {
   100         if (TraceClassInitialization) {
   101           tty->print_cr(
   102             "Fail over class verification to old verifier for: %s", klassName);
   103         }
   104         exception_name = inference_verify(
   105           klass, message_buffer, message_buffer_len, THREAD);
   106       }
   107     } else {
   108       exception_name = inference_verify(
   109           klass, message_buffer, message_buffer_len, THREAD);
   110     }
   112     if (TraceClassInitialization) {
   113       if (HAS_PENDING_EXCEPTION) {
   114         tty->print("Verification for %s has", klassName);
   115         tty->print_cr(" exception pending %s ",
   116           instanceKlass::cast(PENDING_EXCEPTION->klass())->external_name());
   117       } else if (!exception_name.is_null()) {
   118         tty->print_cr("Verification for %s failed", klassName);
   119       }
   120       tty->print_cr("End class verification for: %s", klassName);
   121     }
   122   }
   124   if (HAS_PENDING_EXCEPTION) {
   125     return false; // use the existing exception
   126   } else if (exception_name.is_null()) {
   127     return true; // verifcation succeeded
   128   } else { // VerifyError or ClassFormatError to be created and thrown
   129     ResourceMark rm(THREAD);
   130     instanceKlassHandle kls =
   131       SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false);
   132     while (!kls.is_null()) {
   133       if (kls == klass) {
   134         // If the class being verified is the exception we're creating
   135         // or one of it's superclasses, we're in trouble and are going
   136         // to infinitely recurse when we try to initialize the exception.
   137         // So bail out here by throwing the preallocated VM error.
   138         THROW_OOP_(Universe::virtual_machine_error_instance(), false);
   139       }
   140       kls = kls->super();
   141     }
   142     message_buffer[message_buffer_len - 1] = '\0'; // just to be sure
   143     THROW_MSG_(exception_name, message_buffer, false);
   144   }
   145 }
   147 bool Verifier::is_eligible_for_verification(instanceKlassHandle klass, bool should_verify_class) {
   148   symbolOop name = klass->name();
   149   klassOop refl_magic_klass = SystemDictionary::reflect_MagicAccessorImpl_klass();
   151   return (should_verify_for(klass->class_loader(), should_verify_class) &&
   152     // return if the class is a bootstrapping class
   153     // or defineClass specified not to verify by default (flags override passed arg)
   154     // We need to skip the following four for bootstraping
   155     name != vmSymbols::java_lang_Object() &&
   156     name != vmSymbols::java_lang_Class() &&
   157     name != vmSymbols::java_lang_String() &&
   158     name != vmSymbols::java_lang_Throwable() &&
   160     // Can not verify the bytecodes for shared classes because they have
   161     // already been rewritten to contain constant pool cache indices,
   162     // which the verifier can't understand.
   163     // Shared classes shouldn't have stackmaps either.
   164     !klass()->is_shared() &&
   166     // As of the fix for 4486457 we disable verification for all of the
   167     // dynamically-generated bytecodes associated with the 1.4
   168     // reflection implementation, not just those associated with
   169     // sun/reflect/SerializationConstructorAccessor.
   170     // NOTE: this is called too early in the bootstrapping process to be
   171     // guarded by Universe::is_gte_jdk14x_version()/UseNewReflection.
   172     (refl_magic_klass == NULL ||
   173      !klass->is_subtype_of(refl_magic_klass) ||
   174      VerifyReflectionBytecodes)
   175   );
   176 }
   178 symbolHandle Verifier::inference_verify(
   179     instanceKlassHandle klass, char* message, size_t message_len, TRAPS) {
   180   JavaThread* thread = (JavaThread*)THREAD;
   181   JNIEnv *env = thread->jni_environment();
   183   void* verify_func = verify_byte_codes_fn();
   185   if (verify_func == NULL) {
   186     jio_snprintf(message, message_len, "Could not link verifier");
   187     return vmSymbols::java_lang_VerifyError();
   188   }
   190   ResourceMark rm(THREAD);
   191   if (ClassVerifier::_verify_verbose) {
   192     tty->print_cr("Verifying class %s with old format", klass->external_name());
   193   }
   195   jclass cls = (jclass) JNIHandles::make_local(env, klass->java_mirror());
   196   jint result;
   198   {
   199     HandleMark hm(thread);
   200     ThreadToNativeFromVM ttn(thread);
   201     // ThreadToNativeFromVM takes care of changing thread_state, so safepoint
   202     // code knows that we have left the VM
   204     if (_is_new_verify_byte_codes_fn) {
   205       verify_byte_codes_fn_new_t func =
   206         CAST_TO_FN_PTR(verify_byte_codes_fn_new_t, verify_func);
   207       result = (*func)(env, cls, message, (int)message_len,
   208           klass->major_version());
   209     } else {
   210       verify_byte_codes_fn_t func =
   211         CAST_TO_FN_PTR(verify_byte_codes_fn_t, verify_func);
   212       result = (*func)(env, cls, message, (int)message_len);
   213     }
   214   }
   216   JNIHandles::destroy_local(cls);
   218   // These numbers are chosen so that VerifyClassCodes interface doesn't need
   219   // to be changed (still return jboolean (unsigned char)), and result is
   220   // 1 when verification is passed.
   221   symbolHandle nh(NULL);
   222   if (result == 0) {
   223     return vmSymbols::java_lang_VerifyError();
   224   } else if (result == 1) {
   225     return nh; // verified.
   226   } else if (result == 2) {
   227     THROW_MSG_(vmSymbols::java_lang_OutOfMemoryError(), message, nh);
   228   } else if (result == 3) {
   229     return vmSymbols::java_lang_ClassFormatError();
   230   } else {
   231     ShouldNotReachHere();
   232     return nh;
   233   }
   234 }
   236 // Methods in ClassVerifier
   238 bool ClassVerifier::_verify_verbose = false;
   240 ClassVerifier::ClassVerifier(
   241     instanceKlassHandle klass, char* msg, size_t msg_len, TRAPS)
   242     : _thread(THREAD), _exception_type(symbolHandle()), _message(msg),
   243       _message_buffer_len(msg_len), _klass(klass) {
   244   _this_type = VerificationType::reference_type(klass->name());
   245 }
   247 ClassVerifier::~ClassVerifier() {
   248 }
   250 void ClassVerifier::verify_class(TRAPS) {
   251   if (_verify_verbose) {
   252     tty->print_cr("Verifying class %s with new format",
   253       _klass->external_name());
   254   }
   256   objArrayHandle methods(THREAD, _klass->methods());
   257   int num_methods = methods->length();
   259   for (int index = 0; index < num_methods; index++) {
   260     methodOop m = (methodOop)methods->obj_at(index);
   261     if (m->is_native() || m->is_abstract()) {
   262       // If m is native or abstract, skip it.  It is checked in class file
   263       // parser that methods do not override a final method.
   264       continue;
   265     }
   266     verify_method(methodHandle(THREAD, m), CHECK_VERIFY(this));
   267   }
   268 }
   270 void ClassVerifier::verify_method(methodHandle m, TRAPS) {
   271   ResourceMark rm(THREAD);
   272   _method = m;   // initialize _method
   273   if (_verify_verbose) {
   274     tty->print_cr("Verifying method %s", m->name_and_sig_as_C_string());
   275   }
   277   const char* bad_type_msg = "Bad type on operand stack in %s";
   279   int32_t max_stack = m->max_stack();
   280   int32_t max_locals = m->max_locals();
   281   constantPoolHandle cp(THREAD, m->constants());
   283   if (!SignatureVerifier::is_valid_method_signature(m->signature())) {
   284     class_format_error("Invalid method signature");
   285     return;
   286   }
   288   // Initial stack map frame: offset is 0, stack is initially empty.
   289   StackMapFrame current_frame(max_locals, max_stack, this);
   290   // Set initial locals
   291   VerificationType return_type = current_frame.set_locals_from_arg(
   292     m, current_type(), CHECK_VERIFY(this));
   294   int32_t stackmap_index = 0; // index to the stackmap array
   296   u4 code_length = m->code_size();
   298   // Scan the bytecode and map each instruction's start offset to a number.
   299   char* code_data = generate_code_data(m, code_length, CHECK_VERIFY(this));
   301   int ex_min = code_length;
   302   int ex_max = -1;
   303   // Look through each item on the exception table. Each of the fields must refer
   304   // to a legal instruction.
   305   verify_exception_handler_table(
   306     code_length, code_data, ex_min, ex_max, CHECK_VERIFY(this));
   308   // Look through each entry on the local variable table and make sure
   309   // its range of code array offsets is valid. (4169817)
   310   if (m->has_localvariable_table()) {
   311     verify_local_variable_table(code_length, code_data, CHECK_VERIFY(this));
   312   }
   314   typeArrayHandle stackmap_data(THREAD, m->stackmap_data());
   315   StackMapStream stream(stackmap_data);
   316   StackMapReader reader(this, &stream, code_data, code_length, THREAD);
   317   StackMapTable stackmap_table(&reader, &current_frame, max_locals, max_stack,
   318                                code_data, code_length, CHECK_VERIFY(this));
   320   if (_verify_verbose) {
   321     stackmap_table.print();
   322   }
   324   RawBytecodeStream bcs(m);
   326   // Scan the byte code linearly from the start to the end
   327   bool no_control_flow = false; // Set to true when there is no direct control
   328                                 // flow from current instruction to the next
   329                                 // instruction in sequence
   330   Bytecodes::Code opcode;
   331   while (!bcs.is_last_bytecode()) {
   332     opcode = bcs.raw_next();
   333     u2 bci = bcs.bci();
   335     // Set current frame's offset to bci
   336     current_frame.set_offset(bci);
   338     // Make sure every offset in stackmap table point to the beginning to
   339     // an instruction. Match current_frame to stackmap_table entry with
   340     // the same offset if exists.
   341     stackmap_index = verify_stackmap_table(
   342       stackmap_index, bci, &current_frame, &stackmap_table,
   343       no_control_flow, CHECK_VERIFY(this));
   345     bool this_uninit = false;  // Set to true when invokespecial <init> initialized 'this'
   347     // Merge with the next instruction
   348     {
   349       u2 index;
   350       int target;
   351       VerificationType type, type2;
   352       VerificationType atype;
   354 #ifndef PRODUCT
   355       if (_verify_verbose) {
   356         current_frame.print();
   357         tty->print_cr("offset = %d,  opcode = %s", bci, Bytecodes::name(opcode));
   358       }
   359 #endif
   361       // Make sure wide instruction is in correct format
   362       if (bcs.is_wide()) {
   363         if (opcode != Bytecodes::_iinc   && opcode != Bytecodes::_iload  &&
   364             opcode != Bytecodes::_aload  && opcode != Bytecodes::_lload  &&
   365             opcode != Bytecodes::_istore && opcode != Bytecodes::_astore &&
   366             opcode != Bytecodes::_lstore && opcode != Bytecodes::_fload  &&
   367             opcode != Bytecodes::_dload  && opcode != Bytecodes::_fstore &&
   368             opcode != Bytecodes::_dstore) {
   369           verify_error(bci, "Bad wide instruction");
   370           return;
   371         }
   372       }
   374       switch (opcode) {
   375         case Bytecodes::_nop :
   376           no_control_flow = false; break;
   377         case Bytecodes::_aconst_null :
   378           current_frame.push_stack(
   379             VerificationType::null_type(), CHECK_VERIFY(this));
   380           no_control_flow = false; break;
   381         case Bytecodes::_iconst_m1 :
   382         case Bytecodes::_iconst_0 :
   383         case Bytecodes::_iconst_1 :
   384         case Bytecodes::_iconst_2 :
   385         case Bytecodes::_iconst_3 :
   386         case Bytecodes::_iconst_4 :
   387         case Bytecodes::_iconst_5 :
   388           current_frame.push_stack(
   389             VerificationType::integer_type(), CHECK_VERIFY(this));
   390           no_control_flow = false; break;
   391         case Bytecodes::_lconst_0 :
   392         case Bytecodes::_lconst_1 :
   393           current_frame.push_stack_2(
   394             VerificationType::long_type(),
   395             VerificationType::long2_type(), CHECK_VERIFY(this));
   396           no_control_flow = false; break;
   397         case Bytecodes::_fconst_0 :
   398         case Bytecodes::_fconst_1 :
   399         case Bytecodes::_fconst_2 :
   400           current_frame.push_stack(
   401             VerificationType::float_type(), CHECK_VERIFY(this));
   402           no_control_flow = false; break;
   403         case Bytecodes::_dconst_0 :
   404         case Bytecodes::_dconst_1 :
   405           current_frame.push_stack_2(
   406             VerificationType::double_type(),
   407             VerificationType::double2_type(), CHECK_VERIFY(this));
   408           no_control_flow = false; break;
   409         case Bytecodes::_sipush :
   410         case Bytecodes::_bipush :
   411           current_frame.push_stack(
   412             VerificationType::integer_type(), CHECK_VERIFY(this));
   413           no_control_flow = false; break;
   414         case Bytecodes::_ldc :
   415           verify_ldc(
   416             opcode, bcs.get_index(), &current_frame,
   417             cp, bci, CHECK_VERIFY(this));
   418           no_control_flow = false; break;
   419         case Bytecodes::_ldc_w :
   420         case Bytecodes::_ldc2_w :
   421           verify_ldc(
   422             opcode, bcs.get_index_big(), &current_frame,
   423             cp, bci, CHECK_VERIFY(this));
   424           no_control_flow = false; break;
   425         case Bytecodes::_iload :
   426           verify_iload(bcs.get_index(), &current_frame, CHECK_VERIFY(this));
   427           no_control_flow = false; break;
   428         case Bytecodes::_iload_0 :
   429         case Bytecodes::_iload_1 :
   430         case Bytecodes::_iload_2 :
   431         case Bytecodes::_iload_3 :
   432           index = opcode - Bytecodes::_iload_0;
   433           verify_iload(index, &current_frame, CHECK_VERIFY(this));
   434           no_control_flow = false; break;
   435         case Bytecodes::_lload :
   436           verify_lload(bcs.get_index(), &current_frame, CHECK_VERIFY(this));
   437           no_control_flow = false; break;
   438         case Bytecodes::_lload_0 :
   439         case Bytecodes::_lload_1 :
   440         case Bytecodes::_lload_2 :
   441         case Bytecodes::_lload_3 :
   442           index = opcode - Bytecodes::_lload_0;
   443           verify_lload(index, &current_frame, CHECK_VERIFY(this));
   444           no_control_flow = false; break;
   445         case Bytecodes::_fload :
   446           verify_fload(bcs.get_index(), &current_frame, CHECK_VERIFY(this));
   447           no_control_flow = false; break;
   448         case Bytecodes::_fload_0 :
   449         case Bytecodes::_fload_1 :
   450         case Bytecodes::_fload_2 :
   451         case Bytecodes::_fload_3 :
   452           index = opcode - Bytecodes::_fload_0;
   453           verify_fload(index, &current_frame, CHECK_VERIFY(this));
   454           no_control_flow = false; break;
   455         case Bytecodes::_dload :
   456           verify_dload(bcs.get_index(), &current_frame, CHECK_VERIFY(this));
   457           no_control_flow = false; break;
   458         case Bytecodes::_dload_0 :
   459         case Bytecodes::_dload_1 :
   460         case Bytecodes::_dload_2 :
   461         case Bytecodes::_dload_3 :
   462           index = opcode - Bytecodes::_dload_0;
   463           verify_dload(index, &current_frame, CHECK_VERIFY(this));
   464           no_control_flow = false; break;
   465         case Bytecodes::_aload :
   466           verify_aload(bcs.get_index(), &current_frame, CHECK_VERIFY(this));
   467           no_control_flow = false; break;
   468         case Bytecodes::_aload_0 :
   469         case Bytecodes::_aload_1 :
   470         case Bytecodes::_aload_2 :
   471         case Bytecodes::_aload_3 :
   472           index = opcode - Bytecodes::_aload_0;
   473           verify_aload(index, &current_frame, CHECK_VERIFY(this));
   474           no_control_flow = false; break;
   475         case Bytecodes::_iaload :
   476           type = current_frame.pop_stack(
   477             VerificationType::integer_type(), CHECK_VERIFY(this));
   478           atype = current_frame.pop_stack(
   479             VerificationType::reference_check(), CHECK_VERIFY(this));
   480           if (!atype.is_int_array()) {
   481             verify_error(bci, bad_type_msg, "iaload");
   482             return;
   483           }
   484           current_frame.push_stack(
   485             VerificationType::integer_type(), CHECK_VERIFY(this));
   486           no_control_flow = false; break;
   487         case Bytecodes::_baload :
   488           type = current_frame.pop_stack(
   489             VerificationType::integer_type(), CHECK_VERIFY(this));
   490           atype = current_frame.pop_stack(
   491             VerificationType::reference_check(), CHECK_VERIFY(this));
   492           if (!atype.is_bool_array() && !atype.is_byte_array()) {
   493             verify_error(bci, bad_type_msg, "baload");
   494             return;
   495           }
   496           current_frame.push_stack(
   497             VerificationType::integer_type(), CHECK_VERIFY(this));
   498           no_control_flow = false; break;
   499         case Bytecodes::_caload :
   500           type = current_frame.pop_stack(
   501             VerificationType::integer_type(), CHECK_VERIFY(this));
   502           atype = current_frame.pop_stack(
   503             VerificationType::reference_check(), CHECK_VERIFY(this));
   504           if (!atype.is_char_array()) {
   505             verify_error(bci, bad_type_msg, "caload");
   506             return;
   507           }
   508           current_frame.push_stack(
   509             VerificationType::integer_type(), CHECK_VERIFY(this));
   510           no_control_flow = false; break;
   511         case Bytecodes::_saload :
   512           type = current_frame.pop_stack(
   513             VerificationType::integer_type(), CHECK_VERIFY(this));
   514           atype = current_frame.pop_stack(
   515             VerificationType::reference_check(), CHECK_VERIFY(this));
   516           if (!atype.is_short_array()) {
   517             verify_error(bci, bad_type_msg, "saload");
   518             return;
   519           }
   520           current_frame.push_stack(
   521             VerificationType::integer_type(), CHECK_VERIFY(this));
   522           no_control_flow = false; break;
   523         case Bytecodes::_laload :
   524           type = current_frame.pop_stack(
   525             VerificationType::integer_type(), CHECK_VERIFY(this));
   526           atype = current_frame.pop_stack(
   527             VerificationType::reference_check(), CHECK_VERIFY(this));
   528           if (!atype.is_long_array()) {
   529             verify_error(bci, bad_type_msg, "laload");
   530             return;
   531           }
   532           current_frame.push_stack_2(
   533             VerificationType::long_type(),
   534             VerificationType::long2_type(), CHECK_VERIFY(this));
   535           no_control_flow = false; break;
   536         case Bytecodes::_faload :
   537           type = current_frame.pop_stack(
   538             VerificationType::integer_type(), CHECK_VERIFY(this));
   539           atype = current_frame.pop_stack(
   540             VerificationType::reference_check(), CHECK_VERIFY(this));
   541           if (!atype.is_float_array()) {
   542             verify_error(bci, bad_type_msg, "faload");
   543             return;
   544           }
   545           current_frame.push_stack(
   546             VerificationType::float_type(), CHECK_VERIFY(this));
   547           no_control_flow = false; break;
   548         case Bytecodes::_daload :
   549           type = current_frame.pop_stack(
   550             VerificationType::integer_type(), CHECK_VERIFY(this));
   551           atype = current_frame.pop_stack(
   552             VerificationType::reference_check(), CHECK_VERIFY(this));
   553           if (!atype.is_double_array()) {
   554             verify_error(bci, bad_type_msg, "daload");
   555             return;
   556           }
   557           current_frame.push_stack_2(
   558             VerificationType::double_type(),
   559             VerificationType::double2_type(), CHECK_VERIFY(this));
   560           no_control_flow = false; break;
   561         case Bytecodes::_aaload : {
   562           type = current_frame.pop_stack(
   563             VerificationType::integer_type(), CHECK_VERIFY(this));
   564           atype = current_frame.pop_stack(
   565             VerificationType::reference_check(), CHECK_VERIFY(this));
   566           if (!atype.is_reference_array()) {
   567             verify_error(bci, bad_type_msg, "aaload");
   568             return;
   569           }
   570           if (atype.is_null()) {
   571             current_frame.push_stack(
   572               VerificationType::null_type(), CHECK_VERIFY(this));
   573           } else {
   574             VerificationType component =
   575               atype.get_component(CHECK_VERIFY(this));
   576             current_frame.push_stack(component, CHECK_VERIFY(this));
   577           }
   578           no_control_flow = false; break;
   579         }
   580         case Bytecodes::_istore :
   581           verify_istore(bcs.get_index(), &current_frame, CHECK_VERIFY(this));
   582           no_control_flow = false; break;
   583         case Bytecodes::_istore_0 :
   584         case Bytecodes::_istore_1 :
   585         case Bytecodes::_istore_2 :
   586         case Bytecodes::_istore_3 :
   587           index = opcode - Bytecodes::_istore_0;
   588           verify_istore(index, &current_frame, CHECK_VERIFY(this));
   589           no_control_flow = false; break;
   590         case Bytecodes::_lstore :
   591           verify_lstore(bcs.get_index(), &current_frame, CHECK_VERIFY(this));
   592           no_control_flow = false; break;
   593         case Bytecodes::_lstore_0 :
   594         case Bytecodes::_lstore_1 :
   595         case Bytecodes::_lstore_2 :
   596         case Bytecodes::_lstore_3 :
   597           index = opcode - Bytecodes::_lstore_0;
   598           verify_lstore(index, &current_frame, CHECK_VERIFY(this));
   599           no_control_flow = false; break;
   600         case Bytecodes::_fstore :
   601           verify_fstore(bcs.get_index(), &current_frame, CHECK_VERIFY(this));
   602           no_control_flow = false; break;
   603         case Bytecodes::_fstore_0 :
   604         case Bytecodes::_fstore_1 :
   605         case Bytecodes::_fstore_2 :
   606         case Bytecodes::_fstore_3 :
   607           index = opcode - Bytecodes::_fstore_0;
   608           verify_fstore(index, &current_frame, CHECK_VERIFY(this));
   609           no_control_flow = false; break;
   610         case Bytecodes::_dstore :
   611           verify_dstore(bcs.get_index(), &current_frame, CHECK_VERIFY(this));
   612           no_control_flow = false; break;
   613         case Bytecodes::_dstore_0 :
   614         case Bytecodes::_dstore_1 :
   615         case Bytecodes::_dstore_2 :
   616         case Bytecodes::_dstore_3 :
   617           index = opcode - Bytecodes::_dstore_0;
   618           verify_dstore(index, &current_frame, CHECK_VERIFY(this));
   619           no_control_flow = false; break;
   620         case Bytecodes::_astore :
   621           verify_astore(bcs.get_index(), &current_frame, CHECK_VERIFY(this));
   622           no_control_flow = false; break;
   623         case Bytecodes::_astore_0 :
   624         case Bytecodes::_astore_1 :
   625         case Bytecodes::_astore_2 :
   626         case Bytecodes::_astore_3 :
   627           index = opcode - Bytecodes::_astore_0;
   628           verify_astore(index, &current_frame, CHECK_VERIFY(this));
   629           no_control_flow = false; break;
   630         case Bytecodes::_iastore :
   631           type = current_frame.pop_stack(
   632             VerificationType::integer_type(), CHECK_VERIFY(this));
   633           type2 = current_frame.pop_stack(
   634             VerificationType::integer_type(), CHECK_VERIFY(this));
   635           atype = current_frame.pop_stack(
   636             VerificationType::reference_check(), CHECK_VERIFY(this));
   637           if (!atype.is_int_array()) {
   638             verify_error(bci, bad_type_msg, "iastore");
   639             return;
   640           }
   641           no_control_flow = false; break;
   642         case Bytecodes::_bastore :
   643           type = current_frame.pop_stack(
   644             VerificationType::integer_type(), CHECK_VERIFY(this));
   645           type2 = current_frame.pop_stack(
   646             VerificationType::integer_type(), CHECK_VERIFY(this));
   647           atype = current_frame.pop_stack(
   648             VerificationType::reference_check(), CHECK_VERIFY(this));
   649           if (!atype.is_bool_array() && !atype.is_byte_array()) {
   650             verify_error(bci, bad_type_msg, "bastore");
   651             return;
   652           }
   653           no_control_flow = false; break;
   654         case Bytecodes::_castore :
   655           current_frame.pop_stack(
   656             VerificationType::integer_type(), CHECK_VERIFY(this));
   657           current_frame.pop_stack(
   658             VerificationType::integer_type(), CHECK_VERIFY(this));
   659           atype = current_frame.pop_stack(
   660             VerificationType::reference_check(), CHECK_VERIFY(this));
   661           if (!atype.is_char_array()) {
   662             verify_error(bci, bad_type_msg, "castore");
   663             return;
   664           }
   665           no_control_flow = false; break;
   666         case Bytecodes::_sastore :
   667           current_frame.pop_stack(
   668             VerificationType::integer_type(), CHECK_VERIFY(this));
   669           current_frame.pop_stack(
   670             VerificationType::integer_type(), CHECK_VERIFY(this));
   671           atype = current_frame.pop_stack(
   672             VerificationType::reference_check(), CHECK_VERIFY(this));
   673           if (!atype.is_short_array()) {
   674             verify_error(bci, bad_type_msg, "sastore");
   675             return;
   676           }
   677           no_control_flow = false; break;
   678         case Bytecodes::_lastore :
   679           current_frame.pop_stack_2(
   680             VerificationType::long2_type(),
   681             VerificationType::long_type(), CHECK_VERIFY(this));
   682           current_frame.pop_stack(
   683             VerificationType::integer_type(), CHECK_VERIFY(this));
   684           atype = current_frame.pop_stack(
   685             VerificationType::reference_check(), CHECK_VERIFY(this));
   686           if (!atype.is_long_array()) {
   687             verify_error(bci, bad_type_msg, "lastore");
   688             return;
   689           }
   690           no_control_flow = false; break;
   691         case Bytecodes::_fastore :
   692           current_frame.pop_stack(
   693             VerificationType::float_type(), CHECK_VERIFY(this));
   694           current_frame.pop_stack
   695             (VerificationType::integer_type(), CHECK_VERIFY(this));
   696           atype = current_frame.pop_stack(
   697             VerificationType::reference_check(), CHECK_VERIFY(this));
   698           if (!atype.is_float_array()) {
   699             verify_error(bci, bad_type_msg, "fastore");
   700             return;
   701           }
   702           no_control_flow = false; break;
   703         case Bytecodes::_dastore :
   704           current_frame.pop_stack_2(
   705             VerificationType::double2_type(),
   706             VerificationType::double_type(), CHECK_VERIFY(this));
   707           current_frame.pop_stack(
   708             VerificationType::integer_type(), CHECK_VERIFY(this));
   709           atype = current_frame.pop_stack(
   710             VerificationType::reference_check(), CHECK_VERIFY(this));
   711           if (!atype.is_double_array()) {
   712             verify_error(bci, bad_type_msg, "dastore");
   713             return;
   714           }
   715           no_control_flow = false; break;
   716         case Bytecodes::_aastore :
   717           type = current_frame.pop_stack(
   718             VerificationType::reference_check(), CHECK_VERIFY(this));
   719           type2 = current_frame.pop_stack(
   720             VerificationType::integer_type(), CHECK_VERIFY(this));
   721           atype = current_frame.pop_stack(
   722             VerificationType::reference_check(), CHECK_VERIFY(this));
   723           // more type-checking is done at runtime
   724           if (!atype.is_reference_array()) {
   725             verify_error(bci, bad_type_msg, "aastore");
   726             return;
   727           }
   728           // 4938384: relaxed constraint in JVMS 3nd edition.
   729           no_control_flow = false; break;
   730         case Bytecodes::_pop :
   731           current_frame.pop_stack(
   732             VerificationType::category1_check(), CHECK_VERIFY(this));
   733           no_control_flow = false; break;
   734         case Bytecodes::_pop2 :
   735           type = current_frame.pop_stack(CHECK_VERIFY(this));
   736           if (type.is_category1()) {
   737             current_frame.pop_stack(
   738               VerificationType::category1_check(), CHECK_VERIFY(this));
   739           } else if (type.is_category2_2nd()) {
   740             current_frame.pop_stack(
   741               VerificationType::category2_check(), CHECK_VERIFY(this));
   742           } else {
   743             verify_error(bci, bad_type_msg, "pop2");
   744             return;
   745           }
   746           no_control_flow = false; break;
   747         case Bytecodes::_dup :
   748           type = current_frame.pop_stack(
   749             VerificationType::category1_check(), CHECK_VERIFY(this));
   750           current_frame.push_stack(type, CHECK_VERIFY(this));
   751           current_frame.push_stack(type, CHECK_VERIFY(this));
   752           no_control_flow = false; break;
   753         case Bytecodes::_dup_x1 :
   754           type = current_frame.pop_stack(
   755             VerificationType::category1_check(), CHECK_VERIFY(this));
   756           type2 = current_frame.pop_stack(
   757             VerificationType::category1_check(), CHECK_VERIFY(this));
   758           current_frame.push_stack(type, CHECK_VERIFY(this));
   759           current_frame.push_stack(type2, CHECK_VERIFY(this));
   760           current_frame.push_stack(type, CHECK_VERIFY(this));
   761           no_control_flow = false; break;
   762         case Bytecodes::_dup_x2 :
   763         {
   764           VerificationType type3;
   765           type = current_frame.pop_stack(
   766             VerificationType::category1_check(), CHECK_VERIFY(this));
   767           type2 = current_frame.pop_stack(CHECK_VERIFY(this));
   768           if (type2.is_category1()) {
   769             type3 = current_frame.pop_stack(
   770               VerificationType::category1_check(), CHECK_VERIFY(this));
   771           } else if (type2.is_category2_2nd()) {
   772             type3 = current_frame.pop_stack(
   773               VerificationType::category2_check(), CHECK_VERIFY(this));
   774           } else {
   775             verify_error(bci, bad_type_msg, "dup_x2");
   776             return;
   777           }
   778           current_frame.push_stack(type, CHECK_VERIFY(this));
   779           current_frame.push_stack(type3, CHECK_VERIFY(this));
   780           current_frame.push_stack(type2, CHECK_VERIFY(this));
   781           current_frame.push_stack(type, CHECK_VERIFY(this));
   782           no_control_flow = false; break;
   783         }
   784         case Bytecodes::_dup2 :
   785           type = current_frame.pop_stack(CHECK_VERIFY(this));
   786           if (type.is_category1()) {
   787             type2 = current_frame.pop_stack(
   788               VerificationType::category1_check(), CHECK_VERIFY(this));
   789           } else if (type.is_category2_2nd()) {
   790             type2 = current_frame.pop_stack(
   791               VerificationType::category2_check(), CHECK_VERIFY(this));
   792           } else {
   793             verify_error(bci, bad_type_msg, "dup2");
   794             return;
   795           }
   796           current_frame.push_stack(type2, CHECK_VERIFY(this));
   797           current_frame.push_stack(type, CHECK_VERIFY(this));
   798           current_frame.push_stack(type2, CHECK_VERIFY(this));
   799           current_frame.push_stack(type, CHECK_VERIFY(this));
   800           no_control_flow = false; break;
   801         case Bytecodes::_dup2_x1 :
   802         {
   803           VerificationType type3;
   804           type = current_frame.pop_stack(CHECK_VERIFY(this));
   805           if (type.is_category1()) {
   806             type2 = current_frame.pop_stack(
   807               VerificationType::category1_check(), CHECK_VERIFY(this));
   808           } else if(type.is_category2_2nd()) {
   809             type2 = current_frame.pop_stack
   810               (VerificationType::category2_check(), CHECK_VERIFY(this));
   811           } else {
   812             verify_error(bci, bad_type_msg, "dup2_x1");
   813             return;
   814           }
   815           type3 = current_frame.pop_stack(
   816             VerificationType::category1_check(), CHECK_VERIFY(this));
   817           current_frame.push_stack(type2, CHECK_VERIFY(this));
   818           current_frame.push_stack(type, CHECK_VERIFY(this));
   819           current_frame.push_stack(type3, CHECK_VERIFY(this));
   820           current_frame.push_stack(type2, CHECK_VERIFY(this));
   821           current_frame.push_stack(type, CHECK_VERIFY(this));
   822           no_control_flow = false; break;
   823         }
   824         case Bytecodes::_dup2_x2 :
   825         {
   826           VerificationType type3, type4;
   827           type = current_frame.pop_stack(CHECK_VERIFY(this));
   828           if (type.is_category1()) {
   829             type2 = current_frame.pop_stack(
   830               VerificationType::category1_check(), CHECK_VERIFY(this));
   831           } else if (type.is_category2_2nd()) {
   832             type2 = current_frame.pop_stack(
   833               VerificationType::category2_check(), CHECK_VERIFY(this));
   834           } else {
   835             verify_error(bci, bad_type_msg, "dup2_x2");
   836             return;
   837           }
   838           type3 = current_frame.pop_stack(CHECK_VERIFY(this));
   839           if (type3.is_category1()) {
   840             type4 = current_frame.pop_stack(
   841               VerificationType::category1_check(), CHECK_VERIFY(this));
   842           } else if (type3.is_category2_2nd()) {
   843             type4 = current_frame.pop_stack(
   844               VerificationType::category2_check(), CHECK_VERIFY(this));
   845           } else {
   846             verify_error(bci, bad_type_msg, "dup2_x2");
   847             return;
   848           }
   849           current_frame.push_stack(type2, CHECK_VERIFY(this));
   850           current_frame.push_stack(type, CHECK_VERIFY(this));
   851           current_frame.push_stack(type4, CHECK_VERIFY(this));
   852           current_frame.push_stack(type3, CHECK_VERIFY(this));
   853           current_frame.push_stack(type2, CHECK_VERIFY(this));
   854           current_frame.push_stack(type, CHECK_VERIFY(this));
   855           no_control_flow = false; break;
   856         }
   857         case Bytecodes::_swap :
   858           type = current_frame.pop_stack(
   859             VerificationType::category1_check(), CHECK_VERIFY(this));
   860           type2 = current_frame.pop_stack(
   861             VerificationType::category1_check(), CHECK_VERIFY(this));
   862           current_frame.push_stack(type, CHECK_VERIFY(this));
   863           current_frame.push_stack(type2, CHECK_VERIFY(this));
   864           no_control_flow = false; break;
   865         case Bytecodes::_iadd :
   866         case Bytecodes::_isub :
   867         case Bytecodes::_imul :
   868         case Bytecodes::_idiv :
   869         case Bytecodes::_irem :
   870         case Bytecodes::_ishl :
   871         case Bytecodes::_ishr :
   872         case Bytecodes::_iushr :
   873         case Bytecodes::_ior :
   874         case Bytecodes::_ixor :
   875         case Bytecodes::_iand :
   876           current_frame.pop_stack(
   877             VerificationType::integer_type(), CHECK_VERIFY(this));
   878           // fall through
   879         case Bytecodes::_ineg :
   880           current_frame.pop_stack(
   881             VerificationType::integer_type(), CHECK_VERIFY(this));
   882           current_frame.push_stack(
   883             VerificationType::integer_type(), CHECK_VERIFY(this));
   884           no_control_flow = false; break;
   885         case Bytecodes::_ladd :
   886         case Bytecodes::_lsub :
   887         case Bytecodes::_lmul :
   888         case Bytecodes::_ldiv :
   889         case Bytecodes::_lrem :
   890         case Bytecodes::_land :
   891         case Bytecodes::_lor :
   892         case Bytecodes::_lxor :
   893           current_frame.pop_stack_2(
   894             VerificationType::long2_type(),
   895             VerificationType::long_type(), CHECK_VERIFY(this));
   896           // fall through
   897         case Bytecodes::_lneg :
   898           current_frame.pop_stack_2(
   899             VerificationType::long2_type(),
   900             VerificationType::long_type(), CHECK_VERIFY(this));
   901           current_frame.push_stack_2(
   902             VerificationType::long_type(),
   903             VerificationType::long2_type(), CHECK_VERIFY(this));
   904           no_control_flow = false; break;
   905         case Bytecodes::_lshl :
   906         case Bytecodes::_lshr :
   907         case Bytecodes::_lushr :
   908           current_frame.pop_stack(
   909             VerificationType::integer_type(), CHECK_VERIFY(this));
   910           current_frame.pop_stack_2(
   911             VerificationType::long2_type(),
   912             VerificationType::long_type(), CHECK_VERIFY(this));
   913           current_frame.push_stack_2(
   914             VerificationType::long_type(),
   915             VerificationType::long2_type(), CHECK_VERIFY(this));
   916           no_control_flow = false; break;
   917         case Bytecodes::_fadd :
   918         case Bytecodes::_fsub :
   919         case Bytecodes::_fmul :
   920         case Bytecodes::_fdiv :
   921         case Bytecodes::_frem :
   922           current_frame.pop_stack(
   923             VerificationType::float_type(), CHECK_VERIFY(this));
   924           // fall through
   925         case Bytecodes::_fneg :
   926           current_frame.pop_stack(
   927             VerificationType::float_type(), CHECK_VERIFY(this));
   928           current_frame.push_stack(
   929             VerificationType::float_type(), CHECK_VERIFY(this));
   930           no_control_flow = false; break;
   931         case Bytecodes::_dadd :
   932         case Bytecodes::_dsub :
   933         case Bytecodes::_dmul :
   934         case Bytecodes::_ddiv :
   935         case Bytecodes::_drem :
   936           current_frame.pop_stack_2(
   937             VerificationType::double2_type(),
   938             VerificationType::double_type(), CHECK_VERIFY(this));
   939           // fall through
   940         case Bytecodes::_dneg :
   941           current_frame.pop_stack_2(
   942             VerificationType::double2_type(),
   943             VerificationType::double_type(), CHECK_VERIFY(this));
   944           current_frame.push_stack_2(
   945             VerificationType::double_type(),
   946             VerificationType::double2_type(), CHECK_VERIFY(this));
   947           no_control_flow = false; break;
   948         case Bytecodes::_iinc :
   949           verify_iinc(bcs.get_index(), &current_frame, CHECK_VERIFY(this));
   950           no_control_flow = false; break;
   951         case Bytecodes::_i2l :
   952           type = current_frame.pop_stack(
   953             VerificationType::integer_type(), CHECK_VERIFY(this));
   954           current_frame.push_stack_2(
   955             VerificationType::long_type(),
   956             VerificationType::long2_type(), CHECK_VERIFY(this));
   957           no_control_flow = false; break;
   958        case Bytecodes::_l2i :
   959           current_frame.pop_stack_2(
   960             VerificationType::long2_type(),
   961             VerificationType::long_type(), CHECK_VERIFY(this));
   962           current_frame.push_stack(
   963             VerificationType::integer_type(), CHECK_VERIFY(this));
   964           no_control_flow = false; break;
   965         case Bytecodes::_i2f :
   966           current_frame.pop_stack(
   967             VerificationType::integer_type(), CHECK_VERIFY(this));
   968           current_frame.push_stack(
   969             VerificationType::float_type(), CHECK_VERIFY(this));
   970           no_control_flow = false; break;
   971         case Bytecodes::_i2d :
   972           current_frame.pop_stack(
   973             VerificationType::integer_type(), CHECK_VERIFY(this));
   974           current_frame.push_stack_2(
   975             VerificationType::double_type(),
   976             VerificationType::double2_type(), CHECK_VERIFY(this));
   977           no_control_flow = false; break;
   978         case Bytecodes::_l2f :
   979           current_frame.pop_stack_2(
   980             VerificationType::long2_type(),
   981             VerificationType::long_type(), CHECK_VERIFY(this));
   982           current_frame.push_stack(
   983             VerificationType::float_type(), CHECK_VERIFY(this));
   984           no_control_flow = false; break;
   985         case Bytecodes::_l2d :
   986           current_frame.pop_stack_2(
   987             VerificationType::long2_type(),
   988             VerificationType::long_type(), CHECK_VERIFY(this));
   989           current_frame.push_stack_2(
   990             VerificationType::double_type(),
   991             VerificationType::double2_type(), CHECK_VERIFY(this));
   992           no_control_flow = false; break;
   993         case Bytecodes::_f2i :
   994           current_frame.pop_stack(
   995             VerificationType::float_type(), CHECK_VERIFY(this));
   996           current_frame.push_stack(
   997             VerificationType::integer_type(), CHECK_VERIFY(this));
   998           no_control_flow = false; break;
   999         case Bytecodes::_f2l :
  1000           current_frame.pop_stack(
  1001             VerificationType::float_type(), CHECK_VERIFY(this));
  1002           current_frame.push_stack_2(
  1003             VerificationType::long_type(),
  1004             VerificationType::long2_type(), CHECK_VERIFY(this));
  1005           no_control_flow = false; break;
  1006         case Bytecodes::_f2d :
  1007           current_frame.pop_stack(
  1008             VerificationType::float_type(), CHECK_VERIFY(this));
  1009           current_frame.push_stack_2(
  1010             VerificationType::double_type(),
  1011             VerificationType::double2_type(), CHECK_VERIFY(this));
  1012           no_control_flow = false; break;
  1013         case Bytecodes::_d2i :
  1014           current_frame.pop_stack_2(
  1015             VerificationType::double2_type(),
  1016             VerificationType::double_type(), CHECK_VERIFY(this));
  1017           current_frame.push_stack(
  1018             VerificationType::integer_type(), CHECK_VERIFY(this));
  1019           no_control_flow = false; break;
  1020         case Bytecodes::_d2l :
  1021           current_frame.pop_stack_2(
  1022             VerificationType::double2_type(),
  1023             VerificationType::double_type(), CHECK_VERIFY(this));
  1024           current_frame.push_stack_2(
  1025             VerificationType::long_type(),
  1026             VerificationType::long2_type(), CHECK_VERIFY(this));
  1027           no_control_flow = false; break;
  1028         case Bytecodes::_d2f :
  1029           current_frame.pop_stack_2(
  1030             VerificationType::double2_type(),
  1031             VerificationType::double_type(), CHECK_VERIFY(this));
  1032           current_frame.push_stack(
  1033             VerificationType::float_type(), CHECK_VERIFY(this));
  1034           no_control_flow = false; break;
  1035         case Bytecodes::_i2b :
  1036         case Bytecodes::_i2c :
  1037         case Bytecodes::_i2s :
  1038           current_frame.pop_stack(
  1039             VerificationType::integer_type(), CHECK_VERIFY(this));
  1040           current_frame.push_stack(
  1041             VerificationType::integer_type(), CHECK_VERIFY(this));
  1042           no_control_flow = false; break;
  1043         case Bytecodes::_lcmp :
  1044           current_frame.pop_stack_2(
  1045             VerificationType::long2_type(),
  1046             VerificationType::long_type(), CHECK_VERIFY(this));
  1047           current_frame.pop_stack_2(
  1048             VerificationType::long2_type(),
  1049             VerificationType::long_type(), CHECK_VERIFY(this));
  1050           current_frame.push_stack(
  1051             VerificationType::integer_type(), CHECK_VERIFY(this));
  1052           no_control_flow = false; break;
  1053         case Bytecodes::_fcmpl :
  1054         case Bytecodes::_fcmpg :
  1055           current_frame.pop_stack(
  1056             VerificationType::float_type(), CHECK_VERIFY(this));
  1057           current_frame.pop_stack(
  1058             VerificationType::float_type(), CHECK_VERIFY(this));
  1059           current_frame.push_stack(
  1060             VerificationType::integer_type(), CHECK_VERIFY(this));
  1061           no_control_flow = false; break;
  1062         case Bytecodes::_dcmpl :
  1063         case Bytecodes::_dcmpg :
  1064           current_frame.pop_stack_2(
  1065             VerificationType::double2_type(),
  1066             VerificationType::double_type(), CHECK_VERIFY(this));
  1067           current_frame.pop_stack_2(
  1068             VerificationType::double2_type(),
  1069             VerificationType::double_type(), CHECK_VERIFY(this));
  1070           current_frame.push_stack(
  1071             VerificationType::integer_type(), CHECK_VERIFY(this));
  1072           no_control_flow = false; break;
  1073         case Bytecodes::_if_icmpeq:
  1074         case Bytecodes::_if_icmpne:
  1075         case Bytecodes::_if_icmplt:
  1076         case Bytecodes::_if_icmpge:
  1077         case Bytecodes::_if_icmpgt:
  1078         case Bytecodes::_if_icmple:
  1079           current_frame.pop_stack(
  1080             VerificationType::integer_type(), CHECK_VERIFY(this));
  1081           // fall through
  1082         case Bytecodes::_ifeq:
  1083         case Bytecodes::_ifne:
  1084         case Bytecodes::_iflt:
  1085         case Bytecodes::_ifge:
  1086         case Bytecodes::_ifgt:
  1087         case Bytecodes::_ifle:
  1088           current_frame.pop_stack(
  1089             VerificationType::integer_type(), CHECK_VERIFY(this));
  1090           target = bcs.dest();
  1091           stackmap_table.check_jump_target(
  1092             &current_frame, target, CHECK_VERIFY(this));
  1093           no_control_flow = false; break;
  1094         case Bytecodes::_if_acmpeq :
  1095         case Bytecodes::_if_acmpne :
  1096           current_frame.pop_stack(
  1097             VerificationType::reference_check(), CHECK_VERIFY(this));
  1098           // fall through
  1099         case Bytecodes::_ifnull :
  1100         case Bytecodes::_ifnonnull :
  1101           current_frame.pop_stack(
  1102             VerificationType::reference_check(), CHECK_VERIFY(this));
  1103           target = bcs.dest();
  1104           stackmap_table.check_jump_target
  1105             (&current_frame, target, CHECK_VERIFY(this));
  1106           no_control_flow = false; break;
  1107         case Bytecodes::_goto :
  1108           target = bcs.dest();
  1109           stackmap_table.check_jump_target(
  1110             &current_frame, target, CHECK_VERIFY(this));
  1111           no_control_flow = true; break;
  1112         case Bytecodes::_goto_w :
  1113           target = bcs.dest_w();
  1114           stackmap_table.check_jump_target(
  1115             &current_frame, target, CHECK_VERIFY(this));
  1116           no_control_flow = true; break;
  1117         case Bytecodes::_tableswitch :
  1118         case Bytecodes::_lookupswitch :
  1119           verify_switch(
  1120             &bcs, code_length, code_data, &current_frame,
  1121             &stackmap_table, CHECK_VERIFY(this));
  1122           no_control_flow = true; break;
  1123         case Bytecodes::_ireturn :
  1124           type = current_frame.pop_stack(
  1125             VerificationType::integer_type(), CHECK_VERIFY(this));
  1126           verify_return_value(return_type, type, bci, CHECK_VERIFY(this));
  1127           no_control_flow = true; break;
  1128         case Bytecodes::_lreturn :
  1129           type2 = current_frame.pop_stack(
  1130             VerificationType::long2_type(), CHECK_VERIFY(this));
  1131           type = current_frame.pop_stack(
  1132             VerificationType::long_type(), CHECK_VERIFY(this));
  1133           verify_return_value(return_type, type, bci, CHECK_VERIFY(this));
  1134           no_control_flow = true; break;
  1135         case Bytecodes::_freturn :
  1136           type = current_frame.pop_stack(
  1137             VerificationType::float_type(), CHECK_VERIFY(this));
  1138           verify_return_value(return_type, type, bci, CHECK_VERIFY(this));
  1139           no_control_flow = true; break;
  1140         case Bytecodes::_dreturn :
  1141           type2 = current_frame.pop_stack(
  1142             VerificationType::double2_type(),  CHECK_VERIFY(this));
  1143           type = current_frame.pop_stack(
  1144             VerificationType::double_type(), CHECK_VERIFY(this));
  1145           verify_return_value(return_type, type, bci, CHECK_VERIFY(this));
  1146           no_control_flow = true; break;
  1147         case Bytecodes::_areturn :
  1148           type = current_frame.pop_stack(
  1149             VerificationType::reference_check(), CHECK_VERIFY(this));
  1150           verify_return_value(return_type, type, bci, CHECK_VERIFY(this));
  1151           no_control_flow = true; break;
  1152         case Bytecodes::_return :
  1153           if (return_type != VerificationType::bogus_type()) {
  1154             verify_error(bci, "Method expects no return value");
  1155             return;
  1157           // Make sure "this" has been initialized if current method is an
  1158           // <init>
  1159           if (_method->name() == vmSymbols::object_initializer_name() &&
  1160               current_frame.flag_this_uninit()) {
  1161             verify_error(bci,
  1162               "Constructor must call super() or this() before return");
  1163             return;
  1165           no_control_flow = true; break;
  1166         case Bytecodes::_getstatic :
  1167         case Bytecodes::_putstatic :
  1168         case Bytecodes::_getfield :
  1169         case Bytecodes::_putfield :
  1170           verify_field_instructions(
  1171             &bcs, &current_frame, cp, CHECK_VERIFY(this));
  1172           no_control_flow = false; break;
  1173         case Bytecodes::_invokevirtual :
  1174         case Bytecodes::_invokespecial :
  1175         case Bytecodes::_invokestatic :
  1176           verify_invoke_instructions(
  1177             &bcs, code_length, &current_frame,
  1178             &this_uninit, return_type, cp, CHECK_VERIFY(this));
  1179           no_control_flow = false; break;
  1180         case Bytecodes::_invokeinterface :
  1181         case Bytecodes::_invokedynamic :
  1182           verify_invoke_instructions(
  1183             &bcs, code_length, &current_frame,
  1184             &this_uninit, return_type, cp, CHECK_VERIFY(this));
  1185           no_control_flow = false; break;
  1186         case Bytecodes::_new :
  1188           index = bcs.get_index_big();
  1189           verify_cp_class_type(index, cp, CHECK_VERIFY(this));
  1190           VerificationType new_class_type =
  1191             cp_index_to_type(index, cp, CHECK_VERIFY(this));
  1192           if (!new_class_type.is_object()) {
  1193             verify_error(bci, "Illegal new instruction");
  1194             return;
  1196           type = VerificationType::uninitialized_type(bci);
  1197           current_frame.push_stack(type, CHECK_VERIFY(this));
  1198           no_control_flow = false; break;
  1200         case Bytecodes::_newarray :
  1201           type = get_newarray_type(bcs.get_index(), bci, CHECK_VERIFY(this));
  1202           current_frame.pop_stack(
  1203             VerificationType::integer_type(),  CHECK_VERIFY(this));
  1204           current_frame.push_stack(type, CHECK_VERIFY(this));
  1205           no_control_flow = false; break;
  1206         case Bytecodes::_anewarray :
  1207           verify_anewarray(
  1208             bcs.get_index_big(), cp, &current_frame, CHECK_VERIFY(this));
  1209           no_control_flow = false; break;
  1210         case Bytecodes::_arraylength :
  1211           type = current_frame.pop_stack(
  1212             VerificationType::reference_check(), CHECK_VERIFY(this));
  1213           if (!(type.is_null() || type.is_array())) {
  1214             verify_error(bci, bad_type_msg, "arraylength");
  1216           current_frame.push_stack(
  1217             VerificationType::integer_type(), CHECK_VERIFY(this));
  1218           no_control_flow = false; break;
  1219         case Bytecodes::_checkcast :
  1221           index = bcs.get_index_big();
  1222           verify_cp_class_type(index, cp, CHECK_VERIFY(this));
  1223           current_frame.pop_stack(
  1224             VerificationType::reference_check(), CHECK_VERIFY(this));
  1225           VerificationType klass_type = cp_index_to_type(
  1226             index, cp, CHECK_VERIFY(this));
  1227           current_frame.push_stack(klass_type, CHECK_VERIFY(this));
  1228           no_control_flow = false; break;
  1230         case Bytecodes::_instanceof : {
  1231           index = bcs.get_index_big();
  1232           verify_cp_class_type(index, cp, CHECK_VERIFY(this));
  1233           current_frame.pop_stack(
  1234             VerificationType::reference_check(), CHECK_VERIFY(this));
  1235           current_frame.push_stack(
  1236             VerificationType::integer_type(), CHECK_VERIFY(this));
  1237           no_control_flow = false; break;
  1239         case Bytecodes::_monitorenter :
  1240         case Bytecodes::_monitorexit :
  1241           current_frame.pop_stack(
  1242             VerificationType::reference_check(), CHECK_VERIFY(this));
  1243           no_control_flow = false; break;
  1244         case Bytecodes::_multianewarray :
  1246           index = bcs.get_index_big();
  1247           u2 dim = *(bcs.bcp()+3);
  1248           verify_cp_class_type(index, cp, CHECK_VERIFY(this));
  1249           VerificationType new_array_type =
  1250             cp_index_to_type(index, cp, CHECK_VERIFY(this));
  1251           if (!new_array_type.is_array()) {
  1252             verify_error(bci,
  1253               "Illegal constant pool index in multianewarray instruction");
  1254             return;
  1256           if (dim < 1 || new_array_type.dimensions() < dim) {
  1257             verify_error(bci,
  1258               "Illegal dimension in multianewarray instruction");
  1259             return;
  1261           for (int i = 0; i < dim; i++) {
  1262             current_frame.pop_stack(
  1263               VerificationType::integer_type(), CHECK_VERIFY(this));
  1265           current_frame.push_stack(new_array_type, CHECK_VERIFY(this));
  1266           no_control_flow = false; break;
  1268         case Bytecodes::_athrow :
  1269           type = VerificationType::reference_type(
  1270             vmSymbols::java_lang_Throwable());
  1271           current_frame.pop_stack(type, CHECK_VERIFY(this));
  1272           no_control_flow = true; break;
  1273         default:
  1274           // We only need to check the valid bytecodes in class file.
  1275           // And jsr and ret are not in the new class file format in JDK1.5.
  1276           verify_error(bci, "Bad instruction");
  1277           no_control_flow = false;
  1278           return;
  1279       }  // end switch
  1280     }  // end Merge with the next instruction
  1282     // Look for possible jump target in exception handlers and see if it
  1283     // matches current_frame
  1284     if (bci >= ex_min && bci < ex_max) {
  1285       verify_exception_handler_targets(
  1286         bci, this_uninit, &current_frame, &stackmap_table, CHECK_VERIFY(this));
  1288   } // end while
  1290   // Make sure that control flow does not fall through end of the method
  1291   if (!no_control_flow) {
  1292     verify_error(code_length, "Control flow falls through code end");
  1293     return;
  1297 char* ClassVerifier::generate_code_data(methodHandle m, u4 code_length, TRAPS) {
  1298   char* code_data = NEW_RESOURCE_ARRAY(char, code_length);
  1299   memset(code_data, 0, sizeof(char) * code_length);
  1300   RawBytecodeStream bcs(m);
  1302   while (!bcs.is_last_bytecode()) {
  1303     if (bcs.raw_next() != Bytecodes::_illegal) {
  1304       int bci = bcs.bci();
  1305       if (bcs.code() == Bytecodes::_new) {
  1306         code_data[bci] = NEW_OFFSET;
  1307       } else {
  1308         code_data[bci] = BYTECODE_OFFSET;
  1310     } else {
  1311       verify_error(bcs.bci(), "Bad instruction");
  1312       return NULL;
  1316   return code_data;
  1319 void ClassVerifier::verify_exception_handler_table(u4 code_length, char* code_data, int& min, int& max, TRAPS) {
  1320   typeArrayHandle exhandlers (THREAD, _method->exception_table());
  1321   constantPoolHandle cp (THREAD, _method->constants());
  1323   if (exhandlers() != NULL) {
  1324     for(int i = 0; i < exhandlers->length();) {
  1325       u2 start_pc = exhandlers->int_at(i++);
  1326       u2 end_pc = exhandlers->int_at(i++);
  1327       u2 handler_pc = exhandlers->int_at(i++);
  1328       if (start_pc >= code_length || code_data[start_pc] == 0) {
  1329         class_format_error("Illegal exception table start_pc %d", start_pc);
  1330         return;
  1332       if (end_pc != code_length) {   // special case: end_pc == code_length
  1333         if (end_pc > code_length || code_data[end_pc] == 0) {
  1334           class_format_error("Illegal exception table end_pc %d", end_pc);
  1335           return;
  1338       if (handler_pc >= code_length || code_data[handler_pc] == 0) {
  1339         class_format_error("Illegal exception table handler_pc %d", handler_pc);
  1340         return;
  1342       int catch_type_index = exhandlers->int_at(i++);
  1343       if (catch_type_index != 0) {
  1344         VerificationType catch_type = cp_index_to_type(
  1345           catch_type_index, cp, CHECK_VERIFY(this));
  1346         VerificationType throwable =
  1347           VerificationType::reference_type(vmSymbols::java_lang_Throwable());
  1348         bool is_subclass = throwable.is_assignable_from(
  1349           catch_type, current_class(), CHECK_VERIFY(this));
  1350         if (!is_subclass) {
  1351           // 4286534: should throw VerifyError according to recent spec change
  1352           verify_error(
  1353             "Catch type is not a subclass of Throwable in handler %d",
  1354             handler_pc);
  1355           return;
  1358       if (start_pc < min) min = start_pc;
  1359       if (end_pc > max) max = end_pc;
  1364 void ClassVerifier::verify_local_variable_table(u4 code_length, char* code_data, TRAPS) {
  1365   int localvariable_table_length = _method()->localvariable_table_length();
  1366   if (localvariable_table_length > 0) {
  1367     LocalVariableTableElement* table = _method()->localvariable_table_start();
  1368     for (int i = 0; i < localvariable_table_length; i++) {
  1369       u2 start_bci = table[i].start_bci;
  1370       u2 length = table[i].length;
  1372       if (start_bci >= code_length || code_data[start_bci] == 0) {
  1373         class_format_error(
  1374           "Illegal local variable table start_pc %d", start_bci);
  1375         return;
  1377       u4 end_bci = (u4)(start_bci + length);
  1378       if (end_bci != code_length) {
  1379         if (end_bci >= code_length || code_data[end_bci] == 0) {
  1380           class_format_error( "Illegal local variable table length %d", length);
  1381           return;
  1388 u2 ClassVerifier::verify_stackmap_table(u2 stackmap_index, u2 bci,
  1389                                         StackMapFrame* current_frame,
  1390                                         StackMapTable* stackmap_table,
  1391                                         bool no_control_flow, TRAPS) {
  1392   if (stackmap_index < stackmap_table->get_frame_count()) {
  1393     u2 this_offset = stackmap_table->get_offset(stackmap_index);
  1394     if (no_control_flow && this_offset > bci) {
  1395       verify_error(bci, "Expecting a stack map frame");
  1396       return 0;
  1398     if (this_offset == bci) {
  1399       // See if current stack map can be assigned to the frame in table.
  1400       // current_frame is the stackmap frame got from the last instruction.
  1401       // If matched, current_frame will be updated by this method.
  1402       bool match = stackmap_table->match_stackmap(
  1403         current_frame, this_offset, stackmap_index,
  1404         !no_control_flow, true, CHECK_VERIFY_(this, 0));
  1405       if (!match) {
  1406         // report type error
  1407         verify_error(bci, "Instruction type does not match stack map");
  1408         return 0;
  1410       stackmap_index++;
  1411     } else if (this_offset < bci) {
  1412       // current_offset should have met this_offset.
  1413       class_format_error("Bad stack map offset %d", this_offset);
  1414       return 0;
  1416   } else if (no_control_flow) {
  1417     verify_error(bci, "Expecting a stack map frame");
  1418     return 0;
  1420   return stackmap_index;
  1423 void ClassVerifier::verify_exception_handler_targets(u2 bci, bool this_uninit, StackMapFrame* current_frame,
  1424                                                      StackMapTable* stackmap_table, TRAPS) {
  1425   constantPoolHandle cp (THREAD, _method->constants());
  1426   typeArrayHandle exhandlers (THREAD, _method->exception_table());
  1427   if (exhandlers() != NULL) {
  1428     for(int i = 0; i < exhandlers->length();) {
  1429       u2 start_pc = exhandlers->int_at(i++);
  1430       u2 end_pc = exhandlers->int_at(i++);
  1431       u2 handler_pc = exhandlers->int_at(i++);
  1432       int catch_type_index = exhandlers->int_at(i++);
  1433       if(bci >= start_pc && bci < end_pc) {
  1434         u1 flags = current_frame->flags();
  1435         if (this_uninit) {  flags |= FLAG_THIS_UNINIT; }
  1437         ResourceMark rm(THREAD);
  1438         StackMapFrame* new_frame = current_frame->frame_in_exception_handler(flags);
  1439         if (catch_type_index != 0) {
  1440           // We know that this index refers to a subclass of Throwable
  1441           VerificationType catch_type = cp_index_to_type(
  1442             catch_type_index, cp, CHECK_VERIFY(this));
  1443           new_frame->push_stack(catch_type, CHECK_VERIFY(this));
  1444         } else {
  1445           VerificationType throwable =
  1446             VerificationType::reference_type(vmSymbols::java_lang_Throwable());
  1447           new_frame->push_stack(throwable, CHECK_VERIFY(this));
  1449         bool match = stackmap_table->match_stackmap(
  1450           new_frame, handler_pc, true, false, CHECK_VERIFY(this));
  1451         if (!match) {
  1452           verify_error(bci,
  1453             "Stack map does not match the one at exception handler %d",
  1454             handler_pc);
  1455           return;
  1462 void ClassVerifier::verify_cp_index(constantPoolHandle cp, int index, TRAPS) {
  1463   int nconstants = cp->length();
  1464   if ((index <= 0) || (index >= nconstants)) {
  1465     verify_error("Illegal constant pool index %d in class %s",
  1466       index, instanceKlass::cast(cp->pool_holder())->external_name());
  1467     return;
  1471 void ClassVerifier::verify_cp_type(
  1472     int index, constantPoolHandle cp, unsigned int types, TRAPS) {
  1474   // In some situations, bytecode rewriting may occur while we're verifying.
  1475   // In this case, a constant pool cache exists and some indices refer to that
  1476   // instead.  Get the original index for the tag check
  1477   constantPoolCacheOop cache = cp->cache();
  1478   if (cache != NULL &&
  1479        ((types == (1 <<  JVM_CONSTANT_InterfaceMethodref)) ||
  1480         (types == (1 <<  JVM_CONSTANT_Methodref)) ||
  1481         (types == (1 <<  JVM_CONSTANT_Fieldref)))) {
  1482     int native_index = index;
  1483     if (Bytes::is_Java_byte_ordering_different()) {
  1484       native_index = Bytes::swap_u2(index);
  1486     assert((native_index >= 0) && (native_index < cache->length()),
  1487       "Must be a legal index into the cp cache");
  1488     index = cache->entry_at(native_index)->constant_pool_index();
  1491   verify_cp_index(cp, index, CHECK_VERIFY(this));
  1492   unsigned int tag = cp->tag_at(index).value();
  1493   if ((types & (1 << tag)) == 0) {
  1494     verify_error(
  1495       "Illegal type at constant pool entry %d in class %s",
  1496       index, instanceKlass::cast(cp->pool_holder())->external_name());
  1497     return;
  1501 void ClassVerifier::verify_cp_class_type(
  1502     int index, constantPoolHandle cp, TRAPS) {
  1503   verify_cp_index(cp, index, CHECK_VERIFY(this));
  1504   constantTag tag = cp->tag_at(index);
  1505   if (!tag.is_klass() && !tag.is_unresolved_klass()) {
  1506     verify_error("Illegal type at constant pool entry %d in class %s",
  1507       index, instanceKlass::cast(cp->pool_holder())->external_name());
  1508     return;
  1512 void ClassVerifier::format_error_message(
  1513     const char* fmt, int offset, va_list va) {
  1514   ResourceMark rm(_thread);
  1515   stringStream message(_message, _message_buffer_len);
  1516   message.vprint(fmt, va);
  1517   if (!_method.is_null()) {
  1518     message.print(" in method %s", _method->name_and_sig_as_C_string());
  1520   if (offset != -1) {
  1521     message.print(" at offset %d", offset);
  1525 void ClassVerifier::verify_error(u2 offset, const char* fmt, ...) {
  1526   _exception_type = vmSymbols::java_lang_VerifyError();
  1527   va_list va;
  1528   va_start(va, fmt);
  1529   format_error_message(fmt, offset, va);
  1530   va_end(va);
  1533 void ClassVerifier::verify_error(const char* fmt, ...) {
  1534   _exception_type = vmSymbols::java_lang_VerifyError();
  1535   va_list va;
  1536   va_start(va, fmt);
  1537   format_error_message(fmt, -1, va);
  1538   va_end(va);
  1541 void ClassVerifier::class_format_error(const char* msg, ...) {
  1542   _exception_type = vmSymbols::java_lang_ClassFormatError();
  1543   va_list va;
  1544   va_start(va, msg);
  1545   format_error_message(msg, -1, va);
  1546   va_end(va);
  1549 klassOop ClassVerifier::load_class(symbolHandle name, TRAPS) {
  1550   // Get current loader and protection domain first.
  1551   oop loader = current_class()->class_loader();
  1552   oop protection_domain = current_class()->protection_domain();
  1554   return SystemDictionary::resolve_or_fail(
  1555     name, Handle(THREAD, loader), Handle(THREAD, protection_domain),
  1556     true, CHECK_NULL);
  1559 bool ClassVerifier::is_protected_access(instanceKlassHandle this_class,
  1560                                         klassOop target_class,
  1561                                         symbolOop field_name,
  1562                                         symbolOop field_sig,
  1563                                         bool is_method) {
  1564   No_Safepoint_Verifier nosafepoint;
  1566   // If target class isn't a super class of this class, we don't worry about this case
  1567   if (!this_class->is_subclass_of(target_class)) {
  1568     return false;
  1570   // Check if the specified method or field is protected
  1571   instanceKlass* target_instance = instanceKlass::cast(target_class);
  1572   fieldDescriptor fd;
  1573   if (is_method) {
  1574     methodOop m = target_instance->uncached_lookup_method(field_name, field_sig);
  1575     if (m != NULL && m->is_protected()) {
  1576       if (!this_class->is_same_class_package(m->method_holder())) {
  1577         return true;
  1580   } else {
  1581     klassOop member_klass = target_instance->find_field(field_name, field_sig, &fd);
  1582     if(member_klass != NULL && fd.is_protected()) {
  1583       if (!this_class->is_same_class_package(member_klass)) {
  1584         return true;
  1588   return false;
  1591 void ClassVerifier::verify_ldc(
  1592     int opcode, u2 index, StackMapFrame *current_frame,
  1593      constantPoolHandle cp, u2 bci, TRAPS) {
  1594   verify_cp_index(cp, index, CHECK_VERIFY(this));
  1595   constantTag tag = cp->tag_at(index);
  1596   unsigned int types;
  1597   if (opcode == Bytecodes::_ldc || opcode == Bytecodes::_ldc_w) {
  1598     if (!tag.is_unresolved_string() && !tag.is_unresolved_klass()) {
  1599       types = (1 << JVM_CONSTANT_Integer) | (1 << JVM_CONSTANT_Float)
  1600             | (1 << JVM_CONSTANT_String)  | (1 << JVM_CONSTANT_Class);
  1601       verify_cp_type(index, cp, types, CHECK_VERIFY(this));
  1603   } else {
  1604     assert(opcode == Bytecodes::_ldc2_w, "must be ldc2_w");
  1605     types = (1 << JVM_CONSTANT_Double) | (1 << JVM_CONSTANT_Long);
  1606     verify_cp_type(index, cp, types, CHECK_VERIFY(this));
  1608   if (tag.is_string() && cp->is_pseudo_string_at(index)) {
  1609     current_frame->push_stack(
  1610       VerificationType::reference_type(
  1611         vmSymbols::java_lang_Object()), CHECK_VERIFY(this));
  1612   } else if (tag.is_string() || tag.is_unresolved_string()) {
  1613     current_frame->push_stack(
  1614       VerificationType::reference_type(
  1615         vmSymbols::java_lang_String()), CHECK_VERIFY(this));
  1616   } else if (tag.is_klass() || tag.is_unresolved_klass()) {
  1617     current_frame->push_stack(
  1618       VerificationType::reference_type(
  1619         vmSymbols::java_lang_Class()), CHECK_VERIFY(this));
  1620   } else if (tag.is_int()) {
  1621     current_frame->push_stack(
  1622       VerificationType::integer_type(), CHECK_VERIFY(this));
  1623   } else if (tag.is_float()) {
  1624     current_frame->push_stack(
  1625       VerificationType::float_type(), CHECK_VERIFY(this));
  1626   } else if (tag.is_double()) {
  1627     current_frame->push_stack_2(
  1628       VerificationType::double_type(),
  1629       VerificationType::double2_type(), CHECK_VERIFY(this));
  1630   } else if (tag.is_long()) {
  1631     current_frame->push_stack_2(
  1632       VerificationType::long_type(),
  1633       VerificationType::long2_type(), CHECK_VERIFY(this));
  1634   } else {
  1635     verify_error(bci, "Invalid index in ldc");
  1636     return;
  1640 void ClassVerifier::verify_switch(
  1641     RawBytecodeStream* bcs, u4 code_length, char* code_data,
  1642     StackMapFrame* current_frame, StackMapTable* stackmap_table, TRAPS) {
  1643   int bci = bcs->bci();
  1644   address bcp = bcs->bcp();
  1645   address aligned_bcp = (address) round_to((intptr_t)(bcp + 1), jintSize);
  1647   // 4639449 & 4647081: padding bytes must be 0
  1648   u2 padding_offset = 1;
  1649   while ((bcp + padding_offset) < aligned_bcp) {
  1650     if(*(bcp + padding_offset) != 0) {
  1651       verify_error(bci, "Nonzero padding byte in lookswitch or tableswitch");
  1652       return;
  1654     padding_offset++;
  1656   int default_offset = (int) Bytes::get_Java_u4(aligned_bcp);
  1657   int keys, delta;
  1658   current_frame->pop_stack(
  1659     VerificationType::integer_type(), CHECK_VERIFY(this));
  1660   if (bcs->code() == Bytecodes::_tableswitch) {
  1661     jint low = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize);
  1662     jint high = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize);
  1663     if (low > high) {
  1664       verify_error(bci,
  1665         "low must be less than or equal to high in tableswitch");
  1666       return;
  1668     keys = high - low + 1;
  1669     if (keys < 0) {
  1670       verify_error(bci, "too many keys in tableswitch");
  1671       return;
  1673     delta = 1;
  1674   } else {
  1675     keys = (int)Bytes::get_Java_u4(aligned_bcp + jintSize);
  1676     if (keys < 0) {
  1677       verify_error(bci, "number of keys in lookupswitch less than 0");
  1678       return;
  1680     delta = 2;
  1681     // Make sure that the lookupswitch items are sorted
  1682     for (int i = 0; i < (keys - 1); i++) {
  1683       jint this_key = Bytes::get_Java_u4(aligned_bcp + (2+2*i)*jintSize);
  1684       jint next_key = Bytes::get_Java_u4(aligned_bcp + (2+2*i+2)*jintSize);
  1685       if (this_key >= next_key) {
  1686         verify_error(bci, "Bad lookupswitch instruction");
  1687         return;
  1691   int target = bci + default_offset;
  1692   stackmap_table->check_jump_target(current_frame, target, CHECK_VERIFY(this));
  1693   for (int i = 0; i < keys; i++) {
  1694     target = bci + (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize);
  1695     stackmap_table->check_jump_target(
  1696       current_frame, target, CHECK_VERIFY(this));
  1700 bool ClassVerifier::name_in_supers(
  1701     symbolOop ref_name, instanceKlassHandle current) {
  1702   klassOop super = current->super();
  1703   while (super != NULL) {
  1704     if (super->klass_part()->name() == ref_name) {
  1705       return true;
  1707     super = super->klass_part()->super();
  1709   return false;
  1712 void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
  1713                                               StackMapFrame* current_frame,
  1714                                               constantPoolHandle cp,
  1715                                               TRAPS) {
  1716   u2 index = bcs->get_index_big();
  1717   verify_cp_type(index, cp, 1 << JVM_CONSTANT_Fieldref, CHECK_VERIFY(this));
  1719   // Get field name and signature
  1720   symbolHandle field_name = symbolHandle(THREAD, cp->name_ref_at(index));
  1721   symbolHandle field_sig = symbolHandle(THREAD, cp->signature_ref_at(index));
  1723   if (!SignatureVerifier::is_valid_type_signature(field_sig)) {
  1724     class_format_error(
  1725       "Invalid signature for field in class %s referenced "
  1726       "from constant pool index %d", _klass->external_name(), index);
  1727     return;
  1730   // Get referenced class type
  1731   VerificationType ref_class_type = cp_ref_index_to_type(
  1732     index, cp, CHECK_VERIFY(this));
  1733   if (!ref_class_type.is_object()) {
  1734     verify_error(
  1735       "Expecting reference to class in class %s at constant pool index %d",
  1736       _klass->external_name(), index);
  1737     return;
  1739   VerificationType target_class_type = ref_class_type;
  1741   assert(sizeof(VerificationType) == sizeof(uintptr_t),
  1742         "buffer type must match VerificationType size");
  1743   uintptr_t field_type_buffer[2];
  1744   VerificationType* field_type = (VerificationType*)field_type_buffer;
  1745   // If we make a VerificationType[2] array directly, the compiler calls
  1746   // to the c-runtime library to do the allocation instead of just
  1747   // stack allocating it.  Plus it would run constructors.  This shows up
  1748   // in performance profiles.
  1750   SignatureStream sig_stream(field_sig, false);
  1751   VerificationType stack_object_type;
  1752   int n = change_sig_to_verificationType(
  1753     &sig_stream, field_type, CHECK_VERIFY(this));
  1754   u2 bci = bcs->bci();
  1755   bool is_assignable;
  1756   switch (bcs->code()) {
  1757     case Bytecodes::_getstatic: {
  1758       for (int i = 0; i < n; i++) {
  1759         current_frame->push_stack(field_type[i], CHECK_VERIFY(this));
  1761       break;
  1763     case Bytecodes::_putstatic: {
  1764       for (int i = n - 1; i >= 0; i--) {
  1765         current_frame->pop_stack(field_type[i], CHECK_VERIFY(this));
  1767       break;
  1769     case Bytecodes::_getfield: {
  1770       stack_object_type = current_frame->pop_stack(
  1771         target_class_type, CHECK_VERIFY(this));
  1772       for (int i = 0; i < n; i++) {
  1773         current_frame->push_stack(field_type[i], CHECK_VERIFY(this));
  1775       goto check_protected;
  1777     case Bytecodes::_putfield: {
  1778       for (int i = n - 1; i >= 0; i--) {
  1779         current_frame->pop_stack(field_type[i], CHECK_VERIFY(this));
  1781       stack_object_type = current_frame->pop_stack(CHECK_VERIFY(this));
  1783       // The JVMS 2nd edition allows field initialization before the superclass
  1784       // initializer, if the field is defined within the current class.
  1785       fieldDescriptor fd;
  1786       if (stack_object_type == VerificationType::uninitialized_this_type() &&
  1787           target_class_type.equals(current_type()) &&
  1788           _klass->find_local_field(field_name(), field_sig(), &fd)) {
  1789         stack_object_type = current_type();
  1791       is_assignable = target_class_type.is_assignable_from(
  1792         stack_object_type, current_class(), CHECK_VERIFY(this));
  1793       if (!is_assignable) {
  1794         verify_error(bci, "Bad type on operand stack in putfield");
  1795         return;
  1798     check_protected: {
  1799       if (_this_type == stack_object_type)
  1800         break; // stack_object_type must be assignable to _current_class_type
  1801       symbolHandle ref_class_name = symbolHandle(THREAD,
  1802         cp->klass_name_at(cp->klass_ref_index_at(index)));
  1803       if (!name_in_supers(ref_class_name(), current_class()))
  1804         // stack_object_type must be assignable to _current_class_type since:
  1805         // 1. stack_object_type must be assignable to ref_class.
  1806         // 2. ref_class must be _current_class or a subclass of it. It can't
  1807         //    be a superclass of it. See revised JVMS 5.4.4.
  1808         break;
  1810       klassOop ref_class_oop = load_class(ref_class_name, CHECK);
  1811       if (is_protected_access(current_class(), ref_class_oop, field_name(),
  1812                               field_sig(), false)) {
  1813         // It's protected access, check if stack object is assignable to
  1814         // current class.
  1815         is_assignable = current_type().is_assignable_from(
  1816           stack_object_type, current_class(), CHECK_VERIFY(this));
  1817         if (!is_assignable) {
  1818           verify_error(bci, "Bad access to protected data in getfield");
  1819           return;
  1822       break;
  1824     default: ShouldNotReachHere();
  1828 void ClassVerifier::verify_invoke_init(
  1829     RawBytecodeStream* bcs, VerificationType ref_class_type,
  1830     StackMapFrame* current_frame, u4 code_length, bool *this_uninit,
  1831     constantPoolHandle cp, TRAPS) {
  1832   u2 bci = bcs->bci();
  1833   VerificationType type = current_frame->pop_stack(
  1834     VerificationType::reference_check(), CHECK_VERIFY(this));
  1835   if (type == VerificationType::uninitialized_this_type()) {
  1836     // The method must be an <init> method of either this class, or one of its
  1837     // superclasses
  1838     klassOop oop = current_class()();
  1839     Klass* klass = oop->klass_part();
  1840     while (klass != NULL && ref_class_type.name() != klass->name()) {
  1841       klass = klass->super()->klass_part();
  1843     if (klass == NULL) {
  1844       verify_error(bci, "Bad <init> method call");
  1845       return;
  1847     current_frame->initialize_object(type, current_type());
  1848     *this_uninit = true;
  1849   } else if (type.is_uninitialized()) {
  1850     u2 new_offset = type.bci();
  1851     address new_bcp = bcs->bcp() - bci + new_offset;
  1852     if (new_offset > (code_length - 3) || (*new_bcp) != Bytecodes::_new) {
  1853       verify_error(new_offset, "Expecting new instruction");
  1854       return;
  1856     u2 new_class_index = Bytes::get_Java_u2(new_bcp + 1);
  1857     verify_cp_class_type(new_class_index, cp, CHECK_VERIFY(this));
  1859     // The method must be an <init> method of the indicated class
  1860     VerificationType new_class_type = cp_index_to_type(
  1861       new_class_index, cp, CHECK_VERIFY(this));
  1862     if (!new_class_type.equals(ref_class_type)) {
  1863       verify_error(bci, "Call to wrong <init> method");
  1864       return;
  1866     // According to the VM spec, if the referent class is a superclass of the
  1867     // current class, and is in a different runtime package, and the method is
  1868     // protected, then the objectref must be the current class or a subclass
  1869     // of the current class.
  1870     VerificationType objectref_type = new_class_type;
  1871     if (name_in_supers(ref_class_type.name(), current_class())) {
  1872       klassOop ref_klass = load_class(
  1873         ref_class_type.name(), CHECK_VERIFY(this));
  1874       methodOop m = instanceKlass::cast(ref_klass)->uncached_lookup_method(
  1875         vmSymbols::object_initializer_name(),
  1876         cp->signature_ref_at(bcs->get_index_big()));
  1877       instanceKlassHandle mh(THREAD, m->method_holder());
  1878       if (m->is_protected() && !mh->is_same_class_package(_klass())) {
  1879         bool assignable = current_type().is_assignable_from(
  1880           objectref_type, current_class(), CHECK_VERIFY(this));
  1881         if (!assignable) {
  1882           verify_error(bci, "Bad access to protected <init> method");
  1883           return;
  1887     current_frame->initialize_object(type, new_class_type);
  1888   } else {
  1889     verify_error(bci, "Bad operand type when invoking <init>");
  1890     return;
  1894 void ClassVerifier::verify_invoke_instructions(
  1895     RawBytecodeStream* bcs, u4 code_length, StackMapFrame* current_frame,
  1896     bool *this_uninit, VerificationType return_type,
  1897     constantPoolHandle cp, TRAPS) {
  1898   // Make sure the constant pool item is the right type
  1899   u2 index = bcs->get_index_big();
  1900   Bytecodes::Code opcode = bcs->code();
  1901   unsigned int types = (opcode == Bytecodes::_invokeinterface
  1902                                 ? 1 << JVM_CONSTANT_InterfaceMethodref
  1903                       : opcode == Bytecodes::_invokedynamic
  1904                                 ? 1 << JVM_CONSTANT_NameAndType
  1905                                 : 1 << JVM_CONSTANT_Methodref);
  1906   verify_cp_type(index, cp, types, CHECK_VERIFY(this));
  1908   // Get method name and signature
  1909   symbolHandle method_name(THREAD, cp->name_ref_at(index));
  1910   symbolHandle method_sig(THREAD, cp->signature_ref_at(index));
  1912   if (!SignatureVerifier::is_valid_method_signature(method_sig)) {
  1913     class_format_error(
  1914       "Invalid method signature in class %s referenced "
  1915       "from constant pool index %d", _klass->external_name(), index);
  1916     return;
  1919   // Get referenced class type
  1920   VerificationType ref_class_type;
  1921   if (opcode == Bytecodes::_invokedynamic) {
  1922     if (!EnableInvokeDynamic) {
  1923       class_format_error(
  1924         "invokedynamic instructions not enabled on this JVM",
  1925         _klass->external_name());
  1926       return;
  1928   } else {
  1929     ref_class_type = cp_ref_index_to_type(index, cp, CHECK_VERIFY(this));
  1932   // For a small signature length, we just allocate 128 bytes instead
  1933   // of parsing the signature once to find its size.
  1934   // -3 is for '(', ')' and return descriptor; multiply by 2 is for
  1935   // longs/doubles to be consertive.
  1936   assert(sizeof(VerificationType) == sizeof(uintptr_t),
  1937         "buffer type must match VerificationType size");
  1938   uintptr_t on_stack_sig_types_buffer[128];
  1939   // If we make a VerificationType[128] array directly, the compiler calls
  1940   // to the c-runtime library to do the allocation instead of just
  1941   // stack allocating it.  Plus it would run constructors.  This shows up
  1942   // in performance profiles.
  1944   VerificationType* sig_types;
  1945   int size = (method_sig->utf8_length() - 3) * 2;
  1946   if (size > 128) {
  1947     // Long and double occupies two slots here.
  1948     ArgumentSizeComputer size_it(method_sig);
  1949     size = size_it.size();
  1950     sig_types = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, VerificationType, size);
  1951   } else{
  1952     sig_types = (VerificationType*)on_stack_sig_types_buffer;
  1954   SignatureStream sig_stream(method_sig);
  1955   int sig_i = 0;
  1956   while (!sig_stream.at_return_type()) {
  1957     sig_i += change_sig_to_verificationType(
  1958       &sig_stream, &sig_types[sig_i], CHECK_VERIFY(this));
  1959     sig_stream.next();
  1961   int nargs = sig_i;
  1963 #ifdef ASSERT
  1965     ArgumentSizeComputer size_it(method_sig);
  1966     assert(nargs == size_it.size(), "Argument sizes do not match");
  1967     assert(nargs <= (method_sig->utf8_length() - 3) * 2, "estimate of max size isn't conservative enough");
  1969 #endif
  1971   // Check instruction operands
  1972   u2 bci = bcs->bci();
  1973   if (opcode == Bytecodes::_invokeinterface) {
  1974     address bcp = bcs->bcp();
  1975     // 4905268: count operand in invokeinterface should be nargs+1, not nargs.
  1976     // JSR202 spec: The count operand of an invokeinterface instruction is valid if it is
  1977     // the difference between the size of the operand stack before and after the instruction
  1978     // executes.
  1979     if (*(bcp+3) != (nargs+1)) {
  1980       verify_error(bci, "Inconsistent args count operand in invokeinterface");
  1981       return;
  1983     if (*(bcp+4) != 0) {
  1984       verify_error(bci, "Fourth operand byte of invokeinterface must be zero");
  1985       return;
  1989   if (opcode == Bytecodes::_invokedynamic) {
  1990     address bcp = bcs->bcp();
  1991     if (*(bcp+3) != 0 || *(bcp+4) != 0) {
  1992       verify_error(bci, "Third and fourth operand bytes of invokedynamic must be zero");
  1993       return;
  1997   if (method_name->byte_at(0) == '<') {
  1998     // Make sure <init> can only be invoked by invokespecial
  1999     if (opcode != Bytecodes::_invokespecial ||
  2000         method_name() != vmSymbols::object_initializer_name()) {
  2001       verify_error(bci, "Illegal call to internal method");
  2002       return;
  2004   } else if (opcode == Bytecodes::_invokespecial
  2005              && !ref_class_type.equals(current_type())
  2006              && !ref_class_type.equals(VerificationType::reference_type(
  2007                   current_class()->super()->klass_part()->name()))) {
  2008     bool subtype = ref_class_type.is_assignable_from(
  2009       current_type(), current_class(), CHECK_VERIFY(this));
  2010     if (!subtype) {
  2011       verify_error(bci, "Bad invokespecial instruction: "
  2012           "current class isn't assignable to reference class.");
  2013        return;
  2016   // Match method descriptor with operand stack
  2017   for (int i = nargs - 1; i >= 0; i--) {  // Run backwards
  2018     current_frame->pop_stack(sig_types[i], CHECK_VERIFY(this));
  2020   // Check objectref on operand stack
  2021   if (opcode != Bytecodes::_invokestatic &&
  2022       opcode != Bytecodes::_invokedynamic) {
  2023     if (method_name() == vmSymbols::object_initializer_name()) {  // <init> method
  2024       verify_invoke_init(bcs, ref_class_type, current_frame,
  2025         code_length, this_uninit, cp, CHECK_VERIFY(this));
  2026     } else {   // other methods
  2027       // Ensures that target class is assignable to method class.
  2028       if (opcode == Bytecodes::_invokespecial) {
  2029         current_frame->pop_stack(current_type(), CHECK_VERIFY(this));
  2030       } else if (opcode == Bytecodes::_invokevirtual) {
  2031         VerificationType stack_object_type =
  2032           current_frame->pop_stack(ref_class_type, CHECK_VERIFY(this));
  2033         if (current_type() != stack_object_type) {
  2034           assert(cp->cache() == NULL, "not rewritten yet");
  2035           symbolHandle ref_class_name = symbolHandle(THREAD,
  2036             cp->klass_name_at(cp->klass_ref_index_at(index)));
  2037           // See the comments in verify_field_instructions() for
  2038           // the rationale behind this.
  2039           if (name_in_supers(ref_class_name(), current_class())) {
  2040             klassOop ref_class = load_class(ref_class_name, CHECK);
  2041             if (is_protected_access(
  2042                   _klass, ref_class, method_name(), method_sig(), true)) {
  2043               // It's protected access, check if stack object is
  2044               // assignable to current class.
  2045               bool is_assignable = current_type().is_assignable_from(
  2046                 stack_object_type, current_class(), CHECK_VERIFY(this));
  2047               if (!is_assignable) {
  2048                 if (ref_class_type.name() == vmSymbols::java_lang_Object()
  2049                     && stack_object_type.is_array()
  2050                     && method_name() == vmSymbols::clone_name()) {
  2051                   // Special case: arrays pretend to implement public Object
  2052                   // clone().
  2053                 } else {
  2054                   verify_error(bci,
  2055                     "Bad access to protected data in invokevirtual");
  2056                   return;
  2062       } else {
  2063         assert(opcode == Bytecodes::_invokeinterface, "Unexpected opcode encountered");
  2064         current_frame->pop_stack(ref_class_type, CHECK_VERIFY(this));
  2068   // Push the result type.
  2069   if (sig_stream.type() != T_VOID) {
  2070     if (method_name() == vmSymbols::object_initializer_name()) {
  2071       // <init> method must have a void return type
  2072       verify_error(bci, "Return type must be void in <init> method");
  2073       return;
  2075     VerificationType return_type[2];
  2076     int n = change_sig_to_verificationType(
  2077       &sig_stream, return_type, CHECK_VERIFY(this));
  2078     for (int i = 0; i < n; i++) {
  2079       current_frame->push_stack(return_type[i], CHECK_VERIFY(this)); // push types backwards
  2084 VerificationType ClassVerifier::get_newarray_type(
  2085     u2 index, u2 bci, TRAPS) {
  2086   const char* from_bt[] = {
  2087     NULL, NULL, NULL, NULL, "[Z", "[C", "[F", "[D", "[B", "[S", "[I", "[J",
  2088   };
  2089   if (index < T_BOOLEAN || index > T_LONG) {
  2090     verify_error(bci, "Illegal newarray instruction");
  2091     return VerificationType::bogus_type();
  2094   // from_bt[index] contains the array signature which has a length of 2
  2095   symbolHandle sig = oopFactory::new_symbol_handle(
  2096     from_bt[index], 2, CHECK_(VerificationType::bogus_type()));
  2097   return VerificationType::reference_type(sig);
  2100 void ClassVerifier::verify_anewarray(
  2101     u2 index, constantPoolHandle cp, StackMapFrame* current_frame, TRAPS) {
  2102   verify_cp_class_type(index, cp, CHECK_VERIFY(this));
  2103   current_frame->pop_stack(
  2104     VerificationType::integer_type(), CHECK_VERIFY(this));
  2106   VerificationType component_type =
  2107     cp_index_to_type(index, cp, CHECK_VERIFY(this));
  2108   ResourceMark rm(THREAD);
  2109   int length;
  2110   char* arr_sig_str;
  2111   if (component_type.is_array()) {     // it's an array
  2112     const char* component_name = component_type.name()->as_utf8();
  2113     // add one dimension to component
  2114     length = (int)strlen(component_name) + 1;
  2115     arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length);
  2116     arr_sig_str[0] = '[';
  2117     strncpy(&arr_sig_str[1], component_name, length - 1);
  2118   } else {         // it's an object or interface
  2119     const char* component_name = component_type.name()->as_utf8();
  2120     // add one dimension to component with 'L' prepended and ';' postpended.
  2121     length = (int)strlen(component_name) + 3;
  2122     arr_sig_str = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, length);
  2123     arr_sig_str[0] = '[';
  2124     arr_sig_str[1] = 'L';
  2125     strncpy(&arr_sig_str[2], component_name, length - 2);
  2126     arr_sig_str[length - 1] = ';';
  2128   symbolHandle arr_sig = oopFactory::new_symbol_handle(
  2129     arr_sig_str, length, CHECK_VERIFY(this));
  2130   VerificationType new_array_type = VerificationType::reference_type(arr_sig);
  2131   current_frame->push_stack(new_array_type, CHECK_VERIFY(this));
  2134 void ClassVerifier::verify_iload(u2 index, StackMapFrame* current_frame, TRAPS) {
  2135   current_frame->get_local(
  2136     index, VerificationType::integer_type(), CHECK_VERIFY(this));
  2137   current_frame->push_stack(
  2138     VerificationType::integer_type(), CHECK_VERIFY(this));
  2141 void ClassVerifier::verify_lload(u2 index, StackMapFrame* current_frame, TRAPS) {
  2142   current_frame->get_local_2(
  2143     index, VerificationType::long_type(),
  2144     VerificationType::long2_type(), CHECK_VERIFY(this));
  2145   current_frame->push_stack_2(
  2146     VerificationType::long_type(),
  2147     VerificationType::long2_type(), CHECK_VERIFY(this));
  2150 void ClassVerifier::verify_fload(u2 index, StackMapFrame* current_frame, TRAPS) {
  2151   current_frame->get_local(
  2152     index, VerificationType::float_type(), CHECK_VERIFY(this));
  2153   current_frame->push_stack(
  2154     VerificationType::float_type(), CHECK_VERIFY(this));
  2157 void ClassVerifier::verify_dload(u2 index, StackMapFrame* current_frame, TRAPS) {
  2158   current_frame->get_local_2(
  2159     index, VerificationType::double_type(),
  2160     VerificationType::double2_type(), CHECK_VERIFY(this));
  2161   current_frame->push_stack_2(
  2162     VerificationType::double_type(),
  2163     VerificationType::double2_type(), CHECK_VERIFY(this));
  2166 void ClassVerifier::verify_aload(u2 index, StackMapFrame* current_frame, TRAPS) {
  2167   VerificationType type = current_frame->get_local(
  2168     index, VerificationType::reference_check(), CHECK_VERIFY(this));
  2169   current_frame->push_stack(type, CHECK_VERIFY(this));
  2172 void ClassVerifier::verify_istore(u2 index, StackMapFrame* current_frame, TRAPS) {
  2173   current_frame->pop_stack(
  2174     VerificationType::integer_type(), CHECK_VERIFY(this));
  2175   current_frame->set_local(
  2176     index, VerificationType::integer_type(), CHECK_VERIFY(this));
  2179 void ClassVerifier::verify_lstore(u2 index, StackMapFrame* current_frame, TRAPS) {
  2180   current_frame->pop_stack_2(
  2181     VerificationType::long2_type(),
  2182     VerificationType::long_type(), CHECK_VERIFY(this));
  2183   current_frame->set_local_2(
  2184     index, VerificationType::long_type(),
  2185     VerificationType::long2_type(), CHECK_VERIFY(this));
  2188 void ClassVerifier::verify_fstore(u2 index, StackMapFrame* current_frame, TRAPS) {
  2189   current_frame->pop_stack(VerificationType::float_type(), CHECK_VERIFY(this));
  2190   current_frame->set_local(
  2191     index, VerificationType::float_type(), CHECK_VERIFY(this));
  2194 void ClassVerifier::verify_dstore(u2 index, StackMapFrame* current_frame, TRAPS) {
  2195   current_frame->pop_stack_2(
  2196     VerificationType::double2_type(),
  2197     VerificationType::double_type(), CHECK_VERIFY(this));
  2198   current_frame->set_local_2(
  2199     index, VerificationType::double_type(),
  2200     VerificationType::double2_type(), CHECK_VERIFY(this));
  2203 void ClassVerifier::verify_astore(u2 index, StackMapFrame* current_frame, TRAPS) {
  2204   VerificationType type = current_frame->pop_stack(
  2205     VerificationType::reference_check(), CHECK_VERIFY(this));
  2206   current_frame->set_local(index, type, CHECK_VERIFY(this));
  2209 void ClassVerifier::verify_iinc(u2 index, StackMapFrame* current_frame, TRAPS) {
  2210   VerificationType type = current_frame->get_local(
  2211     index, VerificationType::integer_type(), CHECK_VERIFY(this));
  2212   current_frame->set_local(index, type, CHECK_VERIFY(this));
  2215 void ClassVerifier::verify_return_value(
  2216     VerificationType return_type, VerificationType type, u2 bci, TRAPS) {
  2217   if (return_type == VerificationType::bogus_type()) {
  2218     verify_error(bci, "Method expects a return value");
  2219     return;
  2221   bool match = return_type.is_assignable_from(type, _klass, CHECK_VERIFY(this));
  2222   if (!match) {
  2223     verify_error(bci, "Bad return type");
  2224     return;

mercurial