hotspot/src/share/vm/ci/ciObjectFactory.cpp
changeset 5882 6b2aecc4f7d8
parent 5547 f4b087cbb361
child 7397 5b173b4ca846
equal deleted inserted replaced
5708:e92b3d8118f1 5882:6b2aecc4f7d8
    68     _ci_objects->appendAll(_shared_ci_objects);
    68     _ci_objects->appendAll(_shared_ci_objects);
    69   }
    69   }
    70 
    70 
    71   _unloaded_methods = new (arena) GrowableArray<ciMethod*>(arena, 4, 0, NULL);
    71   _unloaded_methods = new (arena) GrowableArray<ciMethod*>(arena, 4, 0, NULL);
    72   _unloaded_klasses = new (arena) GrowableArray<ciKlass*>(arena, 8, 0, NULL);
    72   _unloaded_klasses = new (arena) GrowableArray<ciKlass*>(arena, 8, 0, NULL);
       
    73   _unloaded_instances = new (arena) GrowableArray<ciInstance*>(arena, 4, 0, NULL);
    73   _return_addresses =
    74   _return_addresses =
    74     new (arena) GrowableArray<ciReturnAddress*>(arena, 8, 0, NULL);
    75     new (arena) GrowableArray<ciReturnAddress*>(arena, 8, 0, NULL);
    75 }
    76 }
    76 
    77 
    77 // ------------------------------------------------------------------
    78 // ------------------------------------------------------------------
   441   _unloaded_klasses->append(new_klass);
   442   _unloaded_klasses->append(new_klass);
   442 
   443 
   443   return new_klass;
   444   return new_klass;
   444 }
   445 }
   445 
   446 
       
   447 
       
   448 //------------------------------------------------------------------
       
   449 // ciObjectFactory::get_unloaded_instance
       
   450 //
       
   451 // Get a ciInstance representing an as-yet undetermined instance of a given class.
       
   452 //
       
   453 ciInstance* ciObjectFactory::get_unloaded_instance(ciInstanceKlass* instance_klass) {
       
   454   for (int i=0; i<_unloaded_instances->length(); i++) {
       
   455     ciInstance* entry = _unloaded_instances->at(i);
       
   456     if (entry->klass()->equals(instance_klass)) {
       
   457       // We've found a match.
       
   458       return entry;
       
   459     }
       
   460   }
       
   461 
       
   462   // This is a new unloaded instance.  Create it and stick it in
       
   463   // the cache.
       
   464   ciInstance* new_instance = new (arena()) ciInstance(instance_klass);
       
   465 
       
   466   init_ident_of(new_instance);
       
   467   _unloaded_instances->append(new_instance);
       
   468 
       
   469   // make sure it looks the way we want:
       
   470   assert(!new_instance->is_loaded(), "");
       
   471   assert(new_instance->klass() == instance_klass, "");
       
   472 
       
   473   return new_instance;
       
   474 }
       
   475 
       
   476 
       
   477 //------------------------------------------------------------------
       
   478 // ciObjectFactory::get_unloaded_klass_mirror
       
   479 //
       
   480 // Get a ciInstance representing an unresolved klass mirror.
       
   481 //
       
   482 // Currently, this ignores the parameters and returns a unique unloaded instance.
       
   483 ciInstance* ciObjectFactory::get_unloaded_klass_mirror(ciKlass*  type) {
       
   484   assert(ciEnv::_Class_klass != NULL, "");
       
   485   return get_unloaded_instance(ciEnv::_Class_klass->as_instance_klass());
       
   486 }
       
   487 
       
   488 //------------------------------------------------------------------
       
   489 // ciObjectFactory::get_unloaded_method_handle_constant
       
   490 //
       
   491 // Get a ciInstance representing an unresolved method handle constant.
       
   492 //
       
   493 // Currently, this ignores the parameters and returns a unique unloaded instance.
       
   494 ciInstance* ciObjectFactory::get_unloaded_method_handle_constant(ciKlass*  holder,
       
   495                                                                  ciSymbol* name,
       
   496                                                                  ciSymbol* signature,
       
   497                                                                  int       ref_kind) {
       
   498   if (ciEnv::_MethodHandle_klass == NULL)  return NULL;
       
   499   return get_unloaded_instance(ciEnv::_MethodHandle_klass->as_instance_klass());
       
   500 }
       
   501 
       
   502 //------------------------------------------------------------------
       
   503 // ciObjectFactory::get_unloaded_method_type_constant
       
   504 //
       
   505 // Get a ciInstance representing an unresolved method type constant.
       
   506 //
       
   507 // Currently, this ignores the parameters and returns a unique unloaded instance.
       
   508 ciInstance* ciObjectFactory::get_unloaded_method_type_constant(ciSymbol* signature) {
       
   509   if (ciEnv::_MethodType_klass == NULL)  return NULL;
       
   510   return get_unloaded_instance(ciEnv::_MethodType_klass->as_instance_klass());
       
   511 }
       
   512 
       
   513 
       
   514 
   446 //------------------------------------------------------------------
   515 //------------------------------------------------------------------
   447 // ciObjectFactory::get_empty_methodData
   516 // ciObjectFactory::get_empty_methodData
   448 //
   517 //
   449 // Get the ciMethodData representing the methodData for a method with
   518 // Get the ciMethodData representing the methodData for a method with
   450 // none.
   519 // none.
   635 // ------------------------------------------------------------------
   704 // ------------------------------------------------------------------
   636 // ciObjectFactory::print
   705 // ciObjectFactory::print
   637 //
   706 //
   638 // Print debugging information about the object factory
   707 // Print debugging information about the object factory
   639 void ciObjectFactory::print() {
   708 void ciObjectFactory::print() {
   640   tty->print("<ciObjectFactory oops=%d unloaded_methods=%d unloaded_klasses=%d>",
   709   tty->print("<ciObjectFactory oops=%d unloaded_methods=%d unloaded_instances=%d unloaded_klasses=%d>",
   641              _ci_objects->length(), _unloaded_methods->length(),
   710              _ci_objects->length(), _unloaded_methods->length(),
       
   711              _unloaded_instances->length(),
   642              _unloaded_klasses->length());
   712              _unloaded_klasses->length());
   643 }
   713 }