< prev index next >

src/hotspot/share/oops/method.cpp

Print this page


 480 // safepoint as it is called with references live on the stack at
 481 // locations the GC is unaware of.
 482 ValueKlass* Method::returned_value_type(Thread* thread) const {
 483   assert(is_returning_vt(), "method return type should be value type");
 484   SignatureStream ss(signature());
 485   while (!ss.at_return_type()) {
 486     ss.next();
 487   }
 488   Handle class_loader(thread, method_holder()->class_loader());
 489   Handle protection_domain(thread, method_holder()->protection_domain());
 490   Klass* k = NULL;
 491   {
 492     NoSafepointVerifier nsv;
 493     k = ss.as_klass(class_loader, protection_domain, SignatureStream::ReturnNull, thread);
 494   }
 495   assert(k != NULL && !thread->has_pending_exception(), "can't resolve klass");
 496   return ValueKlass::cast(k);
 497 }
 498 #endif
 499 














































 500 bool Method::is_empty_method() const {
 501   return  code_size() == 1
 502       && *code_base() == Bytecodes::_return;
 503 }
 504 
 505 
 506 bool Method::is_vanilla_constructor() const {
 507   // Returns true if this method is a vanilla constructor, i.e. an "<init>" "()V" method
 508   // which only calls the superclass vanilla constructor and possibly does stores of
 509   // zero constants to local fields:
 510   //
 511   //   aload_0
 512   //   invokespecial
 513   //   indexbyte1
 514   //   indexbyte2
 515   //
 516   // followed by an (optional) sequence of:
 517   //
 518   //   aload_0
 519   //   aconst_null / iconst_0 / fconst_0 / dconst_0




 480 // safepoint as it is called with references live on the stack at
 481 // locations the GC is unaware of.
 482 ValueKlass* Method::returned_value_type(Thread* thread) const {
 483   assert(is_returning_vt(), "method return type should be value type");
 484   SignatureStream ss(signature());
 485   while (!ss.at_return_type()) {
 486     ss.next();
 487   }
 488   Handle class_loader(thread, method_holder()->class_loader());
 489   Handle protection_domain(thread, method_holder()->protection_domain());
 490   Klass* k = NULL;
 491   {
 492     NoSafepointVerifier nsv;
 493     k = ss.as_klass(class_loader, protection_domain, SignatureStream::ReturnNull, thread);
 494   }
 495   assert(k != NULL && !thread->has_pending_exception(), "can't resolve klass");
 496   return ValueKlass::cast(k);
 497 }
 498 #endif
 499 
 500 void Method::check_returning_vt(TRAPS) {
 501   ResourceMark rm(THREAD);
 502   SignatureStream ss(signature());
 503   while (!ss.at_return_type()) {
 504     ss.next();
 505   }
 506   assert(ss.is_object(), "should be called only if the return type is known to be an object");
 507 
 508   Handle class_loader(THREAD, method_holder()->class_loader());
 509   Handle protection_domain(THREAD, method_holder()->protection_domain());
 510   Symbol* return_class_name = ss.as_symbol(CHECK);
 511   Klass* k = SystemDictionary::find(return_class_name, class_loader, protection_domain, CHECK);
 512   assert(!THREAD->has_pending_exception(), "can't resolve klass");
 513 
 514   if (k != NULL) {
 515     if (k->is_value()) {
 516       set_known_returning_vt();
 517     } else {
 518       set_known_not_returning_vt();
 519     }
 520   } else {
 521     //   set_known_not_returning_vt(); // <<- enable this and RarelyUsedValueUser.doit() will crash.
 522     // We are still not sure if the return type is a VT. This could happen
 523     // when we call a method whose return type has not yet been resolved:
 524     //
 525     //   public /*non-VT-aware*/ class Foo {
 526     //      SomeType doit() { return null; }
 527     //      public static void main(String args[]) {doit(); doit(); doit(); }
 528     //   }
 529     //
 530     // Normally, if SomeType is a VT, it will be included in Foo's "ValueTypes"
 531     // attribute, which means SomeType is eagerly resolved when Foo
 532     // is loaded.
 533     //
 534     // However, we might have a Foo class that's not VT-aware, so it doesn't have
 535     // a "ValueTypes" attribute, which means SomeType may not be loaded
 536     // before Foo.doit() is called.
 537     //
 538     // Also, we cannot simply assume that SomeType is not a VT, because Foo may
 539     // be a hand-written class that elides the "ValueTypes" attribute on purpose.
 540     //
 541     // This means that in some rare cases we might call check_returning_vt()
 542     // repeatedly (3 times in the examples above).
 543   }
 544 }
 545 
 546 bool Method::is_empty_method() const {
 547   return  code_size() == 1
 548       && *code_base() == Bytecodes::_return;
 549 }
 550 
 551 
 552 bool Method::is_vanilla_constructor() const {
 553   // Returns true if this method is a vanilla constructor, i.e. an "<init>" "()V" method
 554   // which only calls the superclass vanilla constructor and possibly does stores of
 555   // zero constants to local fields:
 556   //
 557   //   aload_0
 558   //   invokespecial
 559   //   indexbyte1
 560   //   indexbyte2
 561   //
 562   // followed by an (optional) sequence of:
 563   //
 564   //   aload_0
 565   //   aconst_null / iconst_0 / fconst_0 / dconst_0


< prev index next >