author | thartmann |
Tue, 12 Jul 2016 08:57:00 +0200 | |
changeset 40056 | 6bdd3da90181 |
parent 30764 | fec48bf5a827 |
child 46271 | 979ebd346ecf |
permissions | -rw-r--r-- |
1 | 1 |
/* |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
24424
diff
changeset
|
2 |
* Copyright (c) 1999, 2015, 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:
3908
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
3908
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:
3908
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "ci/ciObject.hpp" |
|
27 |
#include "ci/ciUtilities.hpp" |
|
30764 | 28 |
#include "gc/shared/collectedHeap.inline.hpp" |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
24424
diff
changeset
|
29 |
#include "oops/oop.inline.hpp" |
1 | 30 |
|
31 |
// ciObject |
|
32 |
// |
|
33 |
// This class represents an oop in the HotSpot virtual machine. |
|
34 |
// Its subclasses are structured in a hierarchy which mirrors |
|
35 |
// an aggregate of the VM's oop and klass hierarchies (see |
|
36 |
// oopHierarchy.hpp). Each instance of ciObject holds a handle |
|
37 |
// to a corresponding oop on the VM side and provides routines |
|
38 |
// for accessing the information in its oop. By using the ciObject |
|
39 |
// hierarchy for accessing oops in the VM, the compiler ensures |
|
40 |
// that it is safe with respect to garbage collection; that is, |
|
41 |
// GC and compilation can proceed independently without |
|
42 |
// interference. |
|
43 |
// |
|
44 |
// Within the VM, the oop and klass hierarchies are separate. |
|
45 |
// The compiler interface does not preserve this separation -- |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
46 |
// the distinction between `Klass*' and `Klass' are not |
1 | 47 |
// reflected in the interface and instead the Klass hierarchy |
48 |
// is directly modeled as the subclasses of ciKlass. |
|
49 |
||
50 |
// ------------------------------------------------------------------ |
|
51 |
// ciObject::ciObject |
|
52 |
ciObject::ciObject(oop o) { |
|
53 |
ASSERT_IN_VM; |
|
54 |
if (ciObjectFactory::is_initialized()) { |
|
55 |
_handle = JNIHandles::make_local(o); |
|
56 |
} else { |
|
57 |
_handle = JNIHandles::make_global(o); |
|
58 |
} |
|
59 |
_klass = NULL; |
|
3908 | 60 |
init_flags_from(o); |
1 | 61 |
} |
62 |
||
63 |
// ------------------------------------------------------------------ |
|
64 |
// ciObject::ciObject |
|
65 |
// |
|
66 |
ciObject::ciObject(Handle h) { |
|
67 |
ASSERT_IN_VM; |
|
68 |
if (ciObjectFactory::is_initialized()) { |
|
69 |
_handle = JNIHandles::make_local(h()); |
|
70 |
} else { |
|
71 |
_handle = JNIHandles::make_global(h); |
|
72 |
} |
|
73 |
_klass = NULL; |
|
3908 | 74 |
init_flags_from(h()); |
1 | 75 |
} |
76 |
||
77 |
// ------------------------------------------------------------------ |
|
78 |
// ciObject::ciObject |
|
79 |
// |
|
80 |
// Unloaded klass/method variant. `klass' is the klass of the unloaded |
|
81 |
// klass/method, if that makes sense. |
|
82 |
ciObject::ciObject(ciKlass* klass) { |
|
83 |
ASSERT_IN_VM; |
|
84 |
assert(klass != NULL, "must supply klass"); |
|
85 |
_handle = NULL; |
|
86 |
_klass = klass; |
|
87 |
} |
|
88 |
||
89 |
// ------------------------------------------------------------------ |
|
90 |
// ciObject::ciObject |
|
91 |
// |
|
92 |
// NULL variant. Used only by ciNullObject. |
|
93 |
ciObject::ciObject() { |
|
94 |
ASSERT_IN_VM; |
|
95 |
_handle = NULL; |
|
96 |
_klass = NULL; |
|
97 |
} |
|
98 |
||
99 |
// ------------------------------------------------------------------ |
|
100 |
// ciObject::klass |
|
101 |
// |
|
102 |
// Get the ciKlass of this ciObject. |
|
103 |
ciKlass* ciObject::klass() { |
|
104 |
if (_klass == NULL) { |
|
105 |
if (_handle == NULL) { |
|
106 |
// When both _klass and _handle are NULL, we are dealing |
|
107 |
// with the distinguished instance of ciNullObject. |
|
108 |
// No one should ask it for its klass. |
|
109 |
assert(is_null_object(), "must be null object"); |
|
110 |
ShouldNotReachHere(); |
|
111 |
return NULL; |
|
112 |
} |
|
113 |
||
114 |
GUARDED_VM_ENTRY( |
|
115 |
oop o = get_oop(); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
116 |
_klass = CURRENT_ENV->get_klass(o->klass()); |
1 | 117 |
); |
118 |
} |
|
119 |
return _klass; |
|
120 |
} |
|
121 |
||
122 |
// ------------------------------------------------------------------ |
|
123 |
// ciObject::equals |
|
124 |
// |
|
125 |
// Are two ciObjects equal? |
|
126 |
bool ciObject::equals(ciObject* obj) { |
|
127 |
return (this == obj); |
|
128 |
} |
|
129 |
||
130 |
// ------------------------------------------------------------------ |
|
131 |
// ciObject::hash |
|
132 |
// |
|
133 |
// A hash value for the convenience of compilers. |
|
134 |
// |
|
135 |
// Implementation note: we use the address of the ciObject as the |
|
136 |
// basis for the hash. Use the _ident field, which is well-behaved. |
|
137 |
int ciObject::hash() { |
|
138 |
return ident() * 31; |
|
139 |
} |
|
140 |
||
141 |
// ------------------------------------------------------------------ |
|
3908 | 142 |
// ciObject::constant_encoding |
1 | 143 |
// |
144 |
// The address which the compiler should embed into the |
|
145 |
// generated code to represent this oop. This address |
|
146 |
// is not the true address of the oop -- it will get patched |
|
147 |
// during nmethod creation. |
|
148 |
// |
|
149 |
// |
|
150 |
// |
|
151 |
// Implementation note: we use the handle as the encoding. The |
|
152 |
// nmethod constructor resolves the handle and patches in the oop. |
|
153 |
// |
|
154 |
// This method should be changed to return an generified address |
|
155 |
// to discourage use of the JNI handle. |
|
3908 | 156 |
jobject ciObject::constant_encoding() { |
1 | 157 |
assert(is_null_object() || handle() != NULL, "cannot embed null pointer"); |
3908 | 158 |
assert(can_be_constant(), "oop must be NULL or perm"); |
1 | 159 |
return handle(); |
160 |
} |
|
161 |
||
162 |
// ------------------------------------------------------------------ |
|
3908 | 163 |
// ciObject::can_be_constant |
164 |
bool ciObject::can_be_constant() { |
|
165 |
if (ScavengeRootsInCode >= 1) return true; // now everybody can encode as a constant |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
166 |
return handle() == NULL; |
3908 | 167 |
} |
168 |
||
169 |
// ------------------------------------------------------------------ |
|
170 |
// ciObject::should_be_constant() |
|
171 |
bool ciObject::should_be_constant() { |
|
172 |
if (ScavengeRootsInCode >= 2) return true; // force everybody to be a constant |
|
10514
e229a19078cf
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
9959
diff
changeset
|
173 |
if (is_null_object()) return true; |
e229a19078cf
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
9959
diff
changeset
|
174 |
|
e229a19078cf
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
9959
diff
changeset
|
175 |
ciEnv* env = CURRENT_ENV; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
176 |
|
9332
2c0eaca39eb4
7032162: assert(flat != TypePtr::BOTTOM) failed: cannot alias-analyze an untyped ptr
never
parents:
7397
diff
changeset
|
177 |
// We want Strings and Classes to be embeddable by default since |
2c0eaca39eb4
7032162: assert(flat != TypePtr::BOTTOM) failed: cannot alias-analyze an untyped ptr
never
parents:
7397
diff
changeset
|
178 |
// they used to be in the perm world. Not all Strings used to be |
2c0eaca39eb4
7032162: assert(flat != TypePtr::BOTTOM) failed: cannot alias-analyze an untyped ptr
never
parents:
7397
diff
changeset
|
179 |
// embeddable but there's no easy way to distinguish the interned |
2c0eaca39eb4
7032162: assert(flat != TypePtr::BOTTOM) failed: cannot alias-analyze an untyped ptr
never
parents:
7397
diff
changeset
|
180 |
// from the regulars ones so just treat them all that way. |
2c0eaca39eb4
7032162: assert(flat != TypePtr::BOTTOM) failed: cannot alias-analyze an untyped ptr
never
parents:
7397
diff
changeset
|
181 |
if (klass() == env->String_klass() || klass() == env->Class_klass()) { |
2c0eaca39eb4
7032162: assert(flat != TypePtr::BOTTOM) failed: cannot alias-analyze an untyped ptr
never
parents:
7397
diff
changeset
|
182 |
return true; |
2c0eaca39eb4
7032162: assert(flat != TypePtr::BOTTOM) failed: cannot alias-analyze an untyped ptr
never
parents:
7397
diff
changeset
|
183 |
} |
24322 | 184 |
if (klass()->is_subclass_of(env->MethodHandle_klass()) || |
185 |
klass()->is_subclass_of(env->CallSite_klass())) { |
|
10514
e229a19078cf
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
9959
diff
changeset
|
186 |
assert(ScavengeRootsInCode >= 1, "must be"); |
e229a19078cf
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
9959
diff
changeset
|
187 |
// We want to treat these aggressively. |
e229a19078cf
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
9959
diff
changeset
|
188 |
return true; |
e229a19078cf
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
9959
diff
changeset
|
189 |
} |
e229a19078cf
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
9959
diff
changeset
|
190 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
191 |
return handle() == NULL; |
1 | 192 |
} |
193 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
194 |
// ------------------------------------------------------------------ |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
195 |
// ciObject::should_be_constant() |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
196 |
void ciObject::init_flags_from(oop x) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
197 |
int flags = 0; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
198 |
if (x != NULL) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
199 |
assert(Universe::heap()->is_in_reserved(x), "must be"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
200 |
if (x->is_scavengable()) |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
201 |
flags |= SCAVENGABLE_FLAG; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
202 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
203 |
_ident |= flags; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
10514
diff
changeset
|
204 |
} |
1 | 205 |
|
206 |
// ------------------------------------------------------------------ |
|
207 |
// ciObject::print |
|
208 |
// |
|
209 |
// Print debugging output about this ciObject. |
|
210 |
// |
|
211 |
// Implementation note: dispatch to the virtual print_impl behavior |
|
212 |
// for this ciObject. |
|
213 |
void ciObject::print(outputStream* st) { |
|
214 |
st->print("<%s", type_string()); |
|
215 |
GUARDED_VM_ENTRY(print_impl(st);) |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24322
diff
changeset
|
216 |
st->print(" ident=%d %s address=" INTPTR_FORMAT ">", ident(), |
3908 | 217 |
is_scavengable() ? "SCAVENGABLE" : "", |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24322
diff
changeset
|
218 |
p2i((address)this)); |
1 | 219 |
} |
220 |
||
221 |
// ------------------------------------------------------------------ |
|
222 |
// ciObject::print_oop |
|
223 |
// |
|
224 |
// Print debugging output about the oop this ciObject represents. |
|
225 |
void ciObject::print_oop(outputStream* st) { |
|
226 |
if (is_null_object()) { |
|
227 |
st->print_cr("NULL"); |
|
228 |
} else if (!is_loaded()) { |
|
229 |
st->print_cr("UNLOADED"); |
|
230 |
} else { |
|
231 |
GUARDED_VM_ENTRY(get_oop()->print_on(st);) |
|
232 |
} |
|
233 |
} |