annotate src/share/vm/ci/ciObjectFactory.hpp @ 3602:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 5eb9169b1a14
children bd7a7ce2e264
rev   line source
duke@0 1 /*
coleenp@3602 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
trims@1472 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 * or visit www.oracle.com if you need additional information or have any
trims@1472 21 * questions.
duke@0 22 *
duke@0 23 */
duke@0 24
stefank@1879 25 #ifndef SHARE_VM_CI_CIOBJECTFACTORY_HPP
stefank@1879 26 #define SHARE_VM_CI_CIOBJECTFACTORY_HPP
stefank@1879 27
stefank@1879 28 #include "ci/ciClassList.hpp"
stefank@1879 29 #include "ci/ciObject.hpp"
stefank@1879 30 #include "utilities/growableArray.hpp"
stefank@1879 31
duke@0 32 // ciObjectFactory
duke@0 33 //
duke@0 34 // This class handles requests for the creation of new instances
duke@0 35 // of ciObject and its subclasses. It contains a caching mechanism
duke@0 36 // which ensures that for each oop, at most one ciObject is created.
duke@0 37 // This invariant allows efficient implementation of ciObject.
duke@0 38 class ciObjectFactory : public ResourceObj {
never@2703 39 friend class VMStructs;
never@2703 40 friend class ciEnv;
never@2703 41
duke@0 42 private:
duke@0 43 static volatile bool _initialized;
coleenp@3602 44 static GrowableArray<ciMetadata*>* _shared_ci_metadata;
duke@0 45 static ciSymbol* _shared_ci_symbols[];
duke@0 46 static int _shared_ident_limit;
duke@0 47
duke@0 48 Arena* _arena;
coleenp@3602 49 GrowableArray<ciMetadata*>* _ci_metadata;
duke@0 50 GrowableArray<ciMethod*>* _unloaded_methods;
duke@0 51 GrowableArray<ciKlass*>* _unloaded_klasses;
jrose@1522 52 GrowableArray<ciInstance*>* _unloaded_instances;
duke@0 53 GrowableArray<ciReturnAddress*>* _return_addresses;
coleenp@2062 54 GrowableArray<ciSymbol*>* _symbols; // keep list of symbols created
duke@0 55 int _next_ident;
duke@0 56
duke@0 57 public:
duke@0 58 struct NonPermObject : public ResourceObj {
duke@0 59 ciObject* _object;
duke@0 60 NonPermObject* _next;
duke@0 61
duke@0 62 inline NonPermObject(NonPermObject* &bucket, oop key, ciObject* object);
duke@0 63 ciObject* object() { return _object; }
duke@0 64 NonPermObject* &next() { return _next; }
duke@0 65 };
duke@0 66 private:
duke@0 67 enum { NON_PERM_BUCKETS = 61 };
duke@0 68 NonPermObject* _non_perm_bucket[NON_PERM_BUCKETS];
duke@0 69 int _non_perm_count;
duke@0 70
coleenp@3602 71 int find(Metadata* key, GrowableArray<ciMetadata*>* objects);
coleenp@3602 72 bool is_found_at(int index, Metadata* key, GrowableArray<ciMetadata*>* objects);
coleenp@3602 73 void insert(int index, ciMetadata* obj, GrowableArray<ciMetadata*>* objects);
coleenp@3602 74
duke@0 75 ciObject* create_new_object(oop o);
coleenp@3602 76 ciMetadata* create_new_object(Metadata* o);
coleenp@3602 77
duke@0 78 static bool is_equal(NonPermObject* p, oop key) {
duke@0 79 return p->object()->get_oop() == key;
duke@0 80 }
duke@0 81
duke@0 82 NonPermObject* &find_non_perm(oop key);
duke@0 83 void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj);
duke@0 84
coleenp@3602 85 void init_ident_of(ciBaseObject* obj);
duke@0 86
duke@0 87 Arena* arena() { return _arena; }
duke@0 88
duke@0 89 void print_contents_impl();
duke@0 90
jrose@1522 91 ciInstance* get_unloaded_instance(ciInstanceKlass* klass);
jrose@1522 92
duke@0 93 public:
duke@0 94 static bool is_initialized() { return _initialized; }
duke@0 95
duke@0 96 static void initialize();
duke@0 97 void init_shared_objects();
coleenp@2062 98 void remove_symbols();
duke@0 99
duke@0 100 ciObjectFactory(Arena* arena, int expected_size);
duke@0 101
duke@0 102 // Get the ciObject corresponding to some oop.
duke@0 103 ciObject* get(oop key);
coleenp@3602 104 ciMetadata* get_metadata(Metadata* key);
coleenp@2062 105 ciSymbol* get_symbol(Symbol* key);
coleenp@2062 106
duke@0 107 // Get the ciSymbol corresponding to one of the vmSymbols.
duke@0 108 static ciSymbol* vm_symbol_at(int index);
duke@0 109
duke@0 110 // Get the ciMethod representing an unloaded/unfound method.
duke@0 111 ciMethod* get_unloaded_method(ciInstanceKlass* holder,
duke@0 112 ciSymbol* name,
twisti@2762 113 ciSymbol* signature,
twisti@2762 114 ciInstanceKlass* accessor);
duke@0 115
duke@0 116 // Get a ciKlass representing an unloaded klass.
duke@0 117 ciKlass* get_unloaded_klass(ciKlass* accessing_klass,
duke@0 118 ciSymbol* name,
duke@0 119 bool create_if_not_found);
duke@0 120
jrose@1522 121 // Get a ciInstance representing an unresolved klass mirror.
jrose@1522 122 ciInstance* get_unloaded_klass_mirror(ciKlass* type);
jrose@1522 123
jrose@1522 124 // Get a ciInstance representing an unresolved method handle constant.
jrose@1522 125 ciInstance* get_unloaded_method_handle_constant(ciKlass* holder,
jrose@1522 126 ciSymbol* name,
jrose@1522 127 ciSymbol* signature,
jrose@1522 128 int ref_kind);
jrose@1522 129
jrose@1522 130 // Get a ciInstance representing an unresolved method type constant.
jrose@1522 131 ciInstance* get_unloaded_method_type_constant(ciSymbol* signature);
jrose@1522 132
duke@0 133
duke@0 134 // Get the ciMethodData representing the methodData for a method
duke@0 135 // with none.
duke@0 136 ciMethodData* get_empty_methodData();
duke@0 137
duke@0 138 ciReturnAddress* get_return_address(int bci);
duke@0 139
coleenp@3602 140 // RedefineClasses support
coleenp@3602 141 void metadata_do(void f(Metadata*));
coleenp@3602 142
duke@0 143 void print_contents();
duke@0 144 void print();
duke@0 145 };
stefank@1879 146
stefank@1879 147 #endif // SHARE_VM_CI_CIOBJECTFACTORY_HPP