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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "ci/ciObject.hpp"
26 #include "ci/ciUtilities.inline.hpp"
27 #include "gc/shared/collectedHeap.inline.hpp"
28 #include "oops/oop.inline.hpp"
29 #include "runtime/jniHandles.inline.hpp"
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 --
46 // the distinction between `Klass*' and `Klass' are not
185 return ciConstant();
186 }
187
188 // ------------------------------------------------------------------
189 // ciObject::add_to_constant_value_cache()
190 //
191 // Add a constant value to the cache.
192 void ciObject::add_to_constant_value_cache(int off, ciConstant val) {
193 assert(val.is_valid(), "value must be valid");
194 assert(!check_constant_value_cache(off, val.basic_type()).is_valid(), "duplicate");
195 if (_constant_values == nullptr) {
196 Arena* arena = CURRENT_ENV->arena();
197 _constant_values = new (arena) GrowableArray<ConstantValue>(arena, 1, 0, ConstantValue());
198 }
199 _constant_values->append(ConstantValue(off, val));
200 }
201
202 // ------------------------------------------------------------------
203 // ciObject::should_be_constant()
204 bool ciObject::should_be_constant() {
205 if (ScavengeRootsInCode >= 2) return true; // force everybody to be a constant
206 if (is_null_object()) return true;
207
208 ciEnv* env = CURRENT_ENV;
209
210 // We want Strings and Classes to be embeddable by default since
211 // they used to be in the perm world. Not all Strings used to be
212 // embeddable but there's no easy way to distinguish the interned
213 // from the regulars ones so just treat them all that way.
214 if (klass() == env->String_klass() || klass() == env->Class_klass()) {
215 return true;
216 }
217 if (klass()->is_subclass_of(env->MethodHandle_klass()) ||
218 klass()->is_subclass_of(env->CallSite_klass())) {
219 // We want to treat these aggressively.
220 return true;
221 }
222
223 return handle() == nullptr;
224 }
225
226 // ------------------------------------------------------------------
227 // ciObject::print
228 //
229 // Print debugging output about this ciObject.
230 //
231 // Implementation note: dispatch to the virtual print_impl behavior
232 // for this ciObject.
233 void ciObject::print(outputStream* st) {
234 st->print("<%s", type_string());
235 GUARDED_VM_ENTRY(print_impl(st);)
236 st->print(" ident=%d address=" INTPTR_FORMAT ">", ident(), p2i(this));
237 }
238
|
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "ci/ciObject.hpp"
26 #include "ci/ciUtilities.inline.hpp"
27 #include "code/SCCache.hpp"
28 #include "gc/shared/collectedHeap.inline.hpp"
29 #include "oops/oop.inline.hpp"
30 #include "runtime/jniHandles.inline.hpp"
31
32 // ciObject
33 //
34 // This class represents an oop in the HotSpot virtual machine.
35 // Its subclasses are structured in a hierarchy which mirrors
36 // an aggregate of the VM's oop and klass hierarchies (see
37 // oopHierarchy.hpp). Each instance of ciObject holds a handle
38 // to a corresponding oop on the VM side and provides routines
39 // for accessing the information in its oop. By using the ciObject
40 // hierarchy for accessing oops in the VM, the compiler ensures
41 // that it is safe with respect to garbage collection; that is,
42 // GC and compilation can proceed independently without
43 // interference.
44 //
45 // Within the VM, the oop and klass hierarchies are separate.
46 // The compiler interface does not preserve this separation --
47 // the distinction between `Klass*' and `Klass' are not
186 return ciConstant();
187 }
188
189 // ------------------------------------------------------------------
190 // ciObject::add_to_constant_value_cache()
191 //
192 // Add a constant value to the cache.
193 void ciObject::add_to_constant_value_cache(int off, ciConstant val) {
194 assert(val.is_valid(), "value must be valid");
195 assert(!check_constant_value_cache(off, val.basic_type()).is_valid(), "duplicate");
196 if (_constant_values == nullptr) {
197 Arena* arena = CURRENT_ENV->arena();
198 _constant_values = new (arena) GrowableArray<ConstantValue>(arena, 1, 0, ConstantValue());
199 }
200 _constant_values->append(ConstantValue(off, val));
201 }
202
203 // ------------------------------------------------------------------
204 // ciObject::should_be_constant()
205 bool ciObject::should_be_constant() {
206 if (ScavengeRootsInCode >= 2 && !(SCCache::is_on_for_write())) {
207 return true; // force everybody to be a constant
208 }
209 if (is_null_object()) {
210 return true;
211 }
212 ciEnv* env = CURRENT_ENV;
213
214 // We want Strings and Classes to be embeddable by default since
215 // they used to be in the perm world. Not all Strings used to be
216 // embeddable but there's no easy way to distinguish the interned
217 // from the regulars ones so just treat them all that way.
218 if (klass() == env->String_klass() || klass() == env->Class_klass()) {
219 return true;
220 }
221 if ((klass()->is_subclass_of(env->MethodHandle_klass()) ||
222 klass()->is_subclass_of(env->CallSite_klass())) &&
223 !(SCCache::is_on_for_write())) { // For now disable it when caching startup code.
224 // We want to treat these aggressively.
225 return true;
226 }
227
228 return handle() == nullptr;
229 }
230
231 // ------------------------------------------------------------------
232 // ciObject::print
233 //
234 // Print debugging output about this ciObject.
235 //
236 // Implementation note: dispatch to the virtual print_impl behavior
237 // for this ciObject.
238 void ciObject::print(outputStream* st) {
239 st->print("<%s", type_string());
240 GUARDED_VM_ENTRY(print_impl(st);)
241 st->print(" ident=%d address=" INTPTR_FORMAT ">", ident(), p2i(this));
242 }
243
|