Wed, 03 Jul 2019 20:42:37 +0800
Merge
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); |
vlivanov@7384 | 76 | ciMetadata* create_new_metadata(Metadata* o); |
mikael@6198 | 77 | |
stefank@6992 | 78 | void ensure_metadata_alive(ciMetadata* m); |
aoqi@0 | 79 | |
aoqi@0 | 80 | static bool is_equal(NonPermObject* p, oop key) { |
aoqi@0 | 81 | return p->object()->get_oop() == key; |
aoqi@0 | 82 | } |
aoqi@0 | 83 | |
aoqi@0 | 84 | NonPermObject* &find_non_perm(oop key); |
aoqi@0 | 85 | void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj); |
aoqi@0 | 86 | |
aoqi@0 | 87 | void init_ident_of(ciBaseObject* obj); |
aoqi@0 | 88 | |
aoqi@0 | 89 | Arena* arena() { return _arena; } |
aoqi@0 | 90 | |
aoqi@0 | 91 | void print_contents_impl(); |
aoqi@0 | 92 | |
aoqi@0 | 93 | ciInstance* get_unloaded_instance(ciInstanceKlass* klass); |
aoqi@0 | 94 | |
aoqi@0 | 95 | public: |
aoqi@0 | 96 | static bool is_initialized() { return _initialized; } |
aoqi@0 | 97 | |
aoqi@0 | 98 | static void initialize(); |
aoqi@0 | 99 | void init_shared_objects(); |
aoqi@0 | 100 | void remove_symbols(); |
aoqi@0 | 101 | |
aoqi@0 | 102 | ciObjectFactory(Arena* arena, int expected_size); |
aoqi@0 | 103 | |
aoqi@0 | 104 | // Get the ciObject corresponding to some oop. |
aoqi@0 | 105 | ciObject* get(oop key); |
aoqi@0 | 106 | ciMetadata* get_metadata(Metadata* key); |
aoqi@0 | 107 | ciSymbol* get_symbol(Symbol* key); |
aoqi@0 | 108 | |
aoqi@0 | 109 | // Get the ciSymbol corresponding to one of the vmSymbols. |
aoqi@0 | 110 | static ciSymbol* vm_symbol_at(int index); |
aoqi@0 | 111 | |
aoqi@0 | 112 | // Get the ciMethod representing an unloaded/unfound method. |
aoqi@0 | 113 | ciMethod* get_unloaded_method(ciInstanceKlass* holder, |
aoqi@0 | 114 | ciSymbol* name, |
aoqi@0 | 115 | ciSymbol* signature, |
aoqi@0 | 116 | ciInstanceKlass* accessor); |
aoqi@0 | 117 | |
aoqi@0 | 118 | // Get a ciKlass representing an unloaded klass. |
aoqi@0 | 119 | ciKlass* get_unloaded_klass(ciKlass* accessing_klass, |
aoqi@0 | 120 | ciSymbol* name, |
aoqi@0 | 121 | bool create_if_not_found); |
aoqi@0 | 122 | |
aoqi@0 | 123 | // Get a ciInstance representing an unresolved klass mirror. |
aoqi@0 | 124 | ciInstance* get_unloaded_klass_mirror(ciKlass* type); |
aoqi@0 | 125 | |
aoqi@0 | 126 | // Get a ciInstance representing an unresolved method handle constant. |
aoqi@0 | 127 | ciInstance* get_unloaded_method_handle_constant(ciKlass* holder, |
aoqi@0 | 128 | ciSymbol* name, |
aoqi@0 | 129 | ciSymbol* signature, |
aoqi@0 | 130 | int ref_kind); |
aoqi@0 | 131 | |
aoqi@0 | 132 | // Get a ciInstance representing an unresolved method type constant. |
aoqi@0 | 133 | ciInstance* get_unloaded_method_type_constant(ciSymbol* signature); |
aoqi@0 | 134 | |
aoqi@0 | 135 | |
aoqi@0 | 136 | ciInstance* get_unloaded_object_constant(); |
aoqi@0 | 137 | |
aoqi@0 | 138 | // Get the ciMethodData representing the methodData for a method |
aoqi@0 | 139 | // with none. |
aoqi@0 | 140 | ciMethodData* get_empty_methodData(); |
aoqi@0 | 141 | |
aoqi@0 | 142 | ciReturnAddress* get_return_address(int bci); |
aoqi@0 | 143 | |
aoqi@0 | 144 | GrowableArray<ciMetadata*>* get_ci_metadata() const { return _ci_metadata; } |
aoqi@0 | 145 | // RedefineClasses support |
aoqi@0 | 146 | void metadata_do(void f(Metadata*)); |
aoqi@0 | 147 | |
aoqi@0 | 148 | void print_contents(); |
aoqi@0 | 149 | void print(); |
aoqi@0 | 150 | }; |
aoqi@0 | 151 | |
aoqi@0 | 152 | #endif // SHARE_VM_CI_CIOBJECTFACTORY_HPP |