From d01f67193f159b7882abadf14c4791b22a9c0e6a Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Tue, 24 Mar 2020 09:34:39 -0700 Subject: [PATCH] 8237497: vmStructs_jvmci.cpp does not check that the correct field type is specified Add missed checks for declarations in vmStructs_jvmci.cpp Reviewed-by: iklam, thartmann --- src/hotspot/share/jvmci/jvmci.cpp | 3 + src/hotspot/share/jvmci/vmStructs_jvmci.cpp | 103 +++++------ src/hotspot/share/jvmci/vmStructs_jvmci.hpp | 4 + src/hotspot/share/runtime/init.cpp | 2 +- src/hotspot/share/runtime/vmStructs.cpp | 167 ++++++++---------- src/hotspot/share/runtime/vmStructs.hpp | 24 +-- .../hotspot/GraalHotSpotVMConfig.java | 4 +- 7 files changed, 139 insertions(+), 168 deletions(-) diff --git a/src/hotspot/share/jvmci/jvmci.cpp b/src/hotspot/share/jvmci/jvmci.cpp index 7293bfd7f97..6129836f494 100644 --- a/src/hotspot/share/jvmci/jvmci.cpp +++ b/src/hotspot/share/jvmci/jvmci.cpp @@ -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 @@ -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. diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp index 54eff4ba2e3..3ecff34970c 100644 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp +++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp @@ -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) \ @@ -194,11 +194,11 @@ nonstatic_field(Klass, _secondary_supers, Array*) \ 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) \ @@ -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*) \ @@ -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 @@ -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 @@ -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, @@ -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() }; @@ -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, @@ -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, @@ -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 + diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.hpp b/src/hotspot/share/jvmci/vmStructs_jvmci.hpp index d53beddebc5..c244632d777 100644 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.hpp +++ b/src/hotspot/share/jvmci/vmStructs_jvmci.hpp @@ -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 diff --git a/src/hotspot/share/runtime/init.cpp b/src/hotspot/share/runtime/init.cpp index 9aa101fac44..69964db5746 100644 --- a/src/hotspot/share/runtime/init.cpp +++ b/src/hotspot/share/runtime/init.cpp @@ -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(); diff --git a/src/hotspot/share/runtime/vmStructs.cpp b/src/hotspot/share/runtime/vmStructs.cpp index ab8c5460333..04767d1250a 100644 --- a/src/hotspot/share/runtime/vmStructs.cpp +++ b/src/hotspot/share/runtime/vmStructs.cpp @@ -106,11 +106,6 @@ #include OS_HEADER(vmStructs) #include OS_CPU_HEADER(vmStructs) -#if INCLUDE_JVMCI -# include "jvmci/vmStructs_jvmci.hpp" -#endif - - #ifdef COMPILER2 #include "opto/addnode.hpp" #include "opto/block.hpp" @@ -2682,16 +2677,10 @@ typedef HashtableEntry KlassHashtableEntry; # define GENERATE_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY(a, b, c) GENERATE_NONSTATIC_VM_STRUCT_ENTRY(a, b, c) # define CHECK_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY(a, b, c) CHECK_NONSTATIC_VM_STRUCT_ENTRY(a, b, c) # define ENSURE_NONPRODUCT_FIELD_TYPE_PRESENT(a, b, c) ENSURE_FIELD_TYPE_PRESENT(a, b, c) -# define GENERATE_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY(a, b, c) GENERATE_NONSTATIC_VM_STRUCT_ENTRY(a, b, c) -# define CHECK_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY(a, b, c) CHECK_NONSTATIC_VM_STRUCT_ENTRY(a, b, c) -# define ENSURE_NONPRODUCT_FIELD_TYPE_PRESENT(a, b, c) ENSURE_FIELD_TYPE_PRESENT(a, b, c) #else # define GENERATE_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY(a, b, c) # define CHECK_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY(a, b, c) # define ENSURE_NONPRODUCT_FIELD_TYPE_PRESENT(a, b, c) -# define GENERATE_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY(a, b, c) -# define CHECK_NONPRODUCT_NONSTATIC_VM_STRUCT_ENTRY(a, b, c) -# define ENSURE_NONPRODUCT_FIELD_TYPE_PRESENT(a, b, c) #endif /* PRODUCT */ // Generate and check a nonstatic field in C1 builds @@ -2963,10 +2952,43 @@ size_t VMStructs::localHotSpotVMLongConstantsLength() { return sizeof(localHotSpotVMLongConstants) / sizeof(VMLongConstantEntry); } -// This is used both to check the types of referenced fields and, in -// debug builds, to ensure that all of the field types are present. -void -VMStructs::init() { +extern "C" { + +#define STRIDE(array) ((char*)&array[1] - (char*)&array[0]) + +JNIEXPORT VMStructEntry* gHotSpotVMStructs = VMStructs::localHotSpotVMStructs; +JNIEXPORT uint64_t gHotSpotVMStructEntryTypeNameOffset = offset_of(VMStructEntry, typeName); +JNIEXPORT uint64_t gHotSpotVMStructEntryFieldNameOffset = offset_of(VMStructEntry, fieldName); +JNIEXPORT uint64_t gHotSpotVMStructEntryTypeStringOffset = offset_of(VMStructEntry, typeString); +JNIEXPORT uint64_t gHotSpotVMStructEntryIsStaticOffset = offset_of(VMStructEntry, isStatic); +JNIEXPORT uint64_t gHotSpotVMStructEntryOffsetOffset = offset_of(VMStructEntry, offset); +JNIEXPORT uint64_t gHotSpotVMStructEntryAddressOffset = offset_of(VMStructEntry, address); +JNIEXPORT uint64_t gHotSpotVMStructEntryArrayStride = STRIDE(gHotSpotVMStructs); + +JNIEXPORT VMTypeEntry* gHotSpotVMTypes = VMStructs::localHotSpotVMTypes; +JNIEXPORT uint64_t gHotSpotVMTypeEntryTypeNameOffset = offset_of(VMTypeEntry, typeName); +JNIEXPORT uint64_t gHotSpotVMTypeEntrySuperclassNameOffset = offset_of(VMTypeEntry, superclassName); +JNIEXPORT uint64_t gHotSpotVMTypeEntryIsOopTypeOffset = offset_of(VMTypeEntry, isOopType); +JNIEXPORT uint64_t gHotSpotVMTypeEntryIsIntegerTypeOffset = offset_of(VMTypeEntry, isIntegerType); +JNIEXPORT uint64_t gHotSpotVMTypeEntryIsUnsignedOffset = offset_of(VMTypeEntry, isUnsigned); +JNIEXPORT uint64_t gHotSpotVMTypeEntrySizeOffset = offset_of(VMTypeEntry, size); +JNIEXPORT uint64_t gHotSpotVMTypeEntryArrayStride = STRIDE(gHotSpotVMTypes); + +JNIEXPORT VMIntConstantEntry* gHotSpotVMIntConstants = VMStructs::localHotSpotVMIntConstants; +JNIEXPORT uint64_t gHotSpotVMIntConstantEntryNameOffset = offset_of(VMIntConstantEntry, name); +JNIEXPORT uint64_t gHotSpotVMIntConstantEntryValueOffset = offset_of(VMIntConstantEntry, value); +JNIEXPORT uint64_t gHotSpotVMIntConstantEntryArrayStride = STRIDE(gHotSpotVMIntConstants); + +JNIEXPORT VMLongConstantEntry* gHotSpotVMLongConstants = VMStructs::localHotSpotVMLongConstants; +JNIEXPORT uint64_t gHotSpotVMLongConstantEntryNameOffset = offset_of(VMLongConstantEntry, name); +JNIEXPORT uint64_t gHotSpotVMLongConstantEntryValueOffset = offset_of(VMLongConstantEntry, value); +JNIEXPORT uint64_t gHotSpotVMLongConstantEntryArrayStride = STRIDE(gHotSpotVMLongConstants); +} // "C" + +#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 VMStructs::init() { VM_STRUCTS(CHECK_NONSTATIC_VM_STRUCT_ENTRY, CHECK_STATIC_VM_STRUCT_ENTRY, CHECK_STATIC_PTR_VOLATILE_VM_STRUCT_ENTRY, @@ -3042,80 +3064,47 @@ VMStructs::init() { // Solstice NFS setup. If everyone switches to local workspaces on // Win32, we can put this back in. #ifndef _WINDOWS - debug_only(VM_STRUCTS(ENSURE_FIELD_TYPE_PRESENT, - CHECK_NO_OP, - CHECK_NO_OP, - CHECK_NO_OP, - CHECK_NO_OP, - CHECK_NO_OP, - CHECK_NO_OP, - CHECK_NO_OP, - CHECK_NO_OP, - CHECK_NO_OP)); - debug_only(VM_STRUCTS(CHECK_NO_OP, - ENSURE_FIELD_TYPE_PRESENT, - ENSURE_FIELD_TYPE_PRESENT, - CHECK_NO_OP, - ENSURE_FIELD_TYPE_PRESENT, - ENSURE_NONPRODUCT_FIELD_TYPE_PRESENT, - ENSURE_C1_FIELD_TYPE_PRESENT, - ENSURE_C2_FIELD_TYPE_PRESENT, - CHECK_NO_OP, - CHECK_NO_OP)); - - debug_only(VM_STRUCTS_CPU(ENSURE_FIELD_TYPE_PRESENT, - ENSURE_FIELD_TYPE_PRESENT, - CHECK_NO_OP, - ENSURE_FIELD_TYPE_PRESENT, - ENSURE_NONPRODUCT_FIELD_TYPE_PRESENT, - ENSURE_C2_FIELD_TYPE_PRESENT, - CHECK_NO_OP, - CHECK_NO_OP)); - debug_only(VM_STRUCTS_OS_CPU(ENSURE_FIELD_TYPE_PRESENT, - ENSURE_FIELD_TYPE_PRESENT, - CHECK_NO_OP, - ENSURE_FIELD_TYPE_PRESENT, - ENSURE_NONPRODUCT_FIELD_TYPE_PRESENT, - ENSURE_C2_FIELD_TYPE_PRESENT, - CHECK_NO_OP, - CHECK_NO_OP)); -#endif -} - -extern "C" { - -#define STRIDE(array) ((char*)&array[1] - (char*)&array[0]) - -JNIEXPORT VMStructEntry* gHotSpotVMStructs = VMStructs::localHotSpotVMStructs; -JNIEXPORT uint64_t gHotSpotVMStructEntryTypeNameOffset = offset_of(VMStructEntry, typeName); -JNIEXPORT uint64_t gHotSpotVMStructEntryFieldNameOffset = offset_of(VMStructEntry, fieldName); -JNIEXPORT uint64_t gHotSpotVMStructEntryTypeStringOffset = offset_of(VMStructEntry, typeString); -JNIEXPORT uint64_t gHotSpotVMStructEntryIsStaticOffset = offset_of(VMStructEntry, isStatic); -JNIEXPORT uint64_t gHotSpotVMStructEntryOffsetOffset = offset_of(VMStructEntry, offset); -JNIEXPORT uint64_t gHotSpotVMStructEntryAddressOffset = offset_of(VMStructEntry, address); -JNIEXPORT uint64_t gHotSpotVMStructEntryArrayStride = STRIDE(gHotSpotVMStructs); - -JNIEXPORT VMTypeEntry* gHotSpotVMTypes = VMStructs::localHotSpotVMTypes; -JNIEXPORT uint64_t gHotSpotVMTypeEntryTypeNameOffset = offset_of(VMTypeEntry, typeName); -JNIEXPORT uint64_t gHotSpotVMTypeEntrySuperclassNameOffset = offset_of(VMTypeEntry, superclassName); -JNIEXPORT uint64_t gHotSpotVMTypeEntryIsOopTypeOffset = offset_of(VMTypeEntry, isOopType); -JNIEXPORT uint64_t gHotSpotVMTypeEntryIsIntegerTypeOffset = offset_of(VMTypeEntry, isIntegerType); -JNIEXPORT uint64_t gHotSpotVMTypeEntryIsUnsignedOffset = offset_of(VMTypeEntry, isUnsigned); -JNIEXPORT uint64_t gHotSpotVMTypeEntrySizeOffset = offset_of(VMTypeEntry, size); -JNIEXPORT uint64_t gHotSpotVMTypeEntryArrayStride = STRIDE(gHotSpotVMTypes); + VM_STRUCTS(ENSURE_FIELD_TYPE_PRESENT, + CHECK_NO_OP, + CHECK_NO_OP, + CHECK_NO_OP, + CHECK_NO_OP, + CHECK_NO_OP, + CHECK_NO_OP, + CHECK_NO_OP, + CHECK_NO_OP, + CHECK_NO_OP); -JNIEXPORT VMIntConstantEntry* gHotSpotVMIntConstants = VMStructs::localHotSpotVMIntConstants; -JNIEXPORT uint64_t gHotSpotVMIntConstantEntryNameOffset = offset_of(VMIntConstantEntry, name); -JNIEXPORT uint64_t gHotSpotVMIntConstantEntryValueOffset = offset_of(VMIntConstantEntry, value); -JNIEXPORT uint64_t gHotSpotVMIntConstantEntryArrayStride = STRIDE(gHotSpotVMIntConstants); + VM_STRUCTS(CHECK_NO_OP, + ENSURE_FIELD_TYPE_PRESENT, + ENSURE_FIELD_TYPE_PRESENT, + CHECK_NO_OP, + ENSURE_FIELD_TYPE_PRESENT, + ENSURE_NONPRODUCT_FIELD_TYPE_PRESENT, + ENSURE_C1_FIELD_TYPE_PRESENT, + ENSURE_C2_FIELD_TYPE_PRESENT, + CHECK_NO_OP, + CHECK_NO_OP); -JNIEXPORT VMLongConstantEntry* gHotSpotVMLongConstants = VMStructs::localHotSpotVMLongConstants; -JNIEXPORT uint64_t gHotSpotVMLongConstantEntryNameOffset = offset_of(VMLongConstantEntry, name); -JNIEXPORT uint64_t gHotSpotVMLongConstantEntryValueOffset = offset_of(VMLongConstantEntry, value); -JNIEXPORT uint64_t gHotSpotVMLongConstantEntryArrayStride = STRIDE(gHotSpotVMLongConstants); + VM_STRUCTS_CPU(ENSURE_FIELD_TYPE_PRESENT, + ENSURE_FIELD_TYPE_PRESENT, + CHECK_NO_OP, + ENSURE_FIELD_TYPE_PRESENT, + ENSURE_NONPRODUCT_FIELD_TYPE_PRESENT, + ENSURE_C2_FIELD_TYPE_PRESENT, + CHECK_NO_OP, + CHECK_NO_OP); + VM_STRUCTS_OS_CPU(ENSURE_FIELD_TYPE_PRESENT, + ENSURE_FIELD_TYPE_PRESENT, + CHECK_NO_OP, + ENSURE_FIELD_TYPE_PRESENT, + ENSURE_NONPRODUCT_FIELD_TYPE_PRESENT, + ENSURE_C2_FIELD_TYPE_PRESENT, + CHECK_NO_OP, + CHECK_NO_OP); +#endif // !_WINDOWS } -#ifdef ASSERT static int recursiveFindType(VMTypeEntry* origtypes, const char* typeName, bool isRecurse) { { VMTypeEntry* types = origtypes; @@ -3182,15 +3171,13 @@ static int recursiveFindType(VMTypeEntry* origtypes, const char* typeName, bool return 0; } - -int -VMStructs::findType(const char* typeName) { +int VMStructs::findType(const char* typeName) { VMTypeEntry* types = gHotSpotVMTypes; return recursiveFindType(types, typeName, false); } -#endif void vmStructs_init() { - debug_only(VMStructs::init()); + VMStructs::init(); } +#endif // ASSERT diff --git a/src/hotspot/share/runtime/vmStructs.hpp b/src/hotspot/share/runtime/vmStructs.hpp index 73c33151a01..5e9db68bd70 100644 --- a/src/hotspot/share/runtime/vmStructs.hpp +++ b/src/hotspot/share/runtime/vmStructs.hpp @@ -109,47 +109,43 @@ class VMStructs { // the fact that it has a NULL fieldName static VMStructEntry localHotSpotVMStructs[]; // The function to get localHotSpotVMStructs length - static size_t localHotSpotVMStructsLength(); + static size_t localHotSpotVMStructsLength() NOT_VM_STRUCTS_RETURN_(0); // The last entry is identified over in the serviceability agent by // the fact that it has a NULL typeName static VMTypeEntry localHotSpotVMTypes[]; // The function to get localHotSpotVMTypes length - static size_t localHotSpotVMTypesLength(); + static size_t localHotSpotVMTypesLength() NOT_VM_STRUCTS_RETURN_(0); // Table of integer constants required by the serviceability agent. // The last entry is identified over in the serviceability agent by // the fact that it has a NULL typeName static VMIntConstantEntry localHotSpotVMIntConstants[]; // The function to get localHotSpotVMIntConstants length - static size_t localHotSpotVMIntConstantsLength(); + static size_t localHotSpotVMIntConstantsLength() NOT_VM_STRUCTS_RETURN_(0); // Table of long constants required by the serviceability agent. // The last entry is identified over in the serviceability agent by // the fact that it has a NULL typeName static VMLongConstantEntry localHotSpotVMLongConstants[]; // The function to get localHotSpotVMIntConstants length - static size_t localHotSpotVMLongConstantsLength(); + static size_t localHotSpotVMLongConstantsLength() NOT_VM_STRUCTS_RETURN_(0); /** * Table of addresses. */ static VMAddressEntry localHotSpotVMAddresses[]; +#ifdef ASSERT // This is used to run any checking code necessary for validation of // the data structure (debug build only) - static void init(); - -#ifndef PRODUCT - // Execute unit tests - static void test(); -#endif + static void init() NOT_VM_STRUCTS_RETURN; private: // Look up a type in localHotSpotVMTypes using strcmp() (debug build only). // Returns 1 if found, 0 if not. - // debug_only(static int findType(const char* typeName);) - static int findType(const char* typeName); + static int findType(const char* typeName) NOT_VM_STRUCTS_RETURN_(0); +#endif // ASSERT }; // This utility macro quotes the passed string @@ -188,6 +184,9 @@ class VMStructs { #define GENERATE_VM_STRUCT_LAST_ENTRY() \ { NULL, NULL, NULL, 0, 0, NULL } + +#ifdef ASSERT + // This macro checks the type of a VMStructEntry by comparing pointer types #define CHECK_NONSTATIC_VM_STRUCT_ENTRY(typeName, fieldName, type) \ {typeName *dummyObj = NULL; type* dummy = &dummyObj->fieldName; \ @@ -219,6 +218,7 @@ class VMStructs { // This is a no-op macro for unchecked fields #define CHECK_NO_OP(a, b, c) +#endif // ASSERT //-------------------------------------------------------------------------------- // VMTypeEntry macros diff --git a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfig.java b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfig.java index 3d5223df7cb..a20a8ddd46e 100644 --- a/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfig.java +++ b/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/GraalHotSpotVMConfig.java @@ -522,7 +522,7 @@ private String markWordField(String simpleName) { public final int logOfHRGrainBytes = getFieldValue("HeapRegion::LogOfHRGrainBytes", Integer.class, "int"); - public final long cardtableStartAddress = getFieldValue("CompilerToVM::Data::cardtable_start_address", Long.class, "jbyte*"); + public final long cardtableStartAddress = getFieldValue("CompilerToVM::Data::cardtable_start_address", Long.class, "CardTable::CardValue*"); public final int cardtableShift = getFieldValue("CompilerToVM::Data::cardtable_shift", Integer.class, "int"); /** @@ -550,7 +550,7 @@ private String markWordField(String simpleName) { public final int basicLockSize = getFieldValue("CompilerToVM::Data::sizeof_BasicLock", Integer.class, "int"); public final int basicLockDisplacedHeaderOffset = getFieldOffset("BasicLock::_displaced_header", Integer.class, markWord); - public final int threadPollingPageOffset = getFieldOffset("Thread::_polling_page", Integer.class, "address", -1); + public final int threadPollingPageOffset = getFieldOffset("Thread::_polling_page", Integer.class, "volatile void*", -1); public final int threadAllocatedBytesOffset = getFieldOffset("Thread::_allocated_bytes", Integer.class, "jlong"); public final int tlabRefillWasteIncrement = getFlag("TLABWasteIncrement", Integer.class);