author | dholmes |
Mon, 21 Mar 2011 22:16:19 -0400 | |
changeset 8735 | 9829dda3b405 |
parent 8076 | 96d498ec7ae1 |
child 8921 | 14bfe81f2a9d |
permissions | -rw-r--r-- |
1 | 1 |
/* |
7397 | 2 |
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 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 |
||
1 | 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 |
private: |
|
40 |
static volatile bool _initialized; |
|
41 |
static GrowableArray<ciObject*>* _shared_ci_objects; |
|
42 |
static ciSymbol* _shared_ci_symbols[]; |
|
43 |
static int _shared_ident_limit; |
|
44 |
||
45 |
Arena* _arena; |
|
46 |
GrowableArray<ciObject*>* _ci_objects; |
|
47 |
GrowableArray<ciMethod*>* _unloaded_methods; |
|
48 |
GrowableArray<ciKlass*>* _unloaded_klasses; |
|
5882 | 49 |
GrowableArray<ciInstance*>* _unloaded_instances; |
1 | 50 |
GrowableArray<ciReturnAddress*>* _return_addresses; |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
51 |
GrowableArray<ciSymbol*>* _symbols; // keep list of symbols created |
1 | 52 |
int _next_ident; |
53 |
||
54 |
public: |
|
55 |
struct NonPermObject : public ResourceObj { |
|
56 |
ciObject* _object; |
|
57 |
NonPermObject* _next; |
|
58 |
||
59 |
inline NonPermObject(NonPermObject* &bucket, oop key, ciObject* object); |
|
60 |
ciObject* object() { return _object; } |
|
61 |
NonPermObject* &next() { return _next; } |
|
62 |
}; |
|
63 |
private: |
|
64 |
enum { NON_PERM_BUCKETS = 61 }; |
|
65 |
NonPermObject* _non_perm_bucket[NON_PERM_BUCKETS]; |
|
66 |
int _non_perm_count; |
|
67 |
||
68 |
int find(oop key, GrowableArray<ciObject*>* objects); |
|
69 |
bool is_found_at(int index, oop key, GrowableArray<ciObject*>* objects); |
|
70 |
void insert(int index, ciObject* obj, GrowableArray<ciObject*>* objects); |
|
71 |
ciObject* create_new_object(oop o); |
|
72 |
static bool is_equal(NonPermObject* p, oop key) { |
|
73 |
return p->object()->get_oop() == key; |
|
74 |
} |
|
75 |
||
76 |
NonPermObject* &find_non_perm(oop key); |
|
77 |
void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj); |
|
78 |
||
79 |
void init_ident_of(ciObject* obj); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
80 |
void init_ident_of(ciSymbol* obj); |
1 | 81 |
|
82 |
Arena* arena() { return _arena; } |
|
83 |
||
84 |
void print_contents_impl(); |
|
85 |
||
5882 | 86 |
ciInstance* get_unloaded_instance(ciInstanceKlass* klass); |
87 |
||
1 | 88 |
public: |
89 |
static bool is_initialized() { return _initialized; } |
|
90 |
||
91 |
static void initialize(); |
|
92 |
void init_shared_objects(); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
93 |
void remove_symbols(); |
1 | 94 |
|
95 |
ciObjectFactory(Arena* arena, int expected_size); |
|
96 |
||
97 |
// Get the ciObject corresponding to some oop. |
|
98 |
ciObject* get(oop key); |
|
99 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
100 |
ciSymbol* get_symbol(Symbol* key); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
101 |
|
1 | 102 |
// Get the ciSymbol corresponding to one of the vmSymbols. |
103 |
static ciSymbol* vm_symbol_at(int index); |
|
104 |
||
105 |
// Get the ciMethod representing an unloaded/unfound method. |
|
106 |
ciMethod* get_unloaded_method(ciInstanceKlass* holder, |
|
107 |
ciSymbol* name, |
|
108 |
ciSymbol* signature); |
|
109 |
||
110 |
// Get a ciKlass representing an unloaded klass. |
|
111 |
ciKlass* get_unloaded_klass(ciKlass* accessing_klass, |
|
112 |
ciSymbol* name, |
|
113 |
bool create_if_not_found); |
|
114 |
||
5882 | 115 |
// Get a ciInstance representing an unresolved klass mirror. |
116 |
ciInstance* get_unloaded_klass_mirror(ciKlass* type); |
|
117 |
||
118 |
// Get a ciInstance representing an unresolved method handle constant. |
|
119 |
ciInstance* get_unloaded_method_handle_constant(ciKlass* holder, |
|
120 |
ciSymbol* name, |
|
121 |
ciSymbol* signature, |
|
122 |
int ref_kind); |
|
123 |
||
124 |
// Get a ciInstance representing an unresolved method type constant. |
|
125 |
ciInstance* get_unloaded_method_type_constant(ciSymbol* signature); |
|
126 |
||
1 | 127 |
|
128 |
// Get the ciMethodData representing the methodData for a method |
|
129 |
// with none. |
|
130 |
ciMethodData* get_empty_methodData(); |
|
131 |
||
132 |
ciReturnAddress* get_return_address(int bci); |
|
133 |
||
134 |
void print_contents(); |
|
135 |
void print(); |
|
136 |
}; |
|
7397 | 137 |
|
138 |
#endif // SHARE_VM_CI_CIOBJECTFACTORY_HPP |