hotspot/src/share/vm/ci/ciObjectFactory.cpp
changeset 25492 d27050bdfb04
parent 25491 70fb742e40aa
child 25946 1572c9f03fb9
equal deleted inserted replaced
25491:70fb742e40aa 25492:d27050bdfb04
    44 #include "gc_interface/collectedHeap.inline.hpp"
    44 #include "gc_interface/collectedHeap.inline.hpp"
    45 #include "memory/allocation.inline.hpp"
    45 #include "memory/allocation.inline.hpp"
    46 #include "oops/oop.inline.hpp"
    46 #include "oops/oop.inline.hpp"
    47 #include "oops/oop.inline2.hpp"
    47 #include "oops/oop.inline2.hpp"
    48 #include "runtime/fieldType.hpp"
    48 #include "runtime/fieldType.hpp"
       
    49 #if INCLUDE_ALL_GCS
       
    50 # include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
       
    51 #endif
    49 
    52 
    50 // ciObjectFactory
    53 // ciObjectFactory
    51 //
    54 //
    52 // This class handles requests for the creation of new instances
    55 // This class handles requests for the creation of new instances
    53 // of ciObject and its subclasses.  It contains a caching mechanism
    56 // of ciObject and its subclasses.  It contains a caching mechanism
   370   }
   373   }
   371 
   374 
   372   // The oop is of some type not supported by the compiler interface.
   375   // The oop is of some type not supported by the compiler interface.
   373   ShouldNotReachHere();
   376   ShouldNotReachHere();
   374   return NULL;
   377   return NULL;
       
   378 }
       
   379 
       
   380 // ------------------------------------------------------------------
       
   381 // ciObjectFactory::ensure_metadata_alive
       
   382 //
       
   383 // Ensure that the metadata wrapped by the ciMetadata is kept alive by GC.
       
   384 // This is primarily useful for metadata which is considered as weak roots
       
   385 // by the GC but need to be strong roots if reachable from a current compilation.
       
   386 //
       
   387 void ciObjectFactory::ensure_metadata_alive(ciMetadata* m) {
       
   388   ASSERT_IN_VM; // We're handling raw oops here.
       
   389 
       
   390 #if INCLUDE_ALL_GCS
       
   391   if (!UseG1GC) {
       
   392     return;
       
   393   }
       
   394   Klass* metadata_owner_klass;
       
   395   if (m->is_klass()) {
       
   396     metadata_owner_klass = m->as_klass()->get_Klass();
       
   397   } else if (m->is_method()) {
       
   398     metadata_owner_klass = m->as_method()->get_Method()->constants()->pool_holder();
       
   399   } else {
       
   400     fatal("Not implemented for other types of metadata");
       
   401   }
       
   402 
       
   403   oop metadata_holder = metadata_owner_klass->klass_holder();
       
   404   if (metadata_holder != NULL) {
       
   405     G1SATBCardTableModRefBS::enqueue(metadata_holder);
       
   406   }
       
   407 
       
   408 #endif
   375 }
   409 }
   376 
   410 
   377 //------------------------------------------------------------------
   411 //------------------------------------------------------------------
   378 // ciObjectFactory::get_unloaded_method
   412 // ciObjectFactory::get_unloaded_method
   379 //
   413 //