Skip to content
This repository was archived by the owner on May 29, 2024. It is now read-only.

Commit cebb0ea

Browse files
committed
Review comments
1 parent d8901d5 commit cebb0ea

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ C2V_VMENTRY_NULL(jobject, getResolvedJavaType0, (JNIEnv* env, jobject, jobject b
409409
JVMCI_THROW_MSG_NULL(NullPointerException, "base object is null");
410410
}
411411

412+
const char* base_desc = nullptr;
412413
JVMCIKlassHandle klass(THREAD);
413414
if (offset == oopDesc::klass_offset_in_bytes()) {
414415
if (JVMCIENV->isa_HotSpotObjectConstantImpl(base_object)) {
@@ -423,6 +424,7 @@ C2V_VMENTRY_NULL(jobject, getResolvedJavaType0, (JNIEnv* env, jobject, jobject b
423424
if (offset == ConstantPool::pool_holder_offset_in_bytes()) {
424425
klass = cp->pool_holder();
425426
} else {
427+
base_desc = FormatBufferResource("[constant pool for %s]", cp->pool_holder()->signature_name());
426428
goto unexpected;
427429
}
428430
} else if (JVMCIENV->isa_HotSpotResolvedObjectTypeImpl(base_object)) {
@@ -442,6 +444,7 @@ C2V_VMENTRY_NULL(jobject, getResolvedJavaType0, (JNIEnv* env, jobject, jobject b
442444
int index = (offset - in_bytes(Klass::primary_supers_offset())) / sizeof(Klass*);
443445
klass = base_klass->primary_super_of_depth(index);
444446
} else {
447+
base_desc = FormatBufferResource("[%s]", base_klass->signature_name());
445448
goto unexpected;
446449
}
447450
} else if (JVMCIENV->isa_HotSpotObjectConstantImpl(base_object)) {
@@ -452,9 +455,13 @@ C2V_VMENTRY_NULL(jobject, getResolvedJavaType0, (JNIEnv* env, jobject, jobject b
452455
} else if (offset == java_lang_Class::array_klass_offset()) {
453456
klass = java_lang_Class::array_klass_acquire(base_oop());
454457
} else {
458+
base_desc = FormatBufferResource("[Class=%s]", java_lang_Class::as_Klass(base_oop())->signature_name());
455459
goto unexpected;
456460
}
457461
} else {
462+
if (!base_oop.is_null()) {
463+
base_desc = FormatBufferResource("[%s]", base_oop()->klass()->signature_name());
464+
}
458465
goto unexpected;
459466
}
460467
} else if (JVMCIENV->isa_HotSpotMethodData(base_object)) {
@@ -481,8 +488,8 @@ C2V_VMENTRY_NULL(jobject, getResolvedJavaType0, (JNIEnv* env, jobject, jobject b
481488

482489
unexpected:
483490
JVMCI_THROW_MSG_NULL(IllegalArgumentException,
484-
err_msg("Unexpected arguments: %s " JLONG_FORMAT " %s",
485-
base_object.is_non_null() ? JVMCIENV->klass_name(base_object) : "null",
491+
err_msg("Unexpected arguments: %s%s " JLONG_FORMAT " %s",
492+
JVMCIENV->klass_name(base_object), base_desc == nullptr ? "" : base_desc,
486493
offset, compressed ? "true" : "false"));
487494
}
488495

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerToVM.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -868,19 +868,21 @@ HotSpotConstantPool getConstantPool(MetaspaceObject object) {
868868

869869
/**
870870
* Read a {@code Klass*} value from the memory location described by {@code base} plus
871-
* {@code displacement} and return the {@link HotSpotResolvedObjectTypeImpl} wrapping it. This
872-
* method does no checking that the memory location actually contains a valid pointer and may
873-
* crash the VM if an invalid location is provided. If the {@code base} is null then
874-
* {@code displacement} is used by itself. If {@code base} is a
875-
* {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or
876-
* {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object
877-
* and added to {@code displacement}. Any other non-null object type causes an
878-
* {@link IllegalArgumentException} to be thrown.
871+
* {@code displacement} and return the {@link HotSpotResolvedObjectTypeImpl} wrapping it. This method
872+
* only performs the read if the memory location is known to contain a valid Klass*. If
873+
* {@code base} is a {@link HotSpotConstantPool}, {@link HotSpotMethodData}, {@link HotSpotObjectConstantImpl},
874+
* or {@link HotSpotResolvedObjectTypeImpl} then the field
875+
* corresopnding to {@code displacement} is fetched using the appropriate HotSpot accessor. Any
876+
* other object type or an unexpected displacement causes an {@link IllegalArgumentException} to
877+
* be thrown. The set of fields which can be read in this fashion corresponds to the {@link VMField}
878+
* with type {@code Klass*} that are described in the {@link HotSpotVMConfigStore#getFields()}.
879+
* Additionally several injected fields in {@link Class} are also handled.
879880
*
880-
* @param base an object to read from or null
881+
* @param base an object to read from
881882
* @param displacement
882883
* @param compressed true if the location contains a compressed Klass*
883884
* @return null or the resolved method for this location
885+
* @throws NullPointerException if {@code base == null}
884886
*/
885887
private native HotSpotResolvedObjectTypeImpl getResolvedJavaType0(Object base, long displacement, boolean compressed);
886888

0 commit comments

Comments
 (0)