< prev index next >

src/share/vm/ci/ciObjectFactory.hpp

Print this page




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  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 #ifndef SHARE_VM_CI_CIOBJECTFACTORY_HPP
  26 #define SHARE_VM_CI_CIOBJECTFACTORY_HPP
  27 
  28 #include "ci/ciClassList.hpp"
  29 #include "ci/ciObject.hpp"

  30 #include "utilities/growableArray.hpp"
  31 
  32 // ciObjectFactory
  33 //
  34 // This class handles requests for the creation of new instances
  35 // of ciObject and its subclasses.  It contains a caching mechanism
  36 // which ensures that for each oop, at most one ciObject is created.
  37 // This invariant allows efficient implementation of ciObject.
  38 class ciObjectFactory : public ResourceObj {
  39   friend class VMStructs;
  40   friend class ciEnv;
  41 
  42 private:
  43   static volatile bool _initialized;
  44   static GrowableArray<ciMetadata*>* _shared_ci_metadata;
  45   static ciSymbol*                 _shared_ci_symbols[];
  46   static int                       _shared_ident_limit;
  47 
  48   Arena*                    _arena;
  49   GrowableArray<ciMetadata*>*        _ci_metadata;


  61 
  62     inline NonPermObject(NonPermObject* &bucket, oop key, ciObject* object);
  63     ciObject*     object()  { return _object; }
  64     NonPermObject* &next()  { return _next; }
  65   };
  66 private:
  67   enum { NON_PERM_BUCKETS = 61 };
  68   NonPermObject* _non_perm_bucket[NON_PERM_BUCKETS];
  69   int _non_perm_count;
  70 
  71   int find(Metadata* key, GrowableArray<ciMetadata*>* objects);
  72   bool is_found_at(int index, Metadata* key, GrowableArray<ciMetadata*>* objects);
  73   void insert(int index, ciMetadata* obj, GrowableArray<ciMetadata*>* objects);
  74 
  75   ciObject* create_new_object(oop o);
  76   ciMetadata* create_new_metadata(Metadata* o);
  77 
  78   void ensure_metadata_alive(ciMetadata* m);
  79 
  80   static bool is_equal(NonPermObject* p, oop key) {





  81     return p->object()->get_oop() == key;
  82   }
  83 
  84   NonPermObject* &find_non_perm(oop key);
  85   void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj);
  86 
  87   void init_ident_of(ciBaseObject* obj);
  88 
  89   Arena* arena() { return _arena; }
  90 
  91   void print_contents_impl();
  92 
  93   ciInstance* get_unloaded_instance(ciInstanceKlass* klass);
  94 
  95 public:
  96   static bool is_initialized() { return _initialized; }
  97 
  98   static void initialize();
  99   void init_shared_objects();
 100   void remove_symbols();




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  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 #ifndef SHARE_VM_CI_CIOBJECTFACTORY_HPP
  26 #define SHARE_VM_CI_CIOBJECTFACTORY_HPP
  27 
  28 #include "ci/ciClassList.hpp"
  29 #include "ci/ciObject.hpp"
  30 #include "gc/shared/barrierSet.hpp"
  31 #include "utilities/growableArray.hpp"
  32 
  33 // ciObjectFactory
  34 //
  35 // This class handles requests for the creation of new instances
  36 // of ciObject and its subclasses.  It contains a caching mechanism
  37 // which ensures that for each oop, at most one ciObject is created.
  38 // This invariant allows efficient implementation of ciObject.
  39 class ciObjectFactory : public ResourceObj {
  40   friend class VMStructs;
  41   friend class ciEnv;
  42 
  43 private:
  44   static volatile bool _initialized;
  45   static GrowableArray<ciMetadata*>* _shared_ci_metadata;
  46   static ciSymbol*                 _shared_ci_symbols[];
  47   static int                       _shared_ident_limit;
  48 
  49   Arena*                    _arena;
  50   GrowableArray<ciMetadata*>*        _ci_metadata;


  62 
  63     inline NonPermObject(NonPermObject* &bucket, oop key, ciObject* object);
  64     ciObject*     object()  { return _object; }
  65     NonPermObject* &next()  { return _next; }
  66   };
  67 private:
  68   enum { NON_PERM_BUCKETS = 61 };
  69   NonPermObject* _non_perm_bucket[NON_PERM_BUCKETS];
  70   int _non_perm_count;
  71 
  72   int find(Metadata* key, GrowableArray<ciMetadata*>* objects);
  73   bool is_found_at(int index, Metadata* key, GrowableArray<ciMetadata*>* objects);
  74   void insert(int index, ciMetadata* obj, GrowableArray<ciMetadata*>* objects);
  75 
  76   ciObject* create_new_object(oop o);
  77   ciMetadata* create_new_metadata(Metadata* o);
  78 
  79   void ensure_metadata_alive(ciMetadata* m);
  80 
  81   static bool is_equal(NonPermObject* p, oop key) {
  82     // Shenandoah: We already force-forwarded the key earlier.
  83     // The oop in the object should always point to to-space.
  84     assert(key == oopDesc::bs()->read_barrier(key), "should be forwarded");
  85     assert(p->object()->get_oop() == oopDesc::bs()->read_barrier(p->object()->get_oop()),
  86            "should be forwarded");
  87     return p->object()->get_oop() == key;
  88   }
  89 
  90   NonPermObject* &find_non_perm(oop key);
  91   void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj);
  92 
  93   void init_ident_of(ciBaseObject* obj);
  94 
  95   Arena* arena() { return _arena; }
  96 
  97   void print_contents_impl();
  98 
  99   ciInstance* get_unloaded_instance(ciInstanceKlass* klass);
 100 
 101 public:
 102   static bool is_initialized() { return _initialized; }
 103 
 104   static void initialize();
 105   void init_shared_objects();
 106   void remove_symbols();


< prev index next >