src/share/vm/ci/ciObjectFactory.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial