Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
8237497: vmStructs_jvmci.cpp does not check that the correct field ty…
Browse files Browse the repository at this point in the history
…pe is specified

Add missed checks for declarations in vmStructs_jvmci.cpp

Reviewed-by: iklam, thartmann
  • Loading branch information
Vladimir Kozlov committed Mar 24, 2020
1 parent 5110de6 commit d01f671
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 168 deletions.
3 changes: 3 additions & 0 deletions src/hotspot/share/jvmci/jvmci.cpp
Expand Up @@ -36,6 +36,8 @@ MetadataHandleBlock* JVMCI::_metadata_handles = NULL;
JVMCIRuntime* JVMCI::_compiler_runtime = NULL;
JVMCIRuntime* JVMCI::_java_runtime = NULL;

void jvmci_vmStructs_init() NOT_DEBUG_RETURN;

bool JVMCI::can_initialize_JVMCI() {
// Initializing JVMCI requires the module system to be initialized past phase 3.
// The JVMCI API itself isn't available until phase 2 and ServiceLoader (which
Expand All @@ -58,6 +60,7 @@ void JVMCI::initialize_compiler(TRAPS) {
}

void JVMCI::initialize_globals() {
jvmci_vmStructs_init();
_metadata_handles = MetadataHandleBlock::allocate_block();
if (UseJVMCINativeLibrary) {
// There are two runtimes.
Expand Down
103 changes: 40 additions & 63 deletions src/hotspot/share/jvmci/vmStructs_jvmci.cpp
Expand Up @@ -70,7 +70,7 @@
static_field(CompilerToVM::Data, _max_oop_map_stack_offset, int) \
static_field(CompilerToVM::Data, _fields_annotations_base_offset, int) \
\
static_field(CompilerToVM::Data, cardtable_start_address, jbyte*) \
static_field(CompilerToVM::Data, cardtable_start_address, CardTable::CardValue*) \
static_field(CompilerToVM::Data, cardtable_shift, int) \
\
static_field(CompilerToVM::Data, vm_page_size, int) \
Expand Down Expand Up @@ -194,11 +194,11 @@
nonstatic_field(Klass, _secondary_supers, Array<Klass*>*) \
nonstatic_field(Klass, _super, Klass*) \
nonstatic_field(Klass, _super_check_offset, juint) \
nonstatic_field(Klass, _subklass, Klass*) \
volatile_nonstatic_field(Klass, _subklass, Klass*) \
nonstatic_field(Klass, _layout_helper, jint) \
nonstatic_field(Klass, _name, Symbol*) \
nonstatic_field(Klass, _prototype_header, markWord) \
nonstatic_field(Klass, _next_sibling, Klass*) \
volatile_nonstatic_field(Klass, _next_sibling, Klass*) \
nonstatic_field(Klass, _java_mirror, OopHandle) \
nonstatic_field(Klass, _modifier_flags, jint) \
nonstatic_field(Klass, _access_flags, AccessFlags) \
Expand Down Expand Up @@ -331,7 +331,7 @@
\
nonstatic_field(Thread, _tlab, ThreadLocalAllocBuffer) \
nonstatic_field(Thread, _allocated_bytes, jlong) \
nonstatic_field(Thread, _polling_page, address) \
nonstatic_field(Thread, _polling_page, volatile void*) \
\
nonstatic_field(ThreadLocalAllocBuffer, _start, HeapWord*) \
nonstatic_field(ThreadLocalAllocBuffer, _top, HeapWord*) \
Expand Down Expand Up @@ -842,10 +842,6 @@
#define VM_STRUCTS_CPU(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field)
#endif

#ifndef VM_TYPES_CPU
#define VM_TYPES_CPU(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type)
#endif

#ifndef VM_INT_CONSTANTS_CPU
#define VM_INT_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
#endif
Expand All @@ -854,22 +850,6 @@
#define VM_LONG_CONSTANTS_CPU(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
#endif

#ifndef VM_STRUCTS_OS
#define VM_STRUCTS_OS(nonstatic_field, static_field, unchecked_nonstatic_field, volatile_nonstatic_field, nonproduct_nonstatic_field, c2_nonstatic_field, unchecked_c1_static_field, unchecked_c2_static_field)
#endif

#ifndef VM_TYPES_OS
#define VM_TYPES_OS(declare_type, declare_toplevel_type, declare_oop_type, declare_integer_type, declare_unsigned_integer_type, declare_c1_toplevel_type, declare_c2_type, declare_c2_toplevel_type)
#endif

#ifndef VM_INT_CONSTANTS_OS
#define VM_INT_CONSTANTS_OS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
#endif

#ifndef VM_LONG_CONSTANTS_OS
#define VM_LONG_CONSTANTS_OS(declare_constant, declare_preprocessor_constant, declare_c1_constant, declare_c2_constant, declare_c2_preprocessor_constant)
#endif

#ifndef VM_ADDRESSES_OS
#define VM_ADDRESSES_OS(declare_address, declare_preprocessor_address, declare_function)
#endif
Expand All @@ -887,15 +867,6 @@ VMStructEntry JVMCIVMStructs::localHotSpotVMStructs[] = {
GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_NONSTATIC_VM_STRUCT_ENTRY)

VM_STRUCTS_OS(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_STATIC_VM_STRUCT_ENTRY,
GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_C2_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_C1_UNCHECKED_STATIC_VM_STRUCT_ENTRY,
GENERATE_C2_UNCHECKED_STATIC_VM_STRUCT_ENTRY)

VM_STRUCTS_CPU(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_STATIC_VM_STRUCT_ENTRY,
GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY,
Expand All @@ -919,24 +890,6 @@ VMTypeEntry JVMCIVMStructs::localHotSpotVMTypes[] = {
GENERATE_INTEGER_VM_TYPE_ENTRY,
GENERATE_UNSIGNED_INTEGER_VM_TYPE_ENTRY)

VM_TYPES_OS(GENERATE_VM_TYPE_ENTRY,
GENERATE_TOPLEVEL_VM_TYPE_ENTRY,
GENERATE_OOP_VM_TYPE_ENTRY,
GENERATE_INTEGER_VM_TYPE_ENTRY,
GENERATE_UNSIGNED_INTEGER_VM_TYPE_ENTRY,
GENERATE_C1_TOPLEVEL_VM_TYPE_ENTRY,
GENERATE_C2_VM_TYPE_ENTRY,
GENERATE_C2_TOPLEVEL_VM_TYPE_ENTRY)

VM_TYPES_CPU(GENERATE_VM_TYPE_ENTRY,
GENERATE_TOPLEVEL_VM_TYPE_ENTRY,
GENERATE_OOP_VM_TYPE_ENTRY,
GENERATE_INTEGER_VM_TYPE_ENTRY,
GENERATE_UNSIGNED_INTEGER_VM_TYPE_ENTRY,
GENERATE_C1_TOPLEVEL_VM_TYPE_ENTRY,
GENERATE_C2_VM_TYPE_ENTRY,
GENERATE_C2_TOPLEVEL_VM_TYPE_ENTRY)

GENERATE_VM_TYPE_LAST_ENTRY()
};

Expand All @@ -945,12 +898,6 @@ VMIntConstantEntry JVMCIVMStructs::localHotSpotVMIntConstants[] = {
GENERATE_VM_INT_CONSTANT_WITH_VALUE_ENTRY,
GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY)

VM_INT_CONSTANTS_OS(GENERATE_VM_INT_CONSTANT_ENTRY,
GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY,
GENERATE_C1_VM_INT_CONSTANT_ENTRY,
GENERATE_C2_VM_INT_CONSTANT_ENTRY,
GENERATE_C2_PREPROCESSOR_VM_INT_CONSTANT_ENTRY)

VM_INT_CONSTANTS_CPU(GENERATE_VM_INT_CONSTANT_ENTRY,
GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY,
GENERATE_C1_VM_INT_CONSTANT_ENTRY,
Expand All @@ -970,12 +917,6 @@ VMLongConstantEntry JVMCIVMStructs::localHotSpotVMLongConstants[] = {
VM_LONG_CONSTANTS(GENERATE_VM_LONG_CONSTANT_ENTRY,
GENERATE_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY)

VM_LONG_CONSTANTS_OS(GENERATE_VM_LONG_CONSTANT_ENTRY,
GENERATE_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY,
GENERATE_C1_VM_LONG_CONSTANT_ENTRY,
GENERATE_C2_VM_LONG_CONSTANT_ENTRY,
GENERATE_C2_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY)

VM_LONG_CONSTANTS_CPU(GENERATE_VM_LONG_CONSTANT_ENTRY,
GENERATE_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY,
GENERATE_C1_VM_LONG_CONSTANT_ENTRY,
Expand Down Expand Up @@ -1027,3 +968,39 @@ JNIEXPORT VMIntConstantEntry* jvmciHotSpotVMIntConstants = JVMCIVMStructs::local
JNIEXPORT VMLongConstantEntry* jvmciHotSpotVMLongConstants = JVMCIVMStructs::localHotSpotVMLongConstants;
JNIEXPORT VMAddressEntry* jvmciHotSpotVMAddresses = JVMCIVMStructs::localHotSpotVMAddresses;
}

#ifdef ASSERT
// This is used both to check the types of referenced fields and
// to ensure that all of the field types are present.
void JVMCIVMStructs::init() {
VM_STRUCTS(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
CHECK_STATIC_VM_STRUCT_ENTRY,
CHECK_NO_OP,
CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY);


VM_STRUCTS_CPU(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
CHECK_STATIC_VM_STRUCT_ENTRY,
CHECK_NO_OP,
CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
CHECK_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY,
CHECK_C2_NONSTATIC_VM_STRUCT_ENTRY,
CHECK_NO_OP,
CHECK_NO_OP);

#if INCLUDE_G1GC
VM_STRUCTS_JVMCI_G1GC(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
CHECK_STATIC_VM_STRUCT_ENTRY)
#endif

VM_TYPES(CHECK_VM_TYPE_ENTRY,
CHECK_SINGLE_ARG_VM_TYPE_NO_OP,
CHECK_SINGLE_ARG_VM_TYPE_NO_OP,
CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
}

void jvmci_vmStructs_init() {
JVMCIVMStructs::init();
}
#endif // ASSERT

4 changes: 4 additions & 0 deletions src/hotspot/share/jvmci/vmStructs_jvmci.hpp
Expand Up @@ -61,6 +61,10 @@ class JVMCIVMStructs {
static int localHotSpotVMIntConstants_count();
static int localHotSpotVMLongConstants_count();
static int localHotSpotVMAddresses_count();

// This is used to run any checking code necessary for validation of
// the data structure (debug build only)
static void init() NOT_DEBUG_RETURN;
};

#endif // SHARE_JVMCI_VMSTRUCTS_JVMCI_HPP
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/init.cpp
Expand Up @@ -73,7 +73,7 @@ void InterfaceSupport_init();
void universe2_init(); // dependent on codeCache_init and stubRoutines_init, loads primordial classes
void referenceProcessor_init();
void jni_handles_init();
void vmStructs_init();
void vmStructs_init() NOT_DEBUG_RETURN;

void vtableStubs_init();
void InlineCacheBuffer_init();
Expand Down

0 comments on commit d01f671

Please sign in to comment.