< prev index next >

src/hotspot/share/cds/aotArtifactFinder.cpp

Print this page

 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "cds/aotClassLinker.hpp"
 26 #include "cds/aotArtifactFinder.hpp"
 27 #include "cds/aotClassInitializer.hpp"
 28 #include "cds/aotReferenceObjSupport.hpp"
 29 #include "cds/dumpTimeClassInfo.inline.hpp"
 30 #include "cds/heapShared.hpp"
 31 #include "cds/lambdaProxyClassDictionary.hpp"
 32 #include "classfile/systemDictionaryShared.hpp"
 33 #include "logging/log.hpp"
 34 #include "memory/metaspaceClosure.hpp"
 35 #include "oops/instanceKlass.hpp"
 36 #include "oops/objArrayKlass.hpp"

 37 #include "utilities/resourceHash.hpp"
 38 
 39 // All the classes that should be included in the AOT cache (in at least the "allocated" state)
 40 static GrowableArrayCHeap<Klass*, mtClassShared>* _all_cached_classes = nullptr;
 41 
 42 // This is a stack that tracks all the AOT-inited classes that are waiting to be passed
 43 // to HeapShared::copy_and_rescan_aot_inited_mirror().
 44 static GrowableArrayCHeap<InstanceKlass*, mtClassShared>* _pending_aot_inited_classes = nullptr;
 45 
 46 static const int TABLE_SIZE = 15889; // prime number
 47 using ClassesTable = ResourceHashtable<Klass*, bool, TABLE_SIZE, AnyObj::C_HEAP, mtClassShared>;
 48 static ClassesTable* _seen_classes;       // all classes that have been seen by AOTArtifactFinder
 49 static ClassesTable* _aot_inited_classes; // all classes that need to be AOT-initialized.
 50 
 51 void AOTArtifactFinder::initialize() {
 52   _all_cached_classes = new GrowableArrayCHeap<Klass*, mtClassShared>();
 53   _pending_aot_inited_classes = new GrowableArrayCHeap<InstanceKlass*, mtClassShared>();
 54   _seen_classes = new (mtClass)ClassesTable();
 55   _aot_inited_classes = new (mtClass)ClassesTable();
 56 }

147       InstanceKlass* ik = _pending_aot_inited_classes->pop();
148       HeapShared::copy_and_rescan_aot_inited_mirror(ik);
149     }
150   }
151 #endif
152 
153   // Exclude all the (hidden) classes that have not been discovered by the code above.
154   SystemDictionaryShared::dumptime_table()->iterate_all_live_classes([&] (InstanceKlass* k, DumpTimeClassInfo& info) {
155     if (!info.is_excluded() && _seen_classes->get(k) == nullptr) {
156       info.set_excluded();
157       info.set_has_checked_exclusion();
158       if (log_is_enabled(Debug, cds)) {
159         ResourceMark rm;
160         log_debug(cds)("Skipping %s: %s class", k->name()->as_C_string(),
161                       k->is_hidden() ? "Unreferenced hidden" : "AOT tooling");
162       }
163     }
164   });
165 
166   end_scanning_for_oops();


167 }
168 
169 void AOTArtifactFinder::start_scanning_for_oops() {
170 #if INCLUDE_CDS_JAVA_HEAP
171   if (CDSConfig::is_dumping_heap()) {
172     HeapShared::start_scanning_for_oops();
173   }
174 #endif
175 }
176 
177 void AOTArtifactFinder::end_scanning_for_oops() {
178 #if INCLUDE_CDS_JAVA_HEAP
179   if (CDSConfig::is_dumping_heap()) {
180     HeapShared::end_scanning_for_oops();
181   }
182 #endif
183 }
184 
185 void AOTArtifactFinder::add_aot_inited_class(InstanceKlass* ik) {
186   if (CDSConfig::is_initing_classes_at_dump_time()) {

 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "cds/aotClassLinker.hpp"
 26 #include "cds/aotArtifactFinder.hpp"
 27 #include "cds/aotClassInitializer.hpp"
 28 #include "cds/aotReferenceObjSupport.hpp"
 29 #include "cds/dumpTimeClassInfo.inline.hpp"
 30 #include "cds/heapShared.hpp"
 31 #include "cds/lambdaProxyClassDictionary.hpp"
 32 #include "classfile/systemDictionaryShared.hpp"
 33 #include "logging/log.hpp"
 34 #include "memory/metaspaceClosure.hpp"
 35 #include "oops/instanceKlass.hpp"
 36 #include "oops/objArrayKlass.hpp"
 37 #include "oops/trainingData.hpp"
 38 #include "utilities/resourceHash.hpp"
 39 
 40 // All the classes that should be included in the AOT cache (in at least the "allocated" state)
 41 static GrowableArrayCHeap<Klass*, mtClassShared>* _all_cached_classes = nullptr;
 42 
 43 // This is a stack that tracks all the AOT-inited classes that are waiting to be passed
 44 // to HeapShared::copy_and_rescan_aot_inited_mirror().
 45 static GrowableArrayCHeap<InstanceKlass*, mtClassShared>* _pending_aot_inited_classes = nullptr;
 46 
 47 static const int TABLE_SIZE = 15889; // prime number
 48 using ClassesTable = ResourceHashtable<Klass*, bool, TABLE_SIZE, AnyObj::C_HEAP, mtClassShared>;
 49 static ClassesTable* _seen_classes;       // all classes that have been seen by AOTArtifactFinder
 50 static ClassesTable* _aot_inited_classes; // all classes that need to be AOT-initialized.
 51 
 52 void AOTArtifactFinder::initialize() {
 53   _all_cached_classes = new GrowableArrayCHeap<Klass*, mtClassShared>();
 54   _pending_aot_inited_classes = new GrowableArrayCHeap<InstanceKlass*, mtClassShared>();
 55   _seen_classes = new (mtClass)ClassesTable();
 56   _aot_inited_classes = new (mtClass)ClassesTable();
 57 }

148       InstanceKlass* ik = _pending_aot_inited_classes->pop();
149       HeapShared::copy_and_rescan_aot_inited_mirror(ik);
150     }
151   }
152 #endif
153 
154   // Exclude all the (hidden) classes that have not been discovered by the code above.
155   SystemDictionaryShared::dumptime_table()->iterate_all_live_classes([&] (InstanceKlass* k, DumpTimeClassInfo& info) {
156     if (!info.is_excluded() && _seen_classes->get(k) == nullptr) {
157       info.set_excluded();
158       info.set_has_checked_exclusion();
159       if (log_is_enabled(Debug, cds)) {
160         ResourceMark rm;
161         log_debug(cds)("Skipping %s: %s class", k->name()->as_C_string(),
162                       k->is_hidden() ? "Unreferenced hidden" : "AOT tooling");
163       }
164     }
165   });
166 
167   end_scanning_for_oops();
168 
169   TrainingData::cleanup_training_data();
170 }
171 
172 void AOTArtifactFinder::start_scanning_for_oops() {
173 #if INCLUDE_CDS_JAVA_HEAP
174   if (CDSConfig::is_dumping_heap()) {
175     HeapShared::start_scanning_for_oops();
176   }
177 #endif
178 }
179 
180 void AOTArtifactFinder::end_scanning_for_oops() {
181 #if INCLUDE_CDS_JAVA_HEAP
182   if (CDSConfig::is_dumping_heap()) {
183     HeapShared::end_scanning_for_oops();
184   }
185 #endif
186 }
187 
188 void AOTArtifactFinder::add_aot_inited_class(InstanceKlass* ik) {
189   if (CDSConfig::is_initing_classes_at_dump_time()) {
< prev index next >