< prev index next >

src/share/vm/ci/ciObjectFactory.cpp

Print this page




  31 #include "ci/ciMethodData.hpp"
  32 #include "ci/ciMethodHandle.hpp"
  33 #include "ci/ciMethodType.hpp"
  34 #include "ci/ciNullObject.hpp"
  35 #include "ci/ciObjArray.hpp"
  36 #include "ci/ciObjArrayKlass.hpp"
  37 #include "ci/ciObject.hpp"
  38 #include "ci/ciObjectFactory.hpp"
  39 #include "ci/ciSymbol.hpp"
  40 #include "ci/ciTypeArray.hpp"
  41 #include "ci/ciTypeArrayKlass.hpp"
  42 #include "ci/ciUtilities.hpp"
  43 #include "classfile/javaClasses.inline.hpp"
  44 #include "classfile/systemDictionary.hpp"
  45 #include "gc/shared/collectedHeap.inline.hpp"
  46 #include "memory/allocation.inline.hpp"
  47 #include "oops/oop.inline.hpp"
  48 #include "runtime/fieldType.hpp"
  49 #include "utilities/macros.hpp"
  50 #if INCLUDE_ALL_GCS
  51 # include "gc/g1/g1SATBCardTableModRefBS.hpp"
  52 #endif
  53 
  54 // ciObjectFactory
  55 //
  56 // This class handles requests for the creation of new instances
  57 // of ciObject and its subclasses.  It contains a caching mechanism
  58 // which ensures that for each oop, at most one ciObject is created.
  59 // This invariant allows more efficient implementation of ciObject.
  60 //
  61 // Implementation note: the oop->ciObject mapping is represented as
  62 // a table stored in an array.  Even though objects are moved
  63 // by the garbage collector, the compactor preserves their relative
  64 // order; address comparison of oops (in perm space) is safe so long
  65 // as we prohibit GC during our comparisons.  We currently use binary
  66 // search to find the oop in the table, and inserting a new oop
  67 // into the table may be costly.  If this cost ends up being
  68 // problematic the underlying data structure can be switched to some
  69 // sort of balanced binary tree.
  70 
  71 GrowableArray<ciMetadata*>* ciObjectFactory::_shared_ci_metadata = NULL;


 411 //
 412 void ciObjectFactory::ensure_metadata_alive(ciMetadata* m) {
 413   ASSERT_IN_VM; // We're handling raw oops here.
 414 
 415 #if INCLUDE_ALL_GCS
 416   if (!UseG1GC) {
 417     return;
 418   }
 419   Klass* metadata_owner_klass;
 420   if (m->is_klass()) {
 421     metadata_owner_klass = m->as_klass()->get_Klass();
 422   } else if (m->is_method()) {
 423     metadata_owner_klass = m->as_method()->get_Method()->constants()->pool_holder();
 424   } else {
 425     fatal("Not implemented for other types of metadata");
 426     return;
 427   }
 428 
 429   oop metadata_holder = metadata_owner_klass->klass_holder();
 430   if (metadata_holder != NULL) {
 431     G1SATBCardTableModRefBS::enqueue(metadata_holder);
 432   }
 433 
 434 #endif
 435 }
 436 
 437 //------------------------------------------------------------------
 438 // ciObjectFactory::get_unloaded_method
 439 //
 440 // Get the ciMethod representing an unloaded/unfound method.
 441 //
 442 // Implementation note: unloaded methods are currently stored in
 443 // an unordered array, requiring a linear-time lookup for each
 444 // unloaded method.  This may need to change.
 445 ciMethod* ciObjectFactory::get_unloaded_method(ciInstanceKlass* holder,
 446                                                ciSymbol*        name,
 447                                                ciSymbol*        signature,
 448                                                ciInstanceKlass* accessor) {
 449   ciSignature* that = NULL;
 450   for (int i = 0; i < _unloaded_methods->length(); i++) {
 451     ciMethod* entry = _unloaded_methods->at(i);




  31 #include "ci/ciMethodData.hpp"
  32 #include "ci/ciMethodHandle.hpp"
  33 #include "ci/ciMethodType.hpp"
  34 #include "ci/ciNullObject.hpp"
  35 #include "ci/ciObjArray.hpp"
  36 #include "ci/ciObjArrayKlass.hpp"
  37 #include "ci/ciObject.hpp"
  38 #include "ci/ciObjectFactory.hpp"
  39 #include "ci/ciSymbol.hpp"
  40 #include "ci/ciTypeArray.hpp"
  41 #include "ci/ciTypeArrayKlass.hpp"
  42 #include "ci/ciUtilities.hpp"
  43 #include "classfile/javaClasses.inline.hpp"
  44 #include "classfile/systemDictionary.hpp"
  45 #include "gc/shared/collectedHeap.inline.hpp"
  46 #include "memory/allocation.inline.hpp"
  47 #include "oops/oop.inline.hpp"
  48 #include "runtime/fieldType.hpp"
  49 #include "utilities/macros.hpp"
  50 #if INCLUDE_ALL_GCS
  51 # include "gc/shared/satbMarkQueue.hpp"
  52 #endif
  53 
  54 // ciObjectFactory
  55 //
  56 // This class handles requests for the creation of new instances
  57 // of ciObject and its subclasses.  It contains a caching mechanism
  58 // which ensures that for each oop, at most one ciObject is created.
  59 // This invariant allows more efficient implementation of ciObject.
  60 //
  61 // Implementation note: the oop->ciObject mapping is represented as
  62 // a table stored in an array.  Even though objects are moved
  63 // by the garbage collector, the compactor preserves their relative
  64 // order; address comparison of oops (in perm space) is safe so long
  65 // as we prohibit GC during our comparisons.  We currently use binary
  66 // search to find the oop in the table, and inserting a new oop
  67 // into the table may be costly.  If this cost ends up being
  68 // problematic the underlying data structure can be switched to some
  69 // sort of balanced binary tree.
  70 
  71 GrowableArray<ciMetadata*>* ciObjectFactory::_shared_ci_metadata = NULL;


 411 //
 412 void ciObjectFactory::ensure_metadata_alive(ciMetadata* m) {
 413   ASSERT_IN_VM; // We're handling raw oops here.
 414 
 415 #if INCLUDE_ALL_GCS
 416   if (!UseG1GC) {
 417     return;
 418   }
 419   Klass* metadata_owner_klass;
 420   if (m->is_klass()) {
 421     metadata_owner_klass = m->as_klass()->get_Klass();
 422   } else if (m->is_method()) {
 423     metadata_owner_klass = m->as_method()->get_Method()->constants()->pool_holder();
 424   } else {
 425     fatal("Not implemented for other types of metadata");
 426     return;
 427   }
 428 
 429   oop metadata_holder = metadata_owner_klass->klass_holder();
 430   if (metadata_holder != NULL) {
 431     SATBMarkQueue::enqueue(metadata_holder);
 432   }
 433 
 434 #endif
 435 }
 436 
 437 //------------------------------------------------------------------
 438 // ciObjectFactory::get_unloaded_method
 439 //
 440 // Get the ciMethod representing an unloaded/unfound method.
 441 //
 442 // Implementation note: unloaded methods are currently stored in
 443 // an unordered array, requiring a linear-time lookup for each
 444 // unloaded method.  This may need to change.
 445 ciMethod* ciObjectFactory::get_unloaded_method(ciInstanceKlass* holder,
 446                                                ciSymbol*        name,
 447                                                ciSymbol*        signature,
 448                                                ciInstanceKlass* accessor) {
 449   ciSignature* that = NULL;
 450   for (int i = 0; i < _unloaded_methods->length(); i++) {
 451     ciMethod* entry = _unloaded_methods->at(i);


< prev index next >