< prev index next >

src/share/vm/runtime/vmStructs.cpp

Print this page
rev 12377 : 8171090: Convert VMStruct_test to GTest
Reviewed-by: duke

@@ -3019,10 +3019,14 @@
                     GENERATE_C2_UNCHECKED_STATIC_VM_STRUCT_ENTRY)
 
   GENERATE_VM_STRUCT_LAST_ENTRY()
 };
 
+size_t VMStructs::localHotSpotVMStructsLength() {
+  return sizeof(localHotSpotVMStructs) / sizeof(VMStructEntry);
+}
+
 VMTypeEntry VMStructs::localHotSpotVMTypes[] = {
 
   VM_TYPES(GENERATE_VM_TYPE_ENTRY,
            GENERATE_TOPLEVEL_VM_TYPE_ENTRY,
            GENERATE_OOP_VM_TYPE_ENTRY,

@@ -3081,10 +3085,14 @@
                   GENERATE_C2_TOPLEVEL_VM_TYPE_ENTRY)
 
   GENERATE_VM_TYPE_LAST_ENTRY()
 };
 
+size_t VMStructs::localHotSpotVMTypesLength() {
+  return sizeof(localHotSpotVMTypes) / sizeof(VMTypeEntry);
+}
+
 VMIntConstantEntry VMStructs::localHotSpotVMIntConstants[] = {
 
   VM_INT_CONSTANTS(GENERATE_VM_INT_CONSTANT_ENTRY,
                    GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY,
                    GENERATE_C1_VM_INT_CONSTANT_ENTRY,

@@ -3123,10 +3131,14 @@
                           GENERATE_C2_PREPROCESSOR_VM_INT_CONSTANT_ENTRY)
 
   GENERATE_VM_INT_CONSTANT_LAST_ENTRY()
 };
 
+size_t VMStructs::localHotSpotVMIntConstantsLength() {
+  return sizeof(localHotSpotVMIntConstants) / sizeof(VMIntConstantEntry);
+}
+
 VMLongConstantEntry VMStructs::localHotSpotVMLongConstants[] = {
 
   VM_LONG_CONSTANTS(GENERATE_VM_LONG_CONSTANT_ENTRY,
                     GENERATE_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY,
                     GENERATE_C1_VM_LONG_CONSTANT_ENTRY,

@@ -3152,10 +3164,14 @@
                            GENERATE_C2_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY)
 
   GENERATE_VM_LONG_CONSTANT_LAST_ENTRY()
 };
 
+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() {
   VM_STRUCTS(CHECK_NONSTATIC_VM_STRUCT_ENTRY,

@@ -3443,47 +3459,5 @@
 #endif
 
 void vmStructs_init() {
   debug_only(VMStructs::init());
 }
-
-#ifndef PRODUCT
-void VMStructs::test() {
-  // Make sure last entry in the each array is indeed the correct end marker.
-  // The reason why these are static is to make sure they are zero initialized.
-  // Putting them on the stack will leave some garbage in the padding of some fields.
-  static VMStructEntry struct_last_entry = GENERATE_VM_STRUCT_LAST_ENTRY();
-  assert(memcmp(&localHotSpotVMStructs[(sizeof(localHotSpotVMStructs) / sizeof(VMStructEntry)) - 1],
-                &struct_last_entry,
-                sizeof(VMStructEntry)) == 0, "Incorrect last entry in localHotSpotVMStructs");
-
-  static VMTypeEntry type_last_entry = GENERATE_VM_TYPE_LAST_ENTRY();
-  assert(memcmp(&localHotSpotVMTypes[sizeof(localHotSpotVMTypes) / sizeof(VMTypeEntry) - 1],
-                &type_last_entry,
-                sizeof(VMTypeEntry)) == 0, "Incorrect last entry in localHotSpotVMTypes");
-
-  static VMIntConstantEntry int_last_entry = GENERATE_VM_INT_CONSTANT_LAST_ENTRY();
-  assert(memcmp(&localHotSpotVMIntConstants[sizeof(localHotSpotVMIntConstants) / sizeof(VMIntConstantEntry) - 1],
-                &int_last_entry,
-                sizeof(VMIntConstantEntry)) == 0, "Incorrect last entry in localHotSpotVMIntConstants");
-
-  static VMLongConstantEntry long_last_entry = GENERATE_VM_LONG_CONSTANT_LAST_ENTRY();
-  assert(memcmp(&localHotSpotVMLongConstants[sizeof(localHotSpotVMLongConstants) / sizeof(VMLongConstantEntry) - 1],
-                &long_last_entry,
-                sizeof(VMLongConstantEntry)) == 0, "Incorrect last entry in localHotSpotVMLongConstants");
-
-
-  // Check for duplicate entries in type array
-  for (int i = 0; localHotSpotVMTypes[i].typeName != NULL; i++) {
-    for (int j = i + 1; localHotSpotVMTypes[j].typeName != NULL; j++) {
-      if (strcmp(localHotSpotVMTypes[i].typeName, localHotSpotVMTypes[j].typeName) == 0) {
-        tty->print_cr("Duplicate entries for '%s'", localHotSpotVMTypes[i].typeName);
-        assert(false, "Duplicate types in localHotSpotVMTypes array");
-      }
-    }
-  }
-}
-
-void VMStructs_test() {
-  VMStructs::test();
-}
-#endif
< prev index next >