< prev index next >

src/hotspot/share/oops/trainingData.hpp

Print this page

 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_OOPS_TRAININGDATA_HPP
 26 #define SHARE_OOPS_TRAININGDATA_HPP
 27 
 28 #include "cds/cdsConfig.hpp"
 29 #include "classfile/classLoaderData.hpp"
 30 #include "classfile/compactHashtable.hpp"
 31 #include "compiler/compiler_globals.hpp"
 32 #include "compiler/compilerDefinitions.hpp"
 33 #include "memory/allocation.hpp"
 34 #include "memory/metaspaceClosure.hpp"
 35 #include "oops/instanceKlass.hpp"
 36 #include "oops/method.hpp"
 37 #include "oops/objArrayKlass.hpp"
 38 #include "runtime/handles.hpp"
 39 #include "runtime/mutexLocker.hpp"

 40 #include "utilities/resizableHashTable.hpp"
 41 
 42 class ciEnv;
 43 class ciBaseObject;
 44 class CompileTask;
 45 class CompileTrainingData;
 46 class KlassTrainingData;
 47 class MethodTrainingData;
 48 
 49 // Base class for all the training data varieties
 50 class TrainingData : public Metadata {
 51   friend KlassTrainingData;
 52   friend MethodTrainingData;
 53   friend CompileTrainingData;
 54 public:
 55   // Key is used to insert any TrainingData (TD) object into a hash tables. The key is currently a
 56   // pointer to a metaspace object the TD is associated with. For example,
 57   // for KlassTrainingData it's an InstanceKlass, for MethodTrainingData it's a Method.
 58   // The utility of the these hash tables is to be able to find a TD object for a given metaspace
 59   // metaspace object.

306     if (have_data()) {
307       archived_training_data_dictionary()->iterate(fn);
308     }
309     if (need_data()) {
310       training_data_set()->iterate(fn);
311     }
312   }
313 
314   virtual MethodTrainingData*   as_MethodTrainingData()  const { return nullptr; }
315   virtual KlassTrainingData*    as_KlassTrainingData()   const { return nullptr; }
316   virtual CompileTrainingData*  as_CompileTrainingData() const { return nullptr; }
317   bool is_MethodTrainingData()  const { return as_MethodTrainingData()  != nullptr; }
318   bool is_KlassTrainingData()   const { return as_KlassTrainingData()   != nullptr; }
319   bool is_CompileTrainingData() const { return as_CompileTrainingData() != nullptr; }
320 
321   virtual void prepare(Visitor& visitor) = 0;
322   virtual void cleanup(Visitor& visitor) = 0;
323 
324   static void initialize() NOT_CDS_RETURN;
325 
326   static void verify();
327 
328   // Widget for recording dependencies, as an N-to-M graph relation,
329   // possibly cyclic.
330   template<typename E>
331   class DepList : public StackObj {
332     GrowableArrayCHeap<E, mtCompiler>* _deps_dyn;
333     Array<E>*                          _deps;
334   public:
335     DepList() {
336       _deps_dyn = nullptr;
337       _deps = nullptr;
338     }
339 
340     int length() const {
341       return (_deps_dyn != nullptr ? _deps_dyn->length()
342               : _deps   != nullptr ? _deps->length()
343               : 0);
344     }
345     E* adr_at(int i) const {
346       return (_deps_dyn != nullptr ? _deps_dyn->adr_at(i)

732   bool _was_toplevel;
733   // metadata snapshots of final state:
734   MethodCounters* _final_counters;
735   MethodData*     _final_profile;
736 
737   MethodTrainingData();
738   MethodTrainingData(Method* method, KlassTrainingData* ktd) : TrainingData(method) {
739     _klass = ktd;
740     _holder = method;
741     for (int i = 0; i < CompLevel_count - 1; i++) {
742       _last_toplevel_compiles[i] = nullptr;
743     }
744     _highest_top_level = CompLevel_none;
745     _level_mask = 0;
746     _was_toplevel = false;
747   }
748 
749   static int level_mask(int level) {
750     return ((level & 0xF) != level ? 0 : 1 << level);
751   }





752 
753  public:
754   KlassTrainingData* klass()  const { return _klass; }
755   bool has_holder()           const { return _holder != nullptr; }
756   Method* holder()            const { return _holder; }
757   bool only_inlined()         const { return !_was_toplevel; }
758   bool saw_level(CompLevel l) const { return (_level_mask & level_mask(l)) != 0; }

759   int highest_top_level()     const { return _highest_top_level; }
760   MethodData* final_profile() const { return _final_profile; }
761 
762   Symbol* name() const {
763     precond(has_holder());
764     return holder()->name();
765   }
766   Symbol* signature() const {
767     precond(has_holder());
768     return holder()->signature();
769   }
770 
771   CompileTrainingData* last_toplevel_compile(int level) const {
772     if (level > CompLevel_none) {
773       return _last_toplevel_compiles[level - 1];
774     }
775     return nullptr;
776   }
777 
778   void notice_compilation(int level, bool inlined = false) {

 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_OOPS_TRAININGDATA_HPP
 26 #define SHARE_OOPS_TRAININGDATA_HPP
 27 
 28 #include "cds/cdsConfig.hpp"
 29 #include "classfile/classLoaderData.hpp"
 30 #include "classfile/compactHashtable.hpp"
 31 #include "compiler/compiler_globals.hpp"
 32 #include "compiler/compilerDefinitions.hpp"
 33 #include "memory/allocation.hpp"
 34 #include "memory/metaspaceClosure.hpp"
 35 #include "oops/instanceKlass.hpp"
 36 #include "oops/method.hpp"
 37 #include "oops/objArrayKlass.hpp"
 38 #include "runtime/handles.hpp"
 39 #include "runtime/mutexLocker.hpp"
 40 #include "utilities/count_leading_zeros.hpp"
 41 #include "utilities/resizableHashTable.hpp"
 42 
 43 class ciEnv;
 44 class ciBaseObject;
 45 class CompileTask;
 46 class CompileTrainingData;
 47 class KlassTrainingData;
 48 class MethodTrainingData;
 49 
 50 // Base class for all the training data varieties
 51 class TrainingData : public Metadata {
 52   friend KlassTrainingData;
 53   friend MethodTrainingData;
 54   friend CompileTrainingData;
 55 public:
 56   // Key is used to insert any TrainingData (TD) object into a hash tables. The key is currently a
 57   // pointer to a metaspace object the TD is associated with. For example,
 58   // for KlassTrainingData it's an InstanceKlass, for MethodTrainingData it's a Method.
 59   // The utility of the these hash tables is to be able to find a TD object for a given metaspace
 60   // metaspace object.

307     if (have_data()) {
308       archived_training_data_dictionary()->iterate(fn);
309     }
310     if (need_data()) {
311       training_data_set()->iterate(fn);
312     }
313   }
314 
315   virtual MethodTrainingData*   as_MethodTrainingData()  const { return nullptr; }
316   virtual KlassTrainingData*    as_KlassTrainingData()   const { return nullptr; }
317   virtual CompileTrainingData*  as_CompileTrainingData() const { return nullptr; }
318   bool is_MethodTrainingData()  const { return as_MethodTrainingData()  != nullptr; }
319   bool is_KlassTrainingData()   const { return as_KlassTrainingData()   != nullptr; }
320   bool is_CompileTrainingData() const { return as_CompileTrainingData() != nullptr; }
321 
322   virtual void prepare(Visitor& visitor) = 0;
323   virtual void cleanup(Visitor& visitor) = 0;
324 
325   static void initialize() NOT_CDS_RETURN;
326 
327   static void verify() NOT_CDS_RETURN;
328 
329   // Widget for recording dependencies, as an N-to-M graph relation,
330   // possibly cyclic.
331   template<typename E>
332   class DepList : public StackObj {
333     GrowableArrayCHeap<E, mtCompiler>* _deps_dyn;
334     Array<E>*                          _deps;
335   public:
336     DepList() {
337       _deps_dyn = nullptr;
338       _deps = nullptr;
339     }
340 
341     int length() const {
342       return (_deps_dyn != nullptr ? _deps_dyn->length()
343               : _deps   != nullptr ? _deps->length()
344               : 0);
345     }
346     E* adr_at(int i) const {
347       return (_deps_dyn != nullptr ? _deps_dyn->adr_at(i)

733   bool _was_toplevel;
734   // metadata snapshots of final state:
735   MethodCounters* _final_counters;
736   MethodData*     _final_profile;
737 
738   MethodTrainingData();
739   MethodTrainingData(Method* method, KlassTrainingData* ktd) : TrainingData(method) {
740     _klass = ktd;
741     _holder = method;
742     for (int i = 0; i < CompLevel_count - 1; i++) {
743       _last_toplevel_compiles[i] = nullptr;
744     }
745     _highest_top_level = CompLevel_none;
746     _level_mask = 0;
747     _was_toplevel = false;
748   }
749 
750   static int level_mask(int level) {
751     return ((level & 0xF) != level ? 0 : 1 << level);
752   }
753   static CompLevel highest_level(int mask) {
754     if (mask == 0)  return (CompLevel) 0;
755     int diff = (count_leading_zeros(level_mask(0)) - count_leading_zeros(mask));
756     return (CompLevel) diff;
757   }
758 
759  public:
760   KlassTrainingData* klass()  const { return _klass; }
761   bool has_holder()           const { return _holder != nullptr; }
762   Method* holder()            const { return _holder; }
763   bool only_inlined()         const { return !_was_toplevel; }
764   bool saw_level(CompLevel l) const { return (_level_mask & level_mask(l)) != 0; }
765   int highest_level()         const { return highest_level(_level_mask); }
766   int highest_top_level()     const { return _highest_top_level; }
767   MethodData* final_profile() const { return _final_profile; }
768 
769   Symbol* name() const {
770     precond(has_holder());
771     return holder()->name();
772   }
773   Symbol* signature() const {
774     precond(has_holder());
775     return holder()->signature();
776   }
777 
778   CompileTrainingData* last_toplevel_compile(int level) const {
779     if (level > CompLevel_none) {
780       return _last_toplevel_compiles[level - 1];
781     }
782     return nullptr;
783   }
784 
785   void notice_compilation(int level, bool inlined = false) {
< prev index next >