hotspot/src/share/vm/runtime/vmStructs.cpp
changeset 46419 472de094cd15
parent 44897 1d9f4d0c9927
parent 46343 3c2650b86bf7
child 46427 54713555867e
equal deleted inserted replaced
44898:b80c30ca5fcd 46419:472de094cd15
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   192 typedef HashtableEntry<intptr_t, mtInternal>  IntptrHashtableEntry;
   192 typedef HashtableEntry<intptr_t, mtInternal>  IntptrHashtableEntry;
   193 typedef Hashtable<intptr_t, mtInternal>       IntptrHashtable;
   193 typedef Hashtable<intptr_t, mtInternal>       IntptrHashtable;
   194 typedef Hashtable<Symbol*, mtSymbol>          SymbolHashtable;
   194 typedef Hashtable<Symbol*, mtSymbol>          SymbolHashtable;
   195 typedef HashtableEntry<Symbol*, mtClass>      SymbolHashtableEntry;
   195 typedef HashtableEntry<Symbol*, mtClass>      SymbolHashtableEntry;
   196 typedef Hashtable<oop, mtSymbol>              StringHashtable;
   196 typedef Hashtable<oop, mtSymbol>              StringHashtable;
   197 typedef TwoOopHashtable<Klass*, mtClass>      KlassTwoOopHashtable;
   197 typedef TwoOopHashtable<InstanceKlass*, mtClass> KlassTwoOopHashtable;
   198 typedef Hashtable<Klass*, mtClass>            KlassHashtable;
   198 typedef Hashtable<InstanceKlass*, mtClass>       KlassHashtable;
   199 typedef HashtableEntry<Klass*, mtClass>       KlassHashtableEntry;
   199 typedef HashtableEntry<InstanceKlass*, mtClass>  KlassHashtableEntry;
   200 typedef TwoOopHashtable<Symbol*, mtClass>     SymbolTwoOopHashtable;
   200 typedef TwoOopHashtable<Symbol*, mtClass>     SymbolTwoOopHashtable;
   201 typedef CompactHashtable<Symbol*, char>       SymbolCompactHashTable;
   201 typedef CompactHashtable<Symbol*, char>       SymbolCompactHashTable;
   202 typedef RehashableHashtable<Symbol*, mtSymbol>   RehashableSymbolHashtable;
   202 typedef RehashableHashtable<Symbol*, mtSymbol>   RehashableSymbolHashtable;
   203 
   203 
   204 //--------------------------------------------------------------------------------
   204 //--------------------------------------------------------------------------------
  3044                     GENERATE_C2_UNCHECKED_STATIC_VM_STRUCT_ENTRY)
  3044                     GENERATE_C2_UNCHECKED_STATIC_VM_STRUCT_ENTRY)
  3045 
  3045 
  3046   GENERATE_VM_STRUCT_LAST_ENTRY()
  3046   GENERATE_VM_STRUCT_LAST_ENTRY()
  3047 };
  3047 };
  3048 
  3048 
       
  3049 size_t VMStructs::localHotSpotVMStructsLength() {
       
  3050   return sizeof(localHotSpotVMStructs) / sizeof(VMStructEntry);
       
  3051 }
       
  3052 
  3049 VMTypeEntry VMStructs::localHotSpotVMTypes[] = {
  3053 VMTypeEntry VMStructs::localHotSpotVMTypes[] = {
  3050 
  3054 
  3051   VM_TYPES(GENERATE_VM_TYPE_ENTRY,
  3055   VM_TYPES(GENERATE_VM_TYPE_ENTRY,
  3052            GENERATE_TOPLEVEL_VM_TYPE_ENTRY,
  3056            GENERATE_TOPLEVEL_VM_TYPE_ENTRY,
  3053            GENERATE_OOP_VM_TYPE_ENTRY,
  3057            GENERATE_OOP_VM_TYPE_ENTRY,
  3106                   GENERATE_C2_TOPLEVEL_VM_TYPE_ENTRY)
  3110                   GENERATE_C2_TOPLEVEL_VM_TYPE_ENTRY)
  3107 
  3111 
  3108   GENERATE_VM_TYPE_LAST_ENTRY()
  3112   GENERATE_VM_TYPE_LAST_ENTRY()
  3109 };
  3113 };
  3110 
  3114 
       
  3115 size_t VMStructs::localHotSpotVMTypesLength() {
       
  3116   return sizeof(localHotSpotVMTypes) / sizeof(VMTypeEntry);
       
  3117 }
       
  3118 
  3111 VMIntConstantEntry VMStructs::localHotSpotVMIntConstants[] = {
  3119 VMIntConstantEntry VMStructs::localHotSpotVMIntConstants[] = {
  3112 
  3120 
  3113   VM_INT_CONSTANTS(GENERATE_VM_INT_CONSTANT_ENTRY,
  3121   VM_INT_CONSTANTS(GENERATE_VM_INT_CONSTANT_ENTRY,
  3114                    GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY,
  3122                    GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY,
  3115                    GENERATE_C1_VM_INT_CONSTANT_ENTRY,
  3123                    GENERATE_C1_VM_INT_CONSTANT_ENTRY,
  3148                           GENERATE_C2_PREPROCESSOR_VM_INT_CONSTANT_ENTRY)
  3156                           GENERATE_C2_PREPROCESSOR_VM_INT_CONSTANT_ENTRY)
  3149 
  3157 
  3150   GENERATE_VM_INT_CONSTANT_LAST_ENTRY()
  3158   GENERATE_VM_INT_CONSTANT_LAST_ENTRY()
  3151 };
  3159 };
  3152 
  3160 
       
  3161 size_t VMStructs::localHotSpotVMIntConstantsLength() {
       
  3162   return sizeof(localHotSpotVMIntConstants) / sizeof(VMIntConstantEntry);
       
  3163 }
       
  3164 
  3153 VMLongConstantEntry VMStructs::localHotSpotVMLongConstants[] = {
  3165 VMLongConstantEntry VMStructs::localHotSpotVMLongConstants[] = {
  3154 
  3166 
  3155   VM_LONG_CONSTANTS(GENERATE_VM_LONG_CONSTANT_ENTRY,
  3167   VM_LONG_CONSTANTS(GENERATE_VM_LONG_CONSTANT_ENTRY,
  3156                     GENERATE_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY,
  3168                     GENERATE_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY,
  3157                     GENERATE_C1_VM_LONG_CONSTANT_ENTRY,
  3169                     GENERATE_C1_VM_LONG_CONSTANT_ENTRY,
  3176                            GENERATE_C2_VM_LONG_CONSTANT_ENTRY,
  3188                            GENERATE_C2_VM_LONG_CONSTANT_ENTRY,
  3177                            GENERATE_C2_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY)
  3189                            GENERATE_C2_PREPROCESSOR_VM_LONG_CONSTANT_ENTRY)
  3178 
  3190 
  3179   GENERATE_VM_LONG_CONSTANT_LAST_ENTRY()
  3191   GENERATE_VM_LONG_CONSTANT_LAST_ENTRY()
  3180 };
  3192 };
       
  3193 
       
  3194 size_t VMStructs::localHotSpotVMLongConstantsLength() {
       
  3195   return sizeof(localHotSpotVMLongConstants) / sizeof(VMLongConstantEntry);
       
  3196 }
  3181 
  3197 
  3182 // This is used both to check the types of referenced fields and, in
  3198 // This is used both to check the types of referenced fields and, in
  3183 // debug builds, to ensure that all of the field types are present.
  3199 // debug builds, to ensure that all of the field types are present.
  3184 void
  3200 void
  3185 VMStructs::init() {
  3201 VMStructs::init() {
  3468 #endif
  3484 #endif
  3469 
  3485 
  3470 void vmStructs_init() {
  3486 void vmStructs_init() {
  3471   debug_only(VMStructs::init());
  3487   debug_only(VMStructs::init());
  3472 }
  3488 }
  3473 
       
  3474 #ifndef PRODUCT
       
  3475 void VMStructs::test() {
       
  3476   // Make sure last entry in the each array is indeed the correct end marker.
       
  3477   // The reason why these are static is to make sure they are zero initialized.
       
  3478   // Putting them on the stack will leave some garbage in the padding of some fields.
       
  3479   static VMStructEntry struct_last_entry = GENERATE_VM_STRUCT_LAST_ENTRY();
       
  3480   assert(memcmp(&localHotSpotVMStructs[(sizeof(localHotSpotVMStructs) / sizeof(VMStructEntry)) - 1],
       
  3481                 &struct_last_entry,
       
  3482                 sizeof(VMStructEntry)) == 0, "Incorrect last entry in localHotSpotVMStructs");
       
  3483 
       
  3484   static VMTypeEntry type_last_entry = GENERATE_VM_TYPE_LAST_ENTRY();
       
  3485   assert(memcmp(&localHotSpotVMTypes[sizeof(localHotSpotVMTypes) / sizeof(VMTypeEntry) - 1],
       
  3486                 &type_last_entry,
       
  3487                 sizeof(VMTypeEntry)) == 0, "Incorrect last entry in localHotSpotVMTypes");
       
  3488 
       
  3489   static VMIntConstantEntry int_last_entry = GENERATE_VM_INT_CONSTANT_LAST_ENTRY();
       
  3490   assert(memcmp(&localHotSpotVMIntConstants[sizeof(localHotSpotVMIntConstants) / sizeof(VMIntConstantEntry) - 1],
       
  3491                 &int_last_entry,
       
  3492                 sizeof(VMIntConstantEntry)) == 0, "Incorrect last entry in localHotSpotVMIntConstants");
       
  3493 
       
  3494   static VMLongConstantEntry long_last_entry = GENERATE_VM_LONG_CONSTANT_LAST_ENTRY();
       
  3495   assert(memcmp(&localHotSpotVMLongConstants[sizeof(localHotSpotVMLongConstants) / sizeof(VMLongConstantEntry) - 1],
       
  3496                 &long_last_entry,
       
  3497                 sizeof(VMLongConstantEntry)) == 0, "Incorrect last entry in localHotSpotVMLongConstants");
       
  3498 
       
  3499 
       
  3500   // Check for duplicate entries in type array
       
  3501   for (int i = 0; localHotSpotVMTypes[i].typeName != NULL; i++) {
       
  3502     for (int j = i + 1; localHotSpotVMTypes[j].typeName != NULL; j++) {
       
  3503       if (strcmp(localHotSpotVMTypes[i].typeName, localHotSpotVMTypes[j].typeName) == 0) {
       
  3504         tty->print_cr("Duplicate entries for '%s'", localHotSpotVMTypes[i].typeName);
       
  3505         assert(false, "Duplicate types in localHotSpotVMTypes array");
       
  3506       }
       
  3507     }
       
  3508   }
       
  3509 }
       
  3510 
       
  3511 void VMStructs_test() {
       
  3512   VMStructs::test();
       
  3513 }
       
  3514 #endif