src/share/vm/ci/ciObjectFactory.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/ci/ciObjectFactory.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,150 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_CI_CIOBJECTFACTORY_HPP
    1.29 +#define SHARE_VM_CI_CIOBJECTFACTORY_HPP
    1.30 +
    1.31 +#include "ci/ciClassList.hpp"
    1.32 +#include "ci/ciObject.hpp"
    1.33 +#include "utilities/growableArray.hpp"
    1.34 +
    1.35 +// ciObjectFactory
    1.36 +//
    1.37 +// This class handles requests for the creation of new instances
    1.38 +// of ciObject and its subclasses.  It contains a caching mechanism
    1.39 +// which ensures that for each oop, at most one ciObject is created.
    1.40 +// This invariant allows efficient implementation of ciObject.
    1.41 +class ciObjectFactory : public ResourceObj {
    1.42 +  friend class VMStructs;
    1.43 +  friend class ciEnv;
    1.44 +
    1.45 +private:
    1.46 +  static volatile bool _initialized;
    1.47 +  static GrowableArray<ciMetadata*>* _shared_ci_metadata;
    1.48 +  static ciSymbol*                 _shared_ci_symbols[];
    1.49 +  static int                       _shared_ident_limit;
    1.50 +
    1.51 +  Arena*                    _arena;
    1.52 +  GrowableArray<ciMetadata*>*        _ci_metadata;
    1.53 +  GrowableArray<ciMethod*>* _unloaded_methods;
    1.54 +  GrowableArray<ciKlass*>* _unloaded_klasses;
    1.55 +  GrowableArray<ciInstance*>* _unloaded_instances;
    1.56 +  GrowableArray<ciReturnAddress*>* _return_addresses;
    1.57 +  GrowableArray<ciSymbol*>* _symbols;  // keep list of symbols created
    1.58 +  int                       _next_ident;
    1.59 +
    1.60 +public:
    1.61 +  struct NonPermObject : public ResourceObj {
    1.62 +    ciObject*      _object;
    1.63 +    NonPermObject* _next;
    1.64 +
    1.65 +    inline NonPermObject(NonPermObject* &bucket, oop key, ciObject* object);
    1.66 +    ciObject*     object()  { return _object; }
    1.67 +    NonPermObject* &next()  { return _next; }
    1.68 +  };
    1.69 +private:
    1.70 +  enum { NON_PERM_BUCKETS = 61 };
    1.71 +  NonPermObject* _non_perm_bucket[NON_PERM_BUCKETS];
    1.72 +  int _non_perm_count;
    1.73 +
    1.74 +  int find(Metadata* key, GrowableArray<ciMetadata*>* objects);
    1.75 +  bool is_found_at(int index, Metadata* key, GrowableArray<ciMetadata*>* objects);
    1.76 +  void insert(int index, ciMetadata* obj, GrowableArray<ciMetadata*>* objects);
    1.77 +
    1.78 +  ciObject* create_new_object(oop o);
    1.79 +  ciMetadata* create_new_object(Metadata* o);
    1.80 +
    1.81 +  static bool is_equal(NonPermObject* p, oop key) {
    1.82 +    return p->object()->get_oop() == key;
    1.83 +  }
    1.84 +
    1.85 +  NonPermObject* &find_non_perm(oop key);
    1.86 +  void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj);
    1.87 +
    1.88 +  void init_ident_of(ciBaseObject* obj);
    1.89 +
    1.90 +  Arena* arena() { return _arena; }
    1.91 +
    1.92 +  void print_contents_impl();
    1.93 +
    1.94 +  ciInstance* get_unloaded_instance(ciInstanceKlass* klass);
    1.95 +
    1.96 +public:
    1.97 +  static bool is_initialized() { return _initialized; }
    1.98 +
    1.99 +  static void initialize();
   1.100 +  void init_shared_objects();
   1.101 +  void remove_symbols();
   1.102 +
   1.103 +  ciObjectFactory(Arena* arena, int expected_size);
   1.104 +
   1.105 +  // Get the ciObject corresponding to some oop.
   1.106 +  ciObject* get(oop key);
   1.107 +  ciMetadata* get_metadata(Metadata* key);
   1.108 +  ciSymbol* get_symbol(Symbol* key);
   1.109 +
   1.110 +  // Get the ciSymbol corresponding to one of the vmSymbols.
   1.111 +  static ciSymbol* vm_symbol_at(int index);
   1.112 +
   1.113 +  // Get the ciMethod representing an unloaded/unfound method.
   1.114 +  ciMethod* get_unloaded_method(ciInstanceKlass* holder,
   1.115 +                                ciSymbol*        name,
   1.116 +                                ciSymbol*        signature,
   1.117 +                                ciInstanceKlass* accessor);
   1.118 +
   1.119 +  // Get a ciKlass representing an unloaded klass.
   1.120 +  ciKlass* get_unloaded_klass(ciKlass* accessing_klass,
   1.121 +                              ciSymbol* name,
   1.122 +                              bool create_if_not_found);
   1.123 +
   1.124 +  // Get a ciInstance representing an unresolved klass mirror.
   1.125 +  ciInstance* get_unloaded_klass_mirror(ciKlass* type);
   1.126 +
   1.127 +  // Get a ciInstance representing an unresolved method handle constant.
   1.128 +  ciInstance* get_unloaded_method_handle_constant(ciKlass*  holder,
   1.129 +                                                  ciSymbol* name,
   1.130 +                                                  ciSymbol* signature,
   1.131 +                                                  int       ref_kind);
   1.132 +
   1.133 +  // Get a ciInstance representing an unresolved method type constant.
   1.134 +  ciInstance* get_unloaded_method_type_constant(ciSymbol* signature);
   1.135 +
   1.136 +
   1.137 +  ciInstance* get_unloaded_object_constant();
   1.138 +
   1.139 +  // Get the ciMethodData representing the methodData for a method
   1.140 +  // with none.
   1.141 +  ciMethodData* get_empty_methodData();
   1.142 +
   1.143 +  ciReturnAddress* get_return_address(int bci);
   1.144 +
   1.145 +  GrowableArray<ciMetadata*>* get_ci_metadata() const { return _ci_metadata; }
   1.146 +  // RedefineClasses support
   1.147 +  void metadata_do(void f(Metadata*));
   1.148 +
   1.149 +  void print_contents();
   1.150 +  void print();
   1.151 +};
   1.152 +
   1.153 +#endif // SHARE_VM_CI_CIOBJECTFACTORY_HPP

mercurial