Skip to content

Commit a55dff5

Browse files
dougxcmarwan-hallaoui
authored andcommitted
[GR-69454] Reduce JVMCI annotation API to accessing raw class file bytes
PullRequest: labsjdk-ce/209
2 parents 93a16f0 + faecb26 commit a55dff5

File tree

50 files changed

+1670
-2851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1670
-2851
lines changed

src/hotspot/share/classfile/vmSymbols.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,6 @@ class SerializeClosure;
705705
template(encodeThrowable_name, "encodeThrowable") \
706706
template(encodeThrowable_signature, "(Ljava/lang/Throwable;JI)I") \
707707
template(decodeAndThrowThrowable_name, "decodeAndThrowThrowable") \
708-
template(encodeAnnotations_name, "encodeAnnotations") \
709-
template(encodeAnnotations_signature, "([BLjava/lang/Class;Ljdk/internal/reflect/ConstantPool;Z[Ljava/lang/Class;)[B")\
710708
template(decodeAndThrowThrowable_signature, "(IJZZ)V") \
711709
template(classRedefinedCount_name, "classRedefinedCount") \
712710
template(classLoader_name, "classLoader") \

src/hotspot/share/jvmci/jvmciCompilerToVM.cpp

Lines changed: 224 additions & 197 deletions
Large diffs are not rendered by default.

src/hotspot/share/jvmci/jvmciCompilerToVM.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ class JVMCIObjectArray;
3535

3636
class CompilerToVM {
3737
public:
38+
// Keep in sync with constants in CompilerToVM.java
39+
static const int DECLARED_ANNOTATIONS = 0;
40+
static const int PARAMETER_ANNOTATIONS = 1;
41+
static const int TYPE_ANNOTATIONS = 2;
42+
static const int ANNOTATION_MEMBER_VALUE = 3;
43+
3844
class Data {
3945
friend class JVMCIVMStructs;
4046

@@ -94,7 +100,7 @@ class CompilerToVM {
94100
static HeapWord** _heap_end_addr;
95101
static HeapWord* volatile* _heap_top_addr;
96102
static int _max_oop_map_stack_offset;
97-
static int _fields_annotations_base_offset;
103+
static int _annotation_array_array_base_offset;
98104

99105
static CardTable::CardValue* cardtable_start_address;
100106
static int cardtable_shift;

src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ bool CompilerToVM::Data::_supports_inline_contig_alloc;
118118
HeapWord** CompilerToVM::Data::_heap_end_addr;
119119
HeapWord* volatile* CompilerToVM::Data::_heap_top_addr;
120120
int CompilerToVM::Data::_max_oop_map_stack_offset;
121-
int CompilerToVM::Data::_fields_annotations_base_offset;
121+
int CompilerToVM::Data::_annotation_array_array_base_offset;
122122

123123
CardTable::CardValue* CompilerToVM::Data::cardtable_start_address;
124124
int CompilerToVM::Data::cardtable_shift;
@@ -226,7 +226,7 @@ void CompilerToVM::Data::initialize(JVMCI_TRAPS) {
226226
symbol_init = (address) vmSymbols::object_initializer_name();
227227
symbol_clinit = (address) vmSymbols::class_initializer_name();
228228

229-
_fields_annotations_base_offset = Array<AnnotationArray*>::base_offset_in_bytes();
229+
_annotation_array_array_base_offset = Array<AnnotationArray*>::base_offset_in_bytes();
230230

231231
data_section_item_alignment = relocInfo::addr_unit();
232232

src/hotspot/share/jvmci/jvmciEnv.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "memory/resourceArea.hpp"
3939
#include "memory/universe.hpp"
4040
#include "oops/objArrayKlass.hpp"
41+
#include "oops/recordComponent.hpp"
4142
#include "oops/typeArrayOop.inline.hpp"
4243
#include "prims/jvmtiExport.hpp"
4344
#include "runtime/arguments.hpp"
@@ -1609,6 +1610,30 @@ JVMCIObject JVMCIEnv::new_FieldInfo(FieldInfo* fieldinfo, JVMCI_TRAPS) {
16091610
}
16101611
}
16111612

1613+
JVMCIObject JVMCIEnv::new_HotSpotResolvedJavaRecordComponent(JVMCIObject declaringRecord, int index, RecordComponent* rc, JVMCI_TRAPS) {
1614+
JavaThread* THREAD = JavaThread::current();
1615+
if (is_hotspot()) {
1616+
JavaCallArguments args;
1617+
args.push_oop(Handle(THREAD, HotSpotJVMCI::resolve(declaringRecord)));
1618+
args.push_int(index);
1619+
args.push_int(rc->name_index());
1620+
args.push_int(rc->descriptor_index());
1621+
Handle obj_h = JavaCalls::construct_new_instance(HotSpotJVMCI::HotSpotResolvedJavaRecordComponent::klass(),
1622+
vmSymbols::HotSpotResolvedJavaRecordComponent_constructor_signature(),
1623+
&args,
1624+
THREAD);
1625+
return wrap(obj_h());
1626+
} else {
1627+
JNIAccessMark jni(this, THREAD);
1628+
jobject result = jni()->NewObject(JNIJVMCI::HotSpotResolvedJavaRecordComponent::clazz(),
1629+
JNIJVMCI::HotSpotResolvedJavaRecordComponent::constructor(),
1630+
(jint)rc->name_index(),
1631+
(jint)rc->descriptor_index());
1632+
1633+
return wrap(result);
1634+
}
1635+
}
1636+
16121637
JVMCIObject JVMCIEnv::get_object_constant(oop objOop, bool compressed, bool dont_register) {
16131638
JavaThread* THREAD = JavaThread::current(); // For exception macros.
16141639
Handle obj = Handle(THREAD, objOop);

src/hotspot/share/jvmci/jvmciEnv.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ class JVMCIEnv : public ResourceObj {
433433
JVMCIObject new_HotSpotStackFrameReference(JVMCI_TRAPS);
434434
JVMCIObject new_JVMCIError(JVMCI_TRAPS);
435435
JVMCIObject new_FieldInfo(FieldInfo* fieldinfo, JVMCI_TRAPS);
436+
JVMCIObject new_HotSpotResolvedJavaRecordComponent(JVMCIObject declaringRecord, int index, RecordComponent* rc, JVMCI_TRAPS);
436437

437438
// Makes a handle to a HotSpot heap object. These handles are
438439
// individually reclaimed by JVMCIRuntime::destroy_oop_handle and

src/hotspot/share/jvmci/jvmciJavaClasses.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@
8484
start_class(HotSpotResolvedJavaMethodImpl, jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl) \
8585
long_field(HotSpotResolvedJavaMethodImpl, methodHandle) \
8686
end_class \
87+
start_class(HotSpotResolvedJavaRecordComponent, jdk_vm_ci_hotspot_HotSpotResolvedJavaRecordComponent) \
88+
jvmci_constructor(HotSpotResolvedJavaRecordComponent, "(Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;III)V") \
89+
end_class \
8790
start_class(HotSpotMethodData, jdk_vm_ci_hotspot_HotSpotMethodData) \
8891
long_field(HotSpotMethodData, methodDataPointer) \
8992
end_class \
@@ -165,6 +168,8 @@
165168
end_class \
166169
start_class(ResolvedJavaMethod, jdk_vm_ci_meta_ResolvedJavaMethod) \
167170
end_class \
171+
start_class(ResolvedJavaRecordComponent, jdk_vm_ci_meta_ResolvedJavaRecordComponent) \
172+
end_class \
168173
start_class(PrimitiveConstant, jdk_vm_ci_meta_PrimitiveConstant) \
169174
object_field(PrimitiveConstant, kind, "Ljdk/vm/ci/meta/JavaKind;") \
170175
long_field(PrimitiveConstant, primitive) \
@@ -211,12 +216,18 @@
211216
jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, HotSpotJVMCIRuntime, exceptionToString, exceptionToString_signature) \
212217
jvmci_method(CallStaticVoidMethod, GetStaticMethodID, call_static, void, HotSpotJVMCIRuntime, postTranslation, object_void_signature) \
213218
end_class \
219+
start_class(CompilerToVM, jdk_vm_ci_hotspot_CompilerToVM) \
220+
static_int_field(CompilerToVM, DECLARED_ANNOTATIONS) \
221+
static_int_field(CompilerToVM, PARAMETER_ANNOTATIONS) \
222+
static_int_field(CompilerToVM, TYPE_ANNOTATIONS) \
223+
static_int_field(CompilerToVM, ANNOTATION_MEMBER_VALUE) \
224+
end_class \
214225
start_class(JVMCIError, jdk_vm_ci_common_JVMCIError) \
215226
jvmci_constructor(JVMCIError, "(Ljava/lang/String;)V") \
216227
end_class \
217228
start_class(InspectedFrameVisitor, jdk_vm_ci_code_stack_InspectedFrameVisitor) \
218229
end_class \
219-
start_class(Services, jdk_vm_ci_services_Services) \
230+
start_class(Services, jdk_vm_ci_services_Services) \
220231
end_class \
221232
start_class(JVMCI, jdk_vm_ci_runtime_JVMCI) \
222233
jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, JVMCI, getRuntime, getRuntime_signature) \

src/hotspot/share/jvmci/jvmciRuntime.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,12 @@ class JavaVMRefsInitialization: public StackObj {
14191419
}
14201420
};
14211421

1422+
#ifdef ASSERT
1423+
static void assert_equals(const char* desc, int expect, int actual) {
1424+
assert(expect == actual, "%s: %d != %d", desc, expect, actual);
1425+
}
1426+
#endif
1427+
14221428
void JVMCIRuntime::initialize(JVMCI_TRAPS) {
14231429
// Check first without _lock
14241430
if (_init_state == fully_initialized) {
@@ -1489,6 +1495,11 @@ void JVMCIRuntime::initialize(JVMCI_TRAPS) {
14891495
create_jvmci_primitive_type(T_VOID, JVMCI_CHECK_EXIT_((void)0));
14901496

14911497
DEBUG_ONLY(CodeInstaller::verify_bci_constants(JVMCIENV);)
1498+
1499+
DEBUG_ONLY(assert_equals("DECLARED_ANNOTATIONS", CompilerToVM::DECLARED_ANNOTATIONS, JVMCIENV->get_CompilerToVM_DECLARED_ANNOTATIONS()));
1500+
DEBUG_ONLY(assert_equals("PARAMETER_ANNOTATIONS", CompilerToVM::PARAMETER_ANNOTATIONS, JVMCIENV->get_CompilerToVM_PARAMETER_ANNOTATIONS()));
1501+
DEBUG_ONLY(assert_equals("TYPE_ANNOTATIONS", CompilerToVM::TYPE_ANNOTATIONS, JVMCIENV->get_CompilerToVM_TYPE_ANNOTATIONS()));
1502+
DEBUG_ONLY(assert_equals("ANNOTATION_MEMBER_VALUE", CompilerToVM::ANNOTATION_MEMBER_VALUE, JVMCIENV->get_CompilerToVM_ANNOTATION_MEMBER_VALUE()));
14921503
}
14931504

14941505
_init_state = fully_initialized;

src/hotspot/share/jvmci/vmStructs_jvmci.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
static_field(CompilerToVM::Data, _heap_top_addr, HeapWord* volatile*) \
118118
\
119119
static_field(CompilerToVM::Data, _max_oop_map_stack_offset, int) \
120-
static_field(CompilerToVM::Data, _fields_annotations_base_offset, int) \
120+
static_field(CompilerToVM::Data, _annotation_array_array_base_offset, int) \
121121
\
122122
static_field(CompilerToVM::Data, cardtable_start_address, CardTable::CardValue*) \
123123
static_field(CompilerToVM::Data, cardtable_shift, int) \
@@ -158,7 +158,9 @@
158158
static_field(Abstract_VM_Version, _features, uint64_t) \
159159
\
160160
nonstatic_field(Annotations, _class_annotations, AnnotationArray*) \
161+
nonstatic_field(Annotations, _class_type_annotations, AnnotationArray*) \
161162
nonstatic_field(Annotations, _fields_annotations, Array<AnnotationArray*>*) \
163+
nonstatic_field(Annotations, _fields_type_annotations, Array<AnnotationArray*>*) \
162164
\
163165
nonstatic_field(Array<int>, _length, int) \
164166
unchecked_nonstatic_field(Array<u1>, _data, sizeof(u1)) \
@@ -224,6 +226,7 @@
224226
nonstatic_field(InstanceKlass, _misc_flags._flags, u2) \
225227
nonstatic_field(InstanceKlass, _annotations, Annotations*) \
226228
nonstatic_field(InstanceKlass, _permitted_subclasses, Array<jushort>*) \
229+
nonstatic_field(InstanceKlass, _record_components, Array<RecordComponent*>*) \
227230
\
228231
volatile_nonstatic_field(JavaFrameAnchor, _last_Java_sp, intptr_t*) \
229232
volatile_nonstatic_field(JavaFrameAnchor, _last_Java_pc, address) \
@@ -689,7 +692,9 @@
689692
declare_constant(ConstMethodFlags::_misc_has_localvariable_table) \
690693
declare_constant(ConstMethodFlags::_misc_has_exception_table) \
691694
declare_constant(ConstMethodFlags::_misc_has_method_annotations) \
695+
declare_constant(ConstMethodFlags::_misc_has_type_annotations) \
692696
declare_constant(ConstMethodFlags::_misc_has_parameter_annotations) \
697+
declare_constant(ConstMethodFlags::_misc_has_default_annotations) \
693698
declare_constant(ConstMethodFlags::_misc_caller_sensitive) \
694699
declare_constant(ConstMethodFlags::_misc_is_hidden) \
695700
declare_constant(ConstMethodFlags::_misc_intrinsic_candidate) \

src/hotspot/share/jvmci/vmSymbols_jvmci.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
template(jdk_vm_ci_hotspot_HotSpotInstalledCode, "jdk/vm/ci/hotspot/HotSpotInstalledCode") \
3838
template(jdk_vm_ci_hotspot_HotSpotNmethod, "jdk/vm/ci/hotspot/HotSpotNmethod") \
3939
template(jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl, "jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl") \
40+
template(jdk_vm_ci_hotspot_HotSpotResolvedJavaRecordComponent, "jdk/vm/ci/hotspot/HotSpotResolvedJavaRecordComponent") \
4041
template(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl, "jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl") \
4142
template(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl_FieldInfo, "jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl$FieldInfo") \
4243
template(jdk_vm_ci_hotspot_HotSpotResolvedPrimitiveType, "jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType") \
@@ -55,6 +56,7 @@
5556
template(jdk_vm_ci_hotspot_VMFlag, "jdk/vm/ci/hotspot/VMFlag") \
5657
template(jdk_vm_ci_hotspot_VMIntrinsicMethod, "jdk/vm/ci/hotspot/VMIntrinsicMethod") \
5758
template(jdk_vm_ci_meta_ResolvedJavaMethod, "jdk/vm/ci/meta/ResolvedJavaMethod") \
59+
template(jdk_vm_ci_meta_ResolvedJavaRecordComponent, "jdk/vm/ci/meta/ResolvedJavaRecordComponent") \
5860
template(jdk_vm_ci_meta_JavaConstant, "jdk/vm/ci/meta/JavaConstant") \
5961
template(jdk_vm_ci_meta_PrimitiveConstant, "jdk/vm/ci/meta/PrimitiveConstant") \
6062
template(jdk_vm_ci_meta_RawConstant, "jdk/vm/ci/meta/RawConstant") \
@@ -97,6 +99,7 @@
9799
template(getCompiler_signature, "()Ljdk/vm/ci/runtime/JVMCICompiler;") \
98100
template(exceptionToString_name, "exceptionToString") \
99101
template(exceptionToString_signature, "(Ljava/lang/Throwable;ZZ)[Ljava/lang/String;") \
102+
template(HotSpotResolvedJavaRecordComponent_constructor_signature, "(Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;III)V") \
100103
template(postTranslation_name, "postTranslation") \
101104
template(getName_name, "getName") \
102105
template(bootstrapFinished_name, "bootstrapFinished") \

0 commit comments

Comments
 (0)