Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/vmSymbols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ class SerializeClosure;
template(encodeThrowable_signature, "(Ljava/lang/Throwable;JI)I") \
template(decodeAndThrowThrowable_name, "decodeAndThrowThrowable") \
template(encodeAnnotations_name, "encodeAnnotations") \
template(encodeAnnotations_signature, "([BLjava/lang/Class;Ljdk/internal/reflect/ConstantPool;Z[Ljava/lang/Class;)[B")\
template(encodeAnnotations_signature, "([BILjava/lang/Class;Ljdk/internal/reflect/ConstantPool;Ljava/lang/Class;)[B")\
template(decodeAndThrowThrowable_signature, "(IJZZ)V") \
template(classRedefinedCount_name, "classRedefinedCount") \
template(classLoader_name, "classLoader") \
Expand Down
348 changes: 207 additions & 141 deletions src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/hotspot/share/jvmci/jvmciCompilerToVM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ class JVMCIObjectArray;

class CompilerToVM {
public:
// Keep in sync with constants in VMSupport.java
static const int DECLARED_ANNOTATIONS = 0;
static const int PARAMETER_ANNOTATIONS = 1;
static const int TYPE_ANNOTATIONS = 2;
static const int ANNOTATION_MEMBER_VALUE = 3;

class Data {
friend class JVMCIVMStructs;

Expand Down
25 changes: 25 additions & 0 deletions src/hotspot/share/jvmci/jvmciEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
#include "oops/objArrayKlass.hpp"
#include "oops/recordComponent.hpp"
#include "oops/typeArrayOop.inline.hpp"
#include "prims/jvmtiExport.hpp"
#include "runtime/arguments.hpp"
Expand Down Expand Up @@ -1608,6 +1609,30 @@ JVMCIObject JVMCIEnv::new_FieldInfo(FieldInfo* fieldinfo, JVMCI_TRAPS) {
}
}

JVMCIObject JVMCIEnv::new_HotSpotResolvedJavaRecordComponent(JVMCIObject declaringRecord, int index, RecordComponent* rc, JVMCI_TRAPS) {
JavaThread* THREAD = JavaThread::current();
if (is_hotspot()) {
JavaCallArguments args;
args.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(declaringRecord)));
args.push_int(index);
args.push_int(rc->name_index());
args.push_int(rc->descriptor_index());
Handle obj_h = JavaCalls::construct_new_instance(HotSpotJVMCI::HotSpotResolvedJavaRecordComponent::klass(),
vmSymbols::HotSpotResolvedJavaRecordComponent_constructor_signature(),
&args,
THREAD);
return wrap(obj_h());
} else {
JNIAccessMark jni(this, THREAD);
jobject result = jni()->NewObject(JNIJVMCI::HotSpotResolvedJavaRecordComponent::clazz(),
JNIJVMCI::HotSpotResolvedJavaRecordComponent::constructor(),
(jint)rc->name_index(),
(jint)rc->descriptor_index());

return wrap(result);
}
}

JVMCIObject JVMCIEnv::get_object_constant(oop objOop, bool compressed, bool dont_register) {
JavaThread* THREAD = JavaThread::current(); // For exception macros.
Handle obj = Handle(THREAD, objOop);
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/jvmci/jvmciEnv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ class JVMCIEnv : public ResourceObj {
JVMCIObject new_HotSpotStackFrameReference(JVMCI_TRAPS);
JVMCIObject new_JVMCIError(JVMCI_TRAPS);
JVMCIObject new_FieldInfo(FieldInfo* fieldinfo, JVMCI_TRAPS);
JVMCIObject new_HotSpotResolvedJavaRecordComponent(JVMCIObject declaringRecord, int index, RecordComponent* rc, JVMCI_TRAPS);

// Makes a handle to a HotSpot heap object. These handles are
// individually reclaimed by JVMCIRuntime::destroy_oop_handle and
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/jvmci/jvmciJavaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ void JNIJVMCI::initialize_field_id(JNIEnv* env, jfieldID &fieldid, jclass clazz,
GET_JNI_CONSTRUCTOR(className, signature)

extern "C" {
void JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass);
void JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass, jint declaredAnnotations, jint parameterAnnotations, jint typeAnnotations);
jobject JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c);
jlong JNICALL JVM_ReadSystemPropertiesInfo(JNIEnv *env, jclass c, jintArray offsets_handle);
}
Expand Down
9 changes: 9 additions & 0 deletions src/hotspot/share/jvmci/jvmciJavaClasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
start_class(HotSpotResolvedJavaMethodImpl, jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl) \
long_field(HotSpotResolvedJavaMethodImpl, methodHandle) \
end_class \
start_class(HotSpotResolvedJavaRecordComponent, jdk_vm_ci_hotspot_HotSpotResolvedJavaRecordComponent) \
jvmci_constructor(HotSpotResolvedJavaRecordComponent, "(Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;III)V") \
end_class \
start_class(HotSpotMethodData, jdk_vm_ci_hotspot_HotSpotMethodData) \
long_field(HotSpotMethodData, methodDataPointer) \
end_class \
Expand Down Expand Up @@ -166,6 +169,8 @@
end_class \
start_class(ResolvedJavaMethod, jdk_vm_ci_meta_ResolvedJavaMethod) \
end_class \
start_class(ResolvedJavaRecordComponent, jdk_vm_ci_meta_ResolvedJavaRecordComponent) \
end_class \
start_class(PrimitiveConstant, jdk_vm_ci_meta_PrimitiveConstant) \
object_field(PrimitiveConstant, kind, "Ljdk/vm/ci/meta/JavaKind;") \
long_field(PrimitiveConstant, primitive) \
Expand Down Expand Up @@ -233,6 +238,10 @@
start_class(VMSupport, jdk_internal_vm_VMSupport) \
jvmci_method(CallStaticIntMethod, GetStaticMethodID, call_static, int, VMSupport, encodeThrowable, encodeThrowable_signature) \
jvmci_method(CallStaticVoidMethod, GetStaticMethodID, call_static, void, VMSupport, decodeAndThrowThrowable, decodeAndThrowThrowable_signature) \
static_int_field(VMSupport, DECLARED_ANNOTATIONS) \
static_int_field(VMSupport, PARAMETER_ANNOTATIONS) \
static_int_field(VMSupport, TYPE_ANNOTATIONS) \
static_int_field(VMSupport, ANNOTATION_MEMBER_VALUE) \
end_class \
start_class(ArrayIndexOutOfBoundsException, java_lang_ArrayIndexOutOfBoundsException) \
jvmci_constructor(ArrayIndexOutOfBoundsException, "(Ljava/lang/String;)V") \
Expand Down
12 changes: 12 additions & 0 deletions src/hotspot/share/jvmci/jvmciRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,13 @@ class JavaVMRefsInitialization: public StackObj {
}
};

#ifdef ASSERT
static void assert_equals(const char* desc, int expect, int actual) {
assert(expect == actual, "%s: %d != %d", desc, expect, actual);

}
#endif

void JVMCIRuntime::initialize(JVMCI_TRAPS) {
// Check first without _lock
if (_init_state == fully_initialized) {
Expand Down Expand Up @@ -1464,6 +1471,11 @@ void JVMCIRuntime::initialize(JVMCI_TRAPS) {
create_jvmci_primitive_type(T_VOID, JVMCI_CHECK_EXIT_((void)0));

DEBUG_ONLY(CodeInstaller::verify_bci_constants(JVMCIENV);)

DEBUG_ONLY(assert_equals("DECLARED_ANNOTATIONS", CompilerToVM::DECLARED_ANNOTATIONS, JVMCIENV->get_VMSupport_DECLARED_ANNOTATIONS()));
DEBUG_ONLY(assert_equals("PARAMETER_ANNOTATIONS", CompilerToVM::PARAMETER_ANNOTATIONS, JVMCIENV->get_VMSupport_PARAMETER_ANNOTATIONS()));
DEBUG_ONLY(assert_equals("TYPE_ANNOTATIONS", CompilerToVM::TYPE_ANNOTATIONS, JVMCIENV->get_VMSupport_TYPE_ANNOTATIONS()));
DEBUG_ONLY(assert_equals("ANNOTATION_MEMBER_VALUE", CompilerToVM::ANNOTATION_MEMBER_VALUE, JVMCIENV->get_VMSupport_ANNOTATION_MEMBER_VALUE()));
}

_init_state = fully_initialized;
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/jvmci/vmStructs_jvmci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
volatile_nonstatic_field(InstanceKlass, _init_thread, JavaThread*) \
nonstatic_field(InstanceKlass, _misc_flags._flags, u2) \
nonstatic_field(InstanceKlass, _annotations, Annotations*) \
nonstatic_field(InstanceKlass, _record_components, Array<RecordComponent*>*) \
\
volatile_nonstatic_field(JavaFrameAnchor, _last_Java_sp, intptr_t*) \
volatile_nonstatic_field(JavaFrameAnchor, _last_Java_pc, address) \
Expand Down Expand Up @@ -710,6 +711,7 @@
declare_constant(ConstMethodFlags::_misc_has_exception_table) \
declare_constant(ConstMethodFlags::_misc_has_method_annotations) \
declare_constant(ConstMethodFlags::_misc_has_parameter_annotations) \
declare_constant(ConstMethodFlags::_misc_has_default_annotations) \
declare_constant(ConstMethodFlags::_misc_caller_sensitive) \
declare_constant(ConstMethodFlags::_misc_is_hidden) \
declare_constant(ConstMethodFlags::_misc_intrinsic_candidate) \
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/jvmci/vmSymbols_jvmci.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
template(jdk_vm_ci_hotspot_HotSpotInstalledCode, "jdk/vm/ci/hotspot/HotSpotInstalledCode") \
template(jdk_vm_ci_hotspot_HotSpotNmethod, "jdk/vm/ci/hotspot/HotSpotNmethod") \
template(jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl, "jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl") \
template(jdk_vm_ci_hotspot_HotSpotResolvedJavaRecordComponent, "jdk/vm/ci/hotspot/HotSpotResolvedJavaRecordComponent") \
template(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl, "jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl") \
template(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl_FieldInfo, "jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl$FieldInfo") \
template(jdk_vm_ci_hotspot_HotSpotResolvedPrimitiveType, "jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType") \
Expand All @@ -55,6 +56,7 @@
template(jdk_vm_ci_hotspot_VMFlag, "jdk/vm/ci/hotspot/VMFlag") \
template(jdk_vm_ci_hotspot_VMIntrinsicMethod, "jdk/vm/ci/hotspot/VMIntrinsicMethod") \
template(jdk_vm_ci_meta_ResolvedJavaMethod, "jdk/vm/ci/meta/ResolvedJavaMethod") \
template(jdk_vm_ci_meta_ResolvedJavaRecordComponent, "jdk/vm/ci/meta/ResolvedJavaRecordComponent") \
template(jdk_vm_ci_meta_JavaConstant, "jdk/vm/ci/meta/JavaConstant") \
template(jdk_vm_ci_meta_PrimitiveConstant, "jdk/vm/ci/meta/PrimitiveConstant") \
template(jdk_vm_ci_meta_RawConstant, "jdk/vm/ci/meta/RawConstant") \
Expand Down Expand Up @@ -97,6 +99,7 @@
template(getCompiler_signature, "()Ljdk/vm/ci/runtime/JVMCICompiler;") \
template(exceptionToString_name, "exceptionToString") \
template(exceptionToString_signature, "(Ljava/lang/Throwable;ZZ)[Ljava/lang/String;") \
template(HotSpotResolvedJavaRecordComponent_constructor_signature, "(Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;III)V") \
template(postTranslation_name, "postTranslation") \
template(getName_name, "getName") \
template(bootstrapFinished_name, "bootstrapFinished") \
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -3674,7 +3674,7 @@ private AnnotationData annotationData() {

private AnnotationData createAnnotationData(int classRedefinedCount) {
Map<Class<? extends Annotation>, Annotation> declaredAnnotations =
AnnotationParser.parseAnnotations(getRawAnnotations(), getConstantPool(), this);
AnnotationParser.parseAnnotations(getRawAnnotations(), getConstantPool(), this, true);
Class<?> superClass = getSuperclass();
Map<Class<? extends Annotation>, Annotation> annotations = null;
if (superClass != null) {
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/reflect/Executable.java
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,8 @@ private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
getAnnotationBytes(),
SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
getDeclaringClass()
);
getDeclaringClass(),
true);
}
declaredAnnotations = declAnnos;
}
Expand Down
2 changes: 1 addition & 1 deletion src/java.base/share/classes/java/lang/reflect/Field.java
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
annotations,
SharedSecrets.getJavaLangAccess()
.getConstantPool(getDeclaringClass()),
getDeclaringClass());
getDeclaringClass(), true);
}
declaredAnnotations = declAnnos;
}
Expand Down
22 changes: 8 additions & 14 deletions src/java.base/share/classes/java/lang/reflect/Method.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import sun.reflect.generics.scope.MethodScope;
import sun.reflect.annotation.AnnotationType;
import sun.reflect.annotation.AnnotationParser;
import sun.reflect.annotation.EnumValue;
import sun.reflect.annotation.EnumValueArray;
import java.lang.annotation.Annotation;
import java.lang.annotation.AnnotationFormatError;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -197,6 +199,10 @@ byte[] getAnnotationBytes() {
return annotations;
}

byte[] getAnnotationDefaultBytes() {
return annotationDefault;
}

/**
* Returns the {@code Class} object representing the class or interface
* that declares the method represented by this object.
Expand Down Expand Up @@ -750,22 +756,10 @@ void setMethodAccessor(MethodAccessor accessor) {
* @jls 9.6.2 Defaults for Annotation Interface Elements
*/
public Object getDefaultValue() {
if (annotationDefault == null)
if (annotationDefault == null) {
return null;
Class<?> memberType = AnnotationType.invocationHandlerReturnType(
getReturnType());
Object result = AnnotationParser.parseMemberValue(
memberType, ByteBuffer.wrap(annotationDefault),
SharedSecrets.getJavaLangAccess().
getConstantPool(getDeclaringClass()),
getDeclaringClass());
if (result instanceof ExceptionProxy) {
if (result instanceof TypeNotPresentExceptionProxy proxy) {
throw new TypeNotPresentException(proxy.typeName(), proxy.getCause());
}
throw new AnnotationFormatError("Invalid default: " + this);
}
return result;
return AnnotationParser.parseAnnotationDefault(this, annotationDefault, true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private Map<Class<? extends Annotation>, Annotation> declaredAnnotations() {
annotations,
SharedSecrets.getJavaLangAccess()
.getConstantPool(getDeclaringRecord()),
getDeclaringRecord());
getDeclaringRecord(), true);
}
declaredAnnotations = declAnnos;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public Class<?>[] getExecutableSharedExceptionTypes(Executable ex) {
return ex.getSharedExceptionTypes();
}

public byte[] getAnnotationDefaultBytes(Method arg) {
return arg.getAnnotationDefaultBytes();
}

//
// Copying routines, needed to quickly fabricate new Field,
// Method, and Constructor objects from templates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public interface JavaLangReflectAccess {
/** Gets the shared array of exception types of an Executable. */
public Class<?>[] getExecutableSharedExceptionTypes(Executable ex);

/** Gets the value of Method.defaultAnnotation */
public byte[] getAnnotationDefaultBytes(Method arg);

// Copying routines, needed to quickly fabricate new Field,
// Method, and Constructor objects from templates

Expand Down
Loading