Skip to content

Commit c45ebc2

Browse files
committed
JVMCI support
1 parent 28a26ae commit c45ebc2

File tree

6 files changed

+22
-6
lines changed

6 files changed

+22
-6
lines changed

src/hotspot/share/jvmci/jvmciCompilerToVM.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class CompilerToVM {
3939
friend class JVMCIVMStructs;
4040

4141
private:
42+
static int oopDesc_klass_offset_in_bytes;
43+
static int arrayOopDesc_length_offset_in_bytes;
44+
4245
static int Klass_vtable_start_offset;
4346
static int Klass_vtable_length_offset;
4447

src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
#include "runtime/stubRoutines.hpp"
5757
#include "utilities/resourceHash.hpp"
5858

59+
int CompilerToVM::Data::oopDesc_klass_offset_in_bytes;
60+
int CompilerToVM::Data::arrayOopDesc_length_offset_in_bytes;
5961

6062
int CompilerToVM::Data::Klass_vtable_start_offset;
6163
int CompilerToVM::Data::Klass_vtable_length_offset;
@@ -148,6 +150,9 @@ int CompilerToVM::Data::data_section_item_alignment;
148150
JVMTI_ONLY( int* CompilerToVM::Data::_should_notify_object_alloc; )
149151

150152
void CompilerToVM::Data::initialize(JVMCI_TRAPS) {
153+
oopDesc_klass_offset_in_bytes = oopDesc::klass_offset_in_bytes();
154+
arrayOopDesc_length_offset_in_bytes = arrayOopDesc::length_offset_in_bytes();
155+
151156
Klass_vtable_start_offset = in_bytes(Klass::vtable_start_offset());
152157
Klass_vtable_length_offset = in_bytes(Klass::vtable_length_offset());
153158

src/hotspot/share/jvmci/vmStructs_jvmci.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
#endif
5757

5858
#define VM_STRUCTS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field) \
59+
static_field(CompilerToVM::Data, oopDesc_klass_offset_in_bytes, int) \
60+
static_field(CompilerToVM::Data, arrayOopDesc_length_offset_in_bytes, int) \
61+
\
5962
static_field(CompilerToVM::Data, Klass_vtable_start_offset, int) \
6063
static_field(CompilerToVM::Data, Klass_vtable_length_offset, int) \
6164
\
@@ -794,6 +797,7 @@
794797
declare_constant(InvocationCounter::count_increment) \
795798
declare_constant(InvocationCounter::count_shift) \
796799
\
800+
declare_constant(markWord::klass_shift) \
797801
declare_constant(markWord::hash_shift) \
798802
declare_constant(markWord::monitor_value) \
799803
\

src/hotspot/share/oops/oop.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,12 @@ class oopDesc {
331331
static int klass_offset_in_bytes() {
332332
#ifdef _LP64
333333
if (UseCompactObjectHeaders) {
334-
// NOTE: The only place where this is used with compact headers is
335-
// the C2 compiler, and even there we don't use it to access the (narrow)Klass*
334+
// NOTE: The only places where this is used with compact headers are the C2
335+
// compiler and JVMCI, and even there we don't use it to access the (narrow)Klass*
336336
// directly. It is used only as a placeholder to identify the special memory slice
337-
// of LoadNKlass instructions. This value could be any value that is not a valid
337+
// containing Klass* info. This value could be any value that is not a valid
338338
// field offset. Use an offset halfway into the markWord, as the markWord is never
339-
// partially loaded from C2.
339+
// partially loaded from C2 and JVMCI.
340340
return mark_offset_in_bytes() + 4;
341341
} else
342342
#endif

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ String getHostArchitectureName() {
6969

7070
final int objectAlignment = getFlag("ObjectAlignmentInBytes", Integer.class);
7171

72-
final int hubOffset = getFieldOffset("oopDesc::_metadata._klass", Integer.class, "Klass*");
72+
final int klassOffsetInBytes = getFieldValue("CompilerToVM::Data::oopDesc_klass_offset_in_bytes", Integer.class, "int");
7373

7474
final int subklassOffset = getFieldOffset("Klass::_subklass", Integer.class, "Klass*");
7575
final int superOffset = getFieldOffset("Klass::_super", Integer.class, "Klass*");

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ HotSpotResolvedObjectTypeImpl getType(HotSpotObjectConstantImpl object) {
191191
String name = theClass.getName().replace('.', '/');
192192
return (HotSpotResolvedObjectTypeImpl) runtime().compilerToVm.lookupType(theClass.getClassLoader(), name);
193193
}
194-
return runtime().compilerToVm.getResolvedJavaType(object, runtime().getConfig().hubOffset, false);
194+
// HotSpot tests if the offset is oopDesc::klass_offset_in_bytes() and returns
195+
// the object type accordingly. When UseCompactClassPointers is enabled,
196+
// oopDesc::klass_offset_in_bytes() will return an offset halfway into the
197+
// object's markWord as a placeholder referring to the klass pointer.
198+
return runtime().compilerToVm.getResolvedJavaType(object, runtime().getConfig().klassOffsetInBytes, false);
195199
}
196200

197201
@Override

0 commit comments

Comments
 (0)