--- old/src/cpu/aarch64/vm/interp_masm_aarch64.cpp 2017-08-14 18:56:22.207728982 -0400 +++ new/src/cpu/aarch64/vm/interp_masm_aarch64.cpp 2017-08-14 18:56:21.849743655 -0400 @@ -272,8 +272,7 @@ // load pointer for resolved_references[] objArray ldr(result, Address(result, ConstantPool::cache_offset_in_bytes())); ldr(result, Address(result, ConstantPoolCache::resolved_references_offset_in_bytes())); - // JNIHandles::resolve(obj); - ldr(result, Address(result, 0)); + resolve_oop_handle(result); // Add in the index add(result, result, tmp); load_heap_oop(result, Address(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT))); --- old/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp 2017-08-14 18:56:30.611842029 -0400 +++ new/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp 2017-08-14 18:56:30.339059201 -0400 @@ -3279,6 +3279,12 @@ } } +// ((OopHandle)result).resolve(); +void MacroAssembler::resolve_oop_handle(Register result) { + // OopHandle::resolve is an indirection. + ldr(result, Address(result, 0)); +} + void MacroAssembler::load_mirror(Register dst, Register method) { const int mirror_offset = in_bytes(Klass::java_mirror_offset()); ldr(dst, Address(rmethod, Method::const_offset())); --- old/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp 2017-08-14 18:56:38.237742780 -0400 +++ new/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp 2017-08-14 18:56:38.011415120 -0400 @@ -790,6 +790,7 @@ void store_klass(Register dst, Register src); void cmp_klass(Register oop, Register trial_klass, Register tmp); + void resolve_oop_handle(Register result); void load_mirror(Register dst, Register method); void load_heap_oop(Register dst, Address src); --- old/src/cpu/arm/vm/interp_masm_arm.cpp 2017-08-14 18:56:46.510802057 -0400 +++ new/src/cpu/arm/vm/interp_masm_arm.cpp 2017-08-14 18:56:46.194807226 -0400 @@ -300,8 +300,7 @@ // load pointer for resolved_references[] objArray ldr(cache, Address(result, ConstantPool::cache_offset_in_bytes())); ldr(cache, Address(result, ConstantPoolCache::resolved_references_offset_in_bytes())); - // JNIHandles::resolve(result) - ldr(cache, Address(cache, 0)); + resolve_oop_handle(cache); // Add in the index // convert from field index to resolved_references() index and from // word index to byte offset. Since this is a java object, it can be compressed --- old/src/cpu/arm/vm/macroAssembler_arm.cpp 2017-08-14 18:56:54.718241214 -0400 +++ new/src/cpu/arm/vm/macroAssembler_arm.cpp 2017-08-14 18:56:54.489530889 -0400 @@ -2887,6 +2887,11 @@ return offset(); } +// ((OopHandle)result).resolve(); +void MacroAssembler::resolve_oop_handle(Register result) { + // OopHandle::resolve is an indirection. + ldr(result, Address(result, 0)); +} void MacroAssembler::load_mirror(Register mirror, Register method, Register tmp) { const int mirror_offset = in_bytes(Klass::java_mirror_offset()); @@ -2896,6 +2901,7 @@ ldr(mirror, Address(tmp, mirror_offset)); } + /////////////////////////////////////////////////////////////////////////////// // Compressed pointers --- old/src/cpu/arm/vm/macroAssembler_arm.hpp 2017-08-14 18:57:02.362432854 -0400 +++ new/src/cpu/arm/vm/macroAssembler_arm.hpp 2017-08-14 18:57:02.134995988 -0400 @@ -687,6 +687,7 @@ AbstractAssembler::emit_address((address)L.data()); } + void resolve_oop_handle(Register result); void load_mirror(Register mirror, Register method, Register tmp); // Porting layer between 32-bit ARM and AArch64 --- old/src/cpu/ppc/vm/interp_masm_ppc_64.cpp 2017-08-14 18:57:11.164780205 -0400 +++ new/src/cpu/ppc/vm/interp_masm_ppc_64.cpp 2017-08-14 18:57:10.805529077 -0400 @@ -464,8 +464,7 @@ // Load pointer for resolved_references[] objArray. ld(result, ConstantPool::cache_offset_in_bytes(), result); ld(result, ConstantPoolCache::resolved_references_offset_in_bytes(), result); - // JNIHandles::resolve(result) - ld(result, 0, result); + resolve_oop_handle(result); #ifdef ASSERT Label index_ok; lwa(R0, arrayOopDesc::length_offset_in_bytes(), result); --- old/src/cpu/ppc/vm/macroAssembler_ppc.cpp 2017-08-14 18:57:19.016437686 -0400 +++ new/src/cpu/ppc/vm/macroAssembler_ppc.cpp 2017-08-14 18:57:18.743561164 -0400 @@ -3372,6 +3372,12 @@ } } +// ((OopHandle)result).resolve(); +void MacroAssembler::resolve_oop_handle(Register result) { + // OopHandle::resolve is an indirection. + ld(result, 0, result); +} + void MacroAssembler::load_mirror_from_const_method(Register mirror, Register const_method) { ld(mirror, in_bytes(ConstMethod::constants_offset()), const_method); ld(mirror, ConstantPool::pool_holder_offset_in_bytes(), mirror); --- old/src/cpu/ppc/vm/macroAssembler_ppc.hpp 2017-08-14 18:57:26.990999737 -0400 +++ new/src/cpu/ppc/vm/macroAssembler_ppc.hpp 2017-08-14 18:57:26.764583085 -0400 @@ -725,6 +725,7 @@ void store_klass(Register dst_oop, Register klass, Register tmp = R0); void store_klass_gap(Register dst_oop, Register val = noreg); // Will store 0 if val not specified. + void resolve_oop_handle(Register result); void load_mirror_from_const_method(Register mirror, Register const_method); static int instr_size_for_decode_klass_not_null(); --- old/src/cpu/s390/vm/interp_masm_s390.cpp 2017-08-14 18:57:35.131805637 -0400 +++ new/src/cpu/s390/vm/interp_masm_s390.cpp 2017-08-14 18:57:34.816483447 -0400 @@ -364,8 +364,7 @@ // Load pointer for resolved_references[] objArray. z_lg(result, ConstantPool::cache_offset_in_bytes(), result); z_lg(result, ConstantPoolCache::resolved_references_offset_in_bytes(), result); - // JNIHandles::resolve(result) - z_lg(result, 0, result); // Load resolved references array itself. + resolve_oop_handle(result); // Load resolved references array itself. #ifdef ASSERT NearLabel index_ok; z_lgf(Z_R0, Address(result, arrayOopDesc::length_offset_in_bytes())); --- old/src/cpu/s390/vm/macroAssembler_s390.cpp 2017-08-14 18:57:42.864757548 -0400 +++ new/src/cpu/s390/vm/macroAssembler_s390.cpp 2017-08-14 18:57:42.588693305 -0400 @@ -4660,6 +4660,12 @@ } } +// ((OopHandle)result).resolve(); +void MacroAssembler::resolve_oop_handle(Register result) { + // OopHandle::resolve is an indirection. + z_lg(result, 0, result); +} + void MacroAssembler::load_mirror(Register mirror, Register method) { mem2reg_opt(mirror, Address(method, Method::const_offset())); mem2reg_opt(mirror, Address(mirror, ConstMethod::constants_offset())); --- old/src/cpu/s390/vm/macroAssembler_s390.hpp 2017-08-14 18:57:50.894982899 -0400 +++ new/src/cpu/s390/vm/macroAssembler_s390.hpp 2017-08-14 18:57:50.667609931 -0400 @@ -832,6 +832,7 @@ void oop_decoder(Register Rdst, Register Rsrc, bool maybeNULL, Register Rbase = Z_R1, int pow2_offset = -1); + void resolve_oop_handle(Register result); void load_mirror(Register mirror, Register method); //-------------------------- --- old/src/cpu/sparc/vm/interp_masm_sparc.cpp 2017-08-14 18:57:59.418074455 -0400 +++ new/src/cpu/sparc/vm/interp_masm_sparc.cpp 2017-08-14 18:57:59.101798466 -0400 @@ -730,8 +730,7 @@ // load pointer for resolved_references[] objArray ld_ptr(result, ConstantPool::cache_offset_in_bytes(), result); ld_ptr(result, ConstantPoolCache::resolved_references_offset_in_bytes(), result); - // JNIHandles::resolve(result) - ld_ptr(result, 0, result); + resolve_oop_handle(result); // Add in the index add(result, tmp, result); load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result); --- old/src/cpu/sparc/vm/macroAssembler_sparc.cpp 2017-08-14 18:58:07.159721208 -0400 +++ new/src/cpu/sparc/vm/macroAssembler_sparc.cpp 2017-08-14 18:58:06.930888141 -0400 @@ -3822,6 +3822,12 @@ card_table_write(bs->byte_map_base, tmp, store_addr); } +// ((OopHandle)result).resolve(); +void MacroAssembler::resolve_oop_handle(Register result) { + // OopHandle::resolve is an indirection. + ld_ptr(result, 0, result); +} + void MacroAssembler::load_mirror(Register mirror, Register method) { const int mirror_offset = in_bytes(Klass::java_mirror_offset()); ld_ptr(method, in_bytes(Method::const_offset()), mirror); --- old/src/cpu/sparc/vm/macroAssembler_sparc.hpp 2017-08-14 18:58:14.760663211 -0400 +++ new/src/cpu/sparc/vm/macroAssembler_sparc.hpp 2017-08-14 18:58:14.532512182 -0400 @@ -995,6 +995,7 @@ inline void ldbool(const Address& a, Register d); inline void movbool( bool boolconst, Register d); + void resolve_oop_handle(Register result); void load_mirror(Register mirror, Register method); // klass oop manipulations if compressed --- old/src/cpu/x86/vm/interp_masm_x86.cpp 2017-08-14 18:58:22.960556139 -0400 +++ new/src/cpu/x86/vm/interp_masm_x86.cpp 2017-08-14 18:58:22.634264781 -0400 @@ -511,8 +511,7 @@ // load pointer for resolved_references[] objArray movptr(result, Address(result, ConstantPool::cache_offset_in_bytes())); movptr(result, Address(result, ConstantPoolCache::resolved_references_offset_in_bytes())); - // JNIHandles::resolve(obj); - movptr(result, Address(result, 0)); + resolve_oop_handle(result); // Add in the index addptr(result, tmp); load_heap_oop(result, Address(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT))); --- old/src/cpu/x86/vm/macroAssembler_x86.cpp 2017-08-14 18:58:30.828264187 -0400 +++ new/src/cpu/x86/vm/macroAssembler_x86.cpp 2017-08-14 18:58:30.552216151 -0400 @@ -6604,6 +6604,12 @@ #endif // _LP64 } +// ((OopHandle)result).resolve(); +void MacroAssembler::resolve_oop_handle(Register result) { + // OopHandle::resolve is an indirection. + movptr(result, Address(result, 0)); +} + void MacroAssembler::load_mirror(Register mirror, Register method) { // get mirror const int mirror_offset = in_bytes(Klass::java_mirror_offset()); @@ -7030,7 +7036,6 @@ #endif // _LP64 - // C2 compiled method's prolog code. void MacroAssembler::verified_entry(int framesize, int stack_bang_size, bool fp_mode_24b) { --- old/src/cpu/x86/vm/macroAssembler_x86.hpp 2017-08-14 18:58:38.621640974 -0400 +++ new/src/cpu/x86/vm/macroAssembler_x86.hpp 2017-08-14 18:58:38.393465991 -0400 @@ -327,6 +327,7 @@ void movbool(Address dst, Register src); void testbool(Register dst); + void resolve_oop_handle(Register result); void load_mirror(Register mirror, Register method); // oop manipulations --- old/src/share/vm/classfile/classLoaderData.cpp 2017-08-14 18:58:47.452349635 -0400 +++ new/src/share/vm/classfile/classLoaderData.cpp 2017-08-14 18:58:47.133144780 -0400 @@ -759,14 +759,18 @@ return metaspace; } -jobject ClassLoaderData::add_handle(Handle h) { +OopHandle ClassLoaderData::add_handle(Handle h) { MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); - return (jobject) _handles.add(h()); + return OopHandle(_handles.add(h())); } -void ClassLoaderData::remove_handle_unsafe(jobject h) { - assert(_handles.contains((oop*) h), "Got unexpected handle " PTR_FORMAT, p2i((oop*) h)); - *((oop*) h) = NULL; +void ClassLoaderData::init_handle_locked(OopHandle& dest, Handle h) { + MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); + if (dest.resolve() != NULL) { + return; + } else { + dest = _handles.add(h()); + } } // Add this metadata pointer to be freed when it's safe. This is only during --- old/src/share/vm/classfile/classLoaderData.hpp 2017-08-14 18:58:55.320575410 -0400 +++ new/src/share/vm/classfile/classLoaderData.hpp 2017-08-14 18:58:55.089921820 -0400 @@ -29,6 +29,7 @@ #include "memory/memRegion.hpp" #include "memory/metaspace.hpp" #include "memory/metaspaceCounters.hpp" +#include "oops/oopHandle.hpp" #include "runtime/mutex.hpp" #include "trace/traceMacros.hpp" #include "utilities/growableArray.hpp" @@ -362,8 +363,8 @@ void verify(); const char* loader_name(); - jobject add_handle(Handle h); - void remove_handle_unsafe(jobject h); + OopHandle add_handle(Handle h); + void init_handle_locked(OopHandle& pd, Handle h); // used for concurrent access to ModuleEntry::_pd field void add_class(Klass* k, bool publicize = true); void remove_class(Klass* k); bool contains_klass(Klass* k); --- old/src/share/vm/classfile/javaClasses.cpp 2017-08-14 18:59:02.951901601 -0400 +++ new/src/share/vm/classfile/javaClasses.cpp 2017-08-14 18:59:02.714801738 -0400 @@ -799,7 +799,7 @@ // If java.base was already defined then patch this particular class with java.base. if (javabase_was_defined) { ModuleEntry *javabase_entry = ModuleEntryTable::javabase_moduleEntry(); - assert(javabase_entry != NULL && javabase_entry->module_handle() != NULL, + assert(javabase_entry != NULL && javabase_entry->module() != NULL, "Setting class module field, " JAVA_BASE_NAME " should be defined"); Handle javabase_handle(THREAD, javabase_entry->module()); set_module(mirror(), javabase_handle()); --- old/src/share/vm/classfile/moduleEntry.cpp 2017-08-14 18:59:10.518036081 -0400 +++ new/src/share/vm/classfile/moduleEntry.cpp 2017-08-14 18:59:10.290792078 -0400 @@ -80,19 +80,16 @@ } // Returns the shared ProtectionDomain -Handle ModuleEntry::shared_protection_domain() { - return Handle(Thread::current(), JNIHandles::resolve(_pd)); +oop ModuleEntry::shared_protection_domain() { + return _pd.resolve(); } // Set the shared ProtectionDomain atomically void ModuleEntry::set_shared_protection_domain(ClassLoaderData *loader_data, Handle pd_h) { // Create a handle for the shared ProtectionDomain and save it atomically. - // If someone beats us setting the _pd cache, the created handle is destroyed. - jobject obj = loader_data->add_handle(pd_h); - if (Atomic::cmpxchg_ptr(obj, &_pd, NULL) != NULL) { - loader_data->remove_handle_unsafe(obj); - } + // init_handle_locked checks if someone beats us setting the _pd cache. + loader_data->init_handle_locked(_pd, pd_h); } // Returns true if this module can read module m --- old/src/share/vm/classfile/moduleEntry.hpp 2017-08-14 18:59:18.316922730 -0400 +++ new/src/share/vm/classfile/moduleEntry.hpp 2017-08-14 18:59:18.045772760 -0400 @@ -27,6 +27,7 @@ #include "classfile/classLoaderData.hpp" #include "classfile/vmSymbols.hpp" +#include "oops/oopHandle.hpp" #include "oops/symbol.hpp" #include "prims/jni.h" #include "runtime/jniHandles.hpp" @@ -56,8 +57,8 @@ // data structure. class ModuleEntry : public HashtableEntry { private: - jobject _module; // java.lang.Module - jobject _pd; // java.security.ProtectionDomain, cached + OopHandle _module; // java.lang.Module + OopHandle _pd; // java.security.ProtectionDomain, cached // for shared classes from this module ClassLoaderData* _loader_data; GrowableArray* _reads; // list of modules that are readable by this module @@ -89,16 +90,16 @@ Symbol* name() const { return literal(); } void set_name(Symbol* n) { set_literal(n); } - oop module() const { return JNIHandles::resolve(_module); } - jobject module_handle() const { return _module; } - void set_module(jobject j) { _module = j; } + oop module() const { return _module.resolve(); } + OopHandle module_handle() const { return _module; } + void set_module(OopHandle j) { _module = j; } // The shared ProtectionDomain reference is set once the VM loads a shared class // originated from the current Module. The referenced ProtectionDomain object is // created by the ClassLoader when loading a class (shared or non-shared) from the // Module for the first time. This ProtectionDomain object is used for all // classes from the Module loaded by the same ClassLoader. - Handle shared_protection_domain(); + oop shared_protection_domain(); void set_shared_protection_domain(ClassLoaderData *loader_data, Handle pd); ClassLoaderData* loader_data() const { return _loader_data; } @@ -246,7 +247,7 @@ static void set_javabase_moduleEntry(ModuleEntry* java_base) { _javabase_module = java_base; } static bool javabase_defined() { return ((_javabase_module != NULL) && - (_javabase_module->module_handle() != NULL)); } + (_javabase_module->module() != NULL)); } static void finalize_javabase(Handle module_handle, Symbol* version, Symbol* location); static void patch_javabase_entries(Handle module_handle); --- old/src/share/vm/oops/constantPool.cpp 2017-08-14 18:59:26.168604571 -0400 +++ new/src/share/vm/oops/constantPool.cpp 2017-08-14 18:59:25.804065834 -0400 @@ -130,7 +130,7 @@ } objArrayOop ConstantPool::resolved_references() const { - return (objArrayOop)JNIHandles::resolve(_cache->resolved_references()); + return (objArrayOop)_cache->resolved_references(); } // Create resolved_references array and mapping array for original cp indexes --- old/src/share/vm/oops/constantPool.hpp 2017-08-14 18:59:33.808758577 -0400 +++ new/src/share/vm/oops/constantPool.hpp 2017-08-14 18:59:33.579529186 -0400 @@ -28,6 +28,7 @@ #include "oops/arrayOop.hpp" #include "oops/cpCache.hpp" #include "oops/objArrayOop.hpp" +#include "oops/oopHandle.hpp" #include "oops/symbol.hpp" #include "oops/typeArrayOop.hpp" #include "runtime/handles.hpp" @@ -820,7 +821,7 @@ private: - void set_resolved_references(jobject s) { _cache->set_resolved_references(s); } + void set_resolved_references(OopHandle s) { _cache->set_resolved_references(s); } Array* reference_map() const { return (_cache == NULL) ? NULL : _cache->reference_map(); } void set_reference_map(Array* o) { _cache->set_reference_map(o); } --- old/src/share/vm/oops/cpCache.hpp 2017-08-14 18:59:41.366269608 -0400 +++ new/src/share/vm/oops/cpCache.hpp 2017-08-14 18:59:41.135675250 -0400 @@ -28,6 +28,7 @@ #include "interpreter/bytecodes.hpp" #include "memory/allocation.hpp" #include "oops/array.hpp" +#include "oops/oopHandle.hpp" #include "runtime/orderAccess.hpp" #include "utilities/align.hpp" @@ -413,7 +414,7 @@ // stored in the ConstantPool, which is read-only. // Array of resolved objects from the constant pool and map from resolved // object index to original constant pool index - jobject _resolved_references; + OopHandle _resolved_references; Array* _reference_map; // Sizing @@ -448,8 +449,8 @@ void metaspace_pointers_do(MetaspaceClosure* it); MetaspaceObj::Type type() const { return ConstantPoolCacheType; } - jobject resolved_references() { return _resolved_references; } - void set_resolved_references(jobject s) { _resolved_references = s; } + oop resolved_references() { return _resolved_references.resolve(); } + void set_resolved_references(OopHandle s) { _resolved_references = s; } Array* reference_map() const { return _reference_map; } void set_reference_map(Array* o) { _reference_map = o; } --- old/src/share/vm/prims/jvmtiEnvBase.cpp 2017-08-14 18:59:49.654476801 -0400 +++ new/src/share/vm/prims/jvmtiEnvBase.cpp 2017-08-14 18:59:49.286817872 -0400 @@ -1490,14 +1490,14 @@ } } -GrowableArray* JvmtiModuleClosure::_tbl = NULL; +GrowableArray* JvmtiModuleClosure::_tbl = NULL; jvmtiError JvmtiModuleClosure::get_all_modules(JvmtiEnv* env, jint* module_count_ptr, jobject** modules_ptr) { ResourceMark rm; MutexLocker ml(Module_lock); - _tbl = new GrowableArray(77); + _tbl = new GrowableArray(77); if (_tbl == NULL) { return JVMTI_ERROR_OUT_OF_MEMORY; } @@ -1513,7 +1513,7 @@ return JVMTI_ERROR_OUT_OF_MEMORY; } for (jint idx = 0; idx < len; idx++) { - array[idx] = _tbl->at(idx); + array[idx] = JNIHandles::make_local(Thread::current(), _tbl->at(idx).resolve()); } _tbl = NULL; *modules_ptr = array; --- old/src/share/vm/prims/jvmtiEnvBase.hpp 2017-08-14 18:59:57.458317059 -0400 +++ new/src/share/vm/prims/jvmtiEnvBase.hpp 2017-08-14 18:59:57.228905177 -0400 @@ -30,6 +30,7 @@ #include "prims/jvmtiEventController.hpp" #include "prims/jvmtiThreadState.hpp" #include "prims/jvmtiThreadState.inline.hpp" +#include "oops/oopHandle.hpp" #include "runtime/fieldDescriptor.hpp" #include "runtime/frame.hpp" #include "runtime/handles.inline.hpp" @@ -704,12 +705,12 @@ // Jvmti module closure to collect all modules loaded to the system. class JvmtiModuleClosure : public StackObj { private: - static GrowableArray *_tbl; // Protected with Module_lock + static GrowableArray *_tbl; // Protected with Module_lock static void do_module(ModuleEntry* entry) { assert_locked_or_safepoint(Module_lock); - jobject module = entry->module_handle(); - guarantee(module != NULL, "module object is NULL"); + OopHandle module = entry->module_handle(); + guarantee(module.resolve() != NULL, "module object is NULL"); _tbl->push(module); } --- old/src/share/vm/prims/jvmtiExport.cpp 2017-08-14 19:00:05.259936847 -0400 +++ new/src/share/vm/prims/jvmtiExport.cpp 2017-08-14 19:00:05.029173079 -0400 @@ -764,7 +764,7 @@ ModuleEntry* module_entry = InstanceKlass::cast(klass)->module(); assert(module_entry != NULL, "module_entry should always be set"); if (module_entry->is_named() && - module_entry->module_handle() != NULL && + module_entry->module() != NULL && !module_entry->has_default_read_edges()) { if (!module_entry->set_has_default_read_edges()) { // We won a potential race. --- old/src/share/vm/runtime/vmStructs.cpp 2017-08-14 19:00:13.005848434 -0400 +++ new/src/share/vm/runtime/vmStructs.cpp 2017-08-14 19:00:12.680069364 -0400 @@ -83,6 +83,7 @@ #include "oops/objArrayKlass.hpp" #include "oops/objArrayOop.hpp" #include "oops/oop.inline.hpp" +#include "oops/oopHandle.hpp" #include "oops/symbol.hpp" #include "oops/typeArrayKlass.hpp" #include "oops/typeArrayOop.hpp" @@ -235,7 +236,7 @@ nonstatic_field(ConstantPool, _operands, Array*) \ nonstatic_field(ConstantPool, _resolved_klasses, Array*) \ nonstatic_field(ConstantPool, _length, int) \ - nonstatic_field(ConstantPoolCache, _resolved_references, jobject) \ + nonstatic_field(ConstantPoolCache, _resolved_references, OopHandle) \ nonstatic_field(ConstantPoolCache, _reference_map, Array*) \ nonstatic_field(ConstantPoolCache, _length, int) \ nonstatic_field(ConstantPoolCache, _constant_pool, ConstantPool*) \ @@ -1450,6 +1451,7 @@ declare_oop_type(oop) \ declare_oop_type(narrowOop) \ declare_oop_type(typeArrayOop) \ + declare_oop_type(OopHandle) \ \ /*************************************/ \ /* MethodOop-related data structures */ \ --- /dev/null 2017-08-03 13:42:08.516000218 -0400 +++ new/src/share/vm/oops/oopHandle.hpp 2017-08-14 19:00:20.640943197 -0400 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_OOPS_OOPHANDLE_HPP +#define SHARE_VM_OOPS_OOPHANDLE_HPP + +#include "oops/oop.hpp" +#include "runtime/atomic.hpp" +#include "runtime/orderAccess.hpp" + +class outputStream; + +// Simple class for encapsulating oop pointers stored in metadata. +// These are different from Handle. The Handle class stores pointers +// to oops on the stack, and manages the allocation from a thread local +// area in the constructor. +// This assumes that the caller will allocate the handle in the appropriate +// area. The reason for the encapsulation is to help with naming and to allow +// future uses for read barriers. + +class OopHandle { +private: + oop* _obj; + +public: + OopHandle() : _obj(NULL) {} + OopHandle(oop* w) : _obj(w) {} + + oop resolve() const { return (_obj == NULL) ? (oop)NULL : *_obj; } +}; + +#endif // SHARE_VM_OOPS_OOPHANDLE_HPP