Skip to content
Permalink
Browse files
8263589: Introduce JavaValue::get_oop/set_oop
Reviewed-by: coleenp, sspitsyn
  • Loading branch information
stefank committed Mar 16, 2021
1 parent 20297a1 commit a1f6591f6c2aaedc51dcbb51610b1de28239d6e8
Show file tree
Hide file tree
Showing 26 changed files with 72 additions and 67 deletions.
@@ -585,7 +585,7 @@ Klass* ClassListParser::load_current_class(TRAPS) {
THROW_NULL(vmSymbols::java_lang_ClassNotFoundException());
}
assert(result.get_type() == T_OBJECT, "just checking");
oop obj = (oop) result.get_jobject();
oop obj = result.get_oop();
assert(obj != NULL, "jdk.internal.loader.BuiltinClassLoader::loadClass never returns null");
klass = java_lang_Class::as_Klass(obj);
} else {
@@ -2395,7 +2395,7 @@ void java_lang_Throwable::print_stack_trace(Handle throwable, outputStream* st)
CLEAR_PENDING_EXCEPTION;
throwable = Handle();
} else {
throwable = Handle(THREAD, (oop) cause.get_jobject());
throwable = Handle(THREAD, cause.get_oop());
if (throwable.not_null()) {
st->print("Caused by: ");
print(throwable(), st);
@@ -88,7 +88,7 @@ void LambdaFormInvokers::regenerate_holder_classes(TRAPS) {
return;
}

objArrayHandle h_array(THREAD, (objArrayOop)result.get_jobject());
objArrayHandle h_array(THREAD, (objArrayOop)result.get_oop());
int sz = h_array->length();
assert(sz % 2 == 0 && sz >= 2, "Must be even size of length");
for (int i = 0; i < sz; i+= 2) {
@@ -127,15 +127,15 @@ void SystemDictionary::compute_java_loaders(TRAPS) {
vmSymbols::void_classloader_signature(),
CHECK);

_java_system_loader = OopHandle(Universe::vm_global(), (oop)result.get_jobject());
_java_system_loader = OopHandle(Universe::vm_global(), result.get_oop());

JavaCalls::call_static(&result,
class_loader_klass,
vmSymbols::getPlatformClassLoader_name(),
vmSymbols::void_classloader_signature(),
CHECK);

_java_platform_loader = OopHandle(Universe::vm_global(), (oop)result.get_jobject());
_java_platform_loader = OopHandle(Universe::vm_global(), result.get_oop());
}

ClassLoaderData* SystemDictionary::register_loader(Handle class_loader, bool create_mirror_cld) {
@@ -1501,7 +1501,7 @@ InstanceKlass* SystemDictionary::load_instance_class(Symbol* class_name, Handle
CHECK_NULL);

assert(result.get_type() == T_OBJECT, "just checking");
oop obj = (oop) result.get_jobject();
oop obj = result.get_oop();

// Primitive classes return null since forName() can not be
// used to obtain any of the Class objects representing primitives or void
@@ -2243,7 +2243,7 @@ Method* SystemDictionary::find_method_handle_invoker(Klass* klass,
vmSymbols::linkMethod_name(),
vmSymbols::linkMethod_signature(),
&args, CHECK_NULL);
Handle mname(THREAD, (oop) result.get_jobject());
Handle mname(THREAD, result.get_oop());
return unpack_method_and_appendix(mname, accessing_klass, appendix_box, appendix_result, THREAD);
}

@@ -2377,7 +2377,7 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature,
vmSymbols::findMethodHandleType_name(),
vmSymbols::findMethodHandleType_signature(),
&args, CHECK_(empty));
Handle method_type(THREAD, (oop) result.get_jobject());
Handle method_type(THREAD, result.get_oop());

if (can_be_cached) {
// We can cache this MethodType inside the JVM.
@@ -2463,7 +2463,7 @@ Handle SystemDictionary::link_method_handle_constant(Klass* caller,
vmSymbols::linkMethodHandleConstant_name(),
vmSymbols::linkMethodHandleConstant_signature(),
&args, CHECK_(empty));
return Handle(THREAD, (oop) result.get_jobject());
return Handle(THREAD, result.get_oop());
}

// Ask Java to run a bootstrap method, in order to create a dynamic call site
@@ -2505,7 +2505,7 @@ void SystemDictionary::invoke_bootstrap_method(BootstrapInfo& bootstrap_specifie
is_indy ? vmSymbols::linkCallSite_signature() : vmSymbols::linkDynamicConstant_signature(),
&args, CHECK);

Handle value(THREAD, (oop) result.get_jobject());
Handle value(THREAD, result.get_oop());
if (is_indy) {
Handle appendix;
Method* method = unpack_method_and_appendix(value,
@@ -757,7 +757,7 @@ Handle SystemDictionaryShared::get_shared_jar_url(int shared_path_index, TRAPS)
vmSymbols::toFileURL_signature(),
path_string, CHECK_(url_h));

atomic_set_shared_jar_url(shared_path_index, (oop)result.get_jobject());
atomic_set_shared_jar_url(shared_path_index, result.get_oop());
}

url_h = Handle(THREAD, shared_jar_url(shared_path_index));
@@ -819,7 +819,7 @@ Handle SystemDictionaryShared::get_protection_domain_from_classloader(Handle cla
vmSymbols::getProtectionDomain_name(),
vmSymbols::getProtectionDomain_signature(),
cs, CHECK_NH);
return Handle(THREAD, (oop)obj_result.get_jobject());
return Handle(THREAD, obj_result.get_oop());
}

// Returns the ProtectionDomain associated with the JAR file identified by the url.
@@ -862,7 +862,7 @@ Handle SystemDictionaryShared::get_shared_protection_domain(Handle class_loader,
JavaCalls::call_static(&result, classLoaders_klass, vmSymbols::toFileURL_name(),
vmSymbols::toFileURL_signature(),
location_string, CHECK_NH);
url = Handle(THREAD, (oop)result.get_jobject());
url = Handle(THREAD, result.get_oop());
}

Handle pd = get_protection_domain_from_classloader(class_loader, url,
@@ -175,7 +175,7 @@ static oop construct_dcmd_instance(JfrJavaArguments* args, TRAPS) {
args->set_name("<init>");
args->set_signature("()V");
JfrJavaSupport::new_object(args, CHECK_NULL);
return (oop)args->result()->get_jobject();
return args->result()->get_oop();
}

JfrDumpFlightRecordingDCmd::JfrDumpFlightRecordingDCmd(outputStream* output,
@@ -276,7 +276,7 @@ void JfrDumpFlightRecordingDCmd::execute(DCmdSource source, TRAPS) {
execute_args.push_jobject(path_to_gc_roots);

JfrJavaSupport::call_virtual(&execute_args, THREAD);
handle_dcmd_result(output(), (oop)result.get_jobject(), source, THREAD);
handle_dcmd_result(output(), result.get_oop(), source, THREAD);
}

JfrCheckFlightRecordingDCmd::JfrCheckFlightRecordingDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),
@@ -337,7 +337,7 @@ void JfrCheckFlightRecordingDCmd::execute(DCmdSource source, TRAPS) {
execute_args.push_jobject(verbose);

JfrJavaSupport::call_virtual(&execute_args, THREAD);
handle_dcmd_result(output(), (oop)result.get_jobject(), source, THREAD);
handle_dcmd_result(output(), result.get_oop(), source, THREAD);
}

JfrStartFlightRecordingDCmd::JfrStartFlightRecordingDCmd(outputStream* output,
@@ -490,7 +490,7 @@ void JfrStartFlightRecordingDCmd::execute(DCmdSource source, TRAPS) {
execute_args.push_jobject(path_to_gc_roots);

JfrJavaSupport::call_virtual(&execute_args, THREAD);
handle_dcmd_result(output(), (oop)result.get_jobject(), source, THREAD);
handle_dcmd_result(output(), result.get_oop(), source, THREAD);
}

JfrStopFlightRecordingDCmd::JfrStopFlightRecordingDCmd(outputStream* output,
@@ -551,7 +551,7 @@ void JfrStopFlightRecordingDCmd::execute(DCmdSource source, TRAPS) {
execute_args.push_jobject(filepath);

JfrJavaSupport::call_virtual(&execute_args, THREAD);
handle_dcmd_result(output(), (oop)result.get_jobject(), source, THREAD);
handle_dcmd_result(output(), result.get_oop(), source, THREAD);
}

JfrConfigureFlightRecorderDCmd::JfrConfigureFlightRecorderDCmd(outputStream* output,
@@ -672,7 +672,7 @@ void JfrConfigureFlightRecorderDCmd::execute(DCmdSource source, TRAPS) {
execute_args.push_jobject(sample_threads);

JfrJavaSupport::call_virtual(&execute_args, THREAD);
handle_dcmd_result(output(), (oop)result.get_jobject(), source, THREAD);
handle_dcmd_result(output(), result.get_oop(), source, THREAD);
}

bool register_jfr_dcmds() {
@@ -73,7 +73,7 @@ void JfrJavaArguments::Parameters::set_receiver(const oop receiver) {
assert(_storage != NULL, "invariant");
assert(receiver != NULL, "invariant");
JavaValue value(T_OBJECT);
value.set_jobject(cast_from_oop<jobject>(receiver));
value.set_oop(receiver);
_storage[0] = value;
}

@@ -84,7 +84,7 @@ void JfrJavaArguments::Parameters::set_receiver(Handle receiver) {
oop JfrJavaArguments::Parameters::receiver() const {
assert(has_receiver(), "invariant");
assert(_storage[0].get_type() == T_OBJECT, "invariant");
return (oop)_storage[0].get_jobject();
return _storage[0].get_oop();
}

bool JfrJavaArguments::Parameters::has_receiver() const {
@@ -96,7 +96,7 @@ bool JfrJavaArguments::Parameters::has_receiver() const {

void JfrJavaArguments::Parameters::push_oop(const oop obj) {
JavaValue value(T_OBJECT);
value.set_jobject(cast_from_oop<jobject>(obj));
value.set_oop(obj);
push(value);
}

@@ -173,7 +173,7 @@ void JfrJavaArguments::Parameters::copy(JavaCallArguments& args, TRAPS) const {
args.push_double(values(i).get_jdouble());
break;
case T_OBJECT:
args.push_oop(Handle(THREAD, (oop)values(i).get_jobject()));
args.push_oop(Handle(THREAD, values(i).get_oop()));
break;
case T_ADDRESS:
args.push_jobject(values(i).get_jobject());
@@ -162,7 +162,7 @@ static void object_construction(JfrJavaArguments* args, JavaValue* result, Insta
result->set_type(T_VOID); // constructor result type
JfrJavaSupport::call_special(args, CHECK);
result->set_type(T_OBJECT); // set back to original result type
result->set_jobject(cast_from_oop<jobject>(h_obj()));
result->set_oop(h_obj());
}

static void array_construction(JfrJavaArguments* args, JavaValue* result, InstanceKlass* klass, int array_length, TRAPS) {
@@ -175,7 +175,7 @@ static void array_construction(JfrJavaArguments* args, JavaValue* result, Instan
ObjArrayKlass::cast(ak)->initialize(THREAD);
HandleMark hm(THREAD);
objArrayOop arr = ObjArrayKlass::cast(ak)->allocate(array_length, CHECK);
result->set_jobject(cast_from_oop<jobject>(arr));
result->set_oop(arr);
}

static void create_object(JfrJavaArguments* args, JavaValue* result, TRAPS) {
@@ -199,7 +199,7 @@ static void create_object(JfrJavaArguments* args, JavaValue* result, TRAPS) {
static void handle_result(JavaValue* result, bool global_ref, Thread* t) {
assert(result != NULL, "invariant");
DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(t));
const oop result_oop = (const oop)result->get_jobject();
const oop result_oop = result->get_oop();
if (result_oop == NULL) {
return;
}
@@ -343,7 +343,7 @@ static void write_specialized_field(JfrJavaArguments* args, const Handle& h_oop,
write_long_field(h_oop, fd, args->param(1).get_jlong());
break;
case T_OBJECT:
write_oop_field(h_oop, fd, (oop)args->param(1).get_jobject());
write_oop_field(h_oop, fd, args->param(1).get_oop());
break;
case T_ADDRESS:
write_oop_field(h_oop, fd, JfrJavaSupport::resolve_non_null(args->param(1).get_jobject()));
@@ -376,7 +376,7 @@ static void read_specialized_field(JavaValue* result, const Handle& h_oop, field
result->set_jlong(h_oop->long_field(fd->offset()));
break;
case T_OBJECT:
result->set_jobject(cast_from_oop<jobject>(h_oop->obj_field(fd->offset())));
result->set_oop(h_oop->obj_field(fd->offset()));
break;
default:
ShouldNotReachHere();
@@ -457,7 +457,7 @@ void JfrJavaSupport::get_field_local_ref(JfrJavaArguments* args, TRAPS) {
assert(result->get_type() == T_OBJECT, "invariant");

read_field(args, result, CHECK);
const oop obj = (const oop)result->get_jobject();
const oop obj = result->get_oop();

if (obj != NULL) {
result->set_jobject(local_jni_handle(obj, THREAD));
@@ -472,7 +472,7 @@ void JfrJavaSupport::get_field_global_ref(JfrJavaArguments* args, TRAPS) {
assert(result != NULL, "invariant");
assert(result->get_type() == T_OBJECT, "invariant");
read_field(args, result, CHECK);
const oop obj = (const oop)result->get_jobject();
const oop obj = result->get_oop();
if (obj != NULL) {
result->set_jobject(global_jni_handle(obj, THREAD));
}
@@ -86,7 +86,7 @@ static const typeArrayOop invoke(jlong trace_id,
return NULL;
}
// The result should be a [B
const oop res = (oop)result.get_jobject();
const oop res = result.get_oop();
assert(res != NULL, "invariant");
assert(res->is_typeArray(), "invariant");
assert(TypeArrayKlass::cast(res->klass())->element_type() == T_BYTE, "invariant");
@@ -97,7 +97,7 @@ bool JfrRecorderThread::start(JfrCheckpointManager* cp_manager, JfrPostBox* post
create_thread_args.push_oop(SystemDictionary::java_system_loader());

JfrJavaSupport::call_static(&create_thread_args, CHECK_false);
instanceHandle h_thread_oop(THREAD, (instanceOop)result.get_jobject());
instanceHandle h_thread_oop(THREAD, (instanceOop)result.get_oop());
assert(h_thread_oop.not_null(), "invariant");
// attempt thread start
Thread* const t = start_thread(h_thread_oop, recorderthread_entry,THREAD);
@@ -44,7 +44,7 @@ static oop new_java_util_arraylist(TRAPS) {
JavaValue result(T_OBJECT);
JfrJavaArguments args(&result, "java/util/ArrayList", "<init>", "()V", CHECK_NULL);
JfrJavaSupport::new_object(&args, CHECK_NULL);
return (oop)result.get_jobject();
return result.get_oop();
}

static const int initial_array_size = 64;
@@ -1045,7 +1045,7 @@ C2V_VMENTRY_NULL(jobject, executeHotSpotNmethod, (JNIEnv* env, jobject, jobject
if (jap.return_type() == T_VOID) {
return NULL;
} else if (is_reference_type(jap.return_type())) {
return JNIHandles::make_local(THREAD, (oop) result.get_jobject());
return JNIHandles::make_local(THREAD, result.get_oop());
} else {
jvalue *value = (jvalue *) result.get_value_addr();
// Narrow the value down if required (Important on big endian machines)
@@ -1329,8 +1329,8 @@ C2V_VMENTRY_NULL(jobject, iterateFrames, (JNIEnv* env, jobject compilerToVM, job
JavaCallArguments args(visitor);
args.push_oop(frame_reference);
call_interface(&result, HotSpotJVMCI::InspectedFrameVisitor::klass(), vmSymbols::visitFrame_name(), vmSymbols::visitFrame_signature(), &args, CHECK_NULL);
if (result.get_jobject() != NULL) {
return JNIHandles::make_local(thread, (oop) result.get_jobject());
if (result.get_oop() != NULL) {
return JNIHandles::make_local(thread, result.get_oop());
}
assert(initialSkip == 0, "There should be no match before initialSkip == 0");
if (HotSpotJVMCI::HotSpotStackFrameReference::objectsMaterialized(JVMCIENV, frame_reference()) == JNI_TRUE) {
@@ -1832,7 +1832,7 @@ C2V_VMENTRY_NULL(jobject, boxPrimitive, (JNIEnv* env, jobject, jobject object))
box_klass,
vmSymbols::valueOf_name(),
box_signature, &jargs, CHECK_NULL);
oop hotspot_box = (oop) box_result.get_jobject();
oop hotspot_box = box_result.get_oop();
JVMCIObject result = JVMCIENV->get_object_constant(hotspot_box, false);
return JVMCIENV->get_jobject(result);
C2V_END

0 comments on commit a1f6591

Please sign in to comment.