< prev index next >

src/hotspot/share/oops/cpCache.cpp

Print this page




 245       set_f1(method());
 246       byte_no = 1;
 247       break;
 248     default:
 249       ShouldNotReachHere();
 250       break;
 251   }
 252 
 253   // Note:  byte_no also appears in TemplateTable::resolve.
 254   if (byte_no == 1) {
 255     assert(invoke_code != Bytecodes::_invokevirtual &&
 256            invoke_code != Bytecodes::_invokeinterface, "");
 257     bool do_resolve = true;
 258     // Don't mark invokespecial to method as resolved if sender is an interface.  The receiver
 259     // has to be checked that it is a subclass of the current class every time this bytecode
 260     // is executed.
 261     if (invoke_code == Bytecodes::_invokespecial && sender_is_interface &&
 262         method->name() != vmSymbols::object_initializer_name()) {
 263       do_resolve = false;
 264     }






 265     // Don't mark invokestatic to method as resolved if the holder class has not yet completed
 266     // initialization. An invokestatic must only proceed if the class is initialized, but if
 267     // we resolve it before then that class initialization check is skipped. However if the call
 268     // is from the same class we can resolve as we must be executing with <clinit> on our call stack.
 269     if (invoke_code == Bytecodes::_invokestatic) {
 270       if (!method->method_holder()->is_initialized() &&
 271           method->method_holder() != pool_holder) {
 272         do_resolve = false;

 273       } else {
 274         assert(method->method_holder()->is_initialized() ||
 275                method->method_holder()->is_reentrant_initialization(Thread::current()),
 276                "invalid class initialization state for invoke_static");
 277       }
 278     }
 279     if (do_resolve) {
 280       set_bytecode_1(invoke_code);
 281     }
 282   } else if (byte_no == 2)  {
 283     if (change_to_virtual) {
 284       assert(invoke_code == Bytecodes::_invokeinterface, "");
 285       // NOTE: THIS IS A HACK - BE VERY CAREFUL!!!
 286       //
 287       // Workaround for the case where we encounter an invokeinterface, but we
 288       // should really have an _invokevirtual since the resolved method is a
 289       // virtual method in java.lang.Object. This is a corner case in the spec
 290       // but is presumably legal. javac does not generate this code.
 291       //
 292       // We do not set bytecode_1() to _invokeinterface, because that is the




 245       set_f1(method());
 246       byte_no = 1;
 247       break;
 248     default:
 249       ShouldNotReachHere();
 250       break;
 251   }
 252 
 253   // Note:  byte_no also appears in TemplateTable::resolve.
 254   if (byte_no == 1) {
 255     assert(invoke_code != Bytecodes::_invokevirtual &&
 256            invoke_code != Bytecodes::_invokeinterface, "");
 257     bool do_resolve = true;
 258     // Don't mark invokespecial to method as resolved if sender is an interface.  The receiver
 259     // has to be checked that it is a subclass of the current class every time this bytecode
 260     // is executed.
 261     if (invoke_code == Bytecodes::_invokespecial && sender_is_interface &&
 262         method->name() != vmSymbols::object_initializer_name()) {
 263       do_resolve = false;
 264     }
 265     if (invoke_code == Bytecodes::_invokestatic) {
 266       if (method->needs_clinit_barrier()) {
 267         if (UseFastClassInitChecks) {
 268           // Template interpreter supports fast class initialization check for invokestatic which
 269           // doesn't require unresolved call site.
 270         } else {
 271           // Don't mark invokestatic to method as resolved if the holder class has not yet completed
 272           // initialization. An invokestatic must only proceed if the class is initialized, but if
 273           // we resolve it before then that class initialization check is skipped.




 274           do_resolve = false;
 275         }
 276       } else {
 277         assert(method->method_holder()->is_initialized() ||
 278                method->method_holder()->is_reentrant_initialization(Thread::current()),
 279                "invalid class initialization state for invoke_static");
 280       }
 281     }
 282     if (do_resolve) {
 283       set_bytecode_1(invoke_code);
 284     }
 285   } else if (byte_no == 2)  {
 286     if (change_to_virtual) {
 287       assert(invoke_code == Bytecodes::_invokeinterface, "");
 288       // NOTE: THIS IS A HACK - BE VERY CAREFUL!!!
 289       //
 290       // Workaround for the case where we encounter an invokeinterface, but we
 291       // should really have an _invokevirtual since the resolved method is a
 292       // virtual method in java.lang.Object. This is a corner case in the spec
 293       // but is presumably legal. javac does not generate this code.
 294       //
 295       // We do not set bytecode_1() to _invokeinterface, because that is the


< prev index next >