< prev index next >

src/hotspot/share/prims/cdsoffsets.cpp

Print this page




  32 #include "memory/allocation.inline.hpp"
  33 #include "prims/cdsoffsets.hpp"
  34 
  35 CDSOffsets::CDSOffsets(const char* name, int offset, CDSOffsets* next) {
  36   _name = NEW_C_HEAP_ARRAY(char, strlen(name) + 1, mtInternal);
  37   strcpy(_name, name);
  38   _offset = offset;
  39   _next = next;
  40 }
  41 
  42 CDSOffsets* CDSOffsets::_all = NULL;
  43 #define ADD_NEXT(list, name, value) \
  44   list->add_end(new CDSOffsets(name, value, NULL))
  45 
  46 #define CREATE_OFFSET_MAPS                                                                  \
  47     _all = new CDSOffsets("size_t_size", sizeof(size_t), NULL);                             \
  48     ADD_NEXT(_all, "int_size", sizeof(int));                                                \
  49     ADD_NEXT(_all, "FileMapHeader::_magic", offset_of(FileMapHeader, _magic));              \
  50     ADD_NEXT(_all, "FileMapHeader::_crc", offset_of(FileMapHeader, _crc));                  \
  51     ADD_NEXT(_all, "FileMapHeader::_version", offset_of(FileMapHeader, _version));          \


  52     ADD_NEXT(_all, "FileMapHeader::_space[0]", offset_of(FileMapHeader, _space));           \
  53     ADD_NEXT(_all, "CDSFileMapRegion::_crc", offset_of(CDSFileMapRegion, _crc));            \
  54     ADD_NEXT(_all, "CDSFileMapRegion::_used", offset_of(CDSFileMapRegion, _used));          \
  55     ADD_NEXT(_all, "FileMapHeader::_paths_misc_info_size", offset_of(FileMapHeader, _paths_misc_info_size)); \
  56     ADD_NEXT(_all, "file_header_size", sizeof(FileMapHeader));                              \
  57     ADD_NEXT(_all, "DynamicArchiveHeader::_base_archive_crc", offset_of(DynamicArchiveHeader, _base_archive_crc)); \
  58     ADD_NEXT(_all, "CDSFileMapRegion_size", sizeof(CDSFileMapRegion));
  59 
  60 int CDSOffsets::find_offset(const char* name) {
  61   if (_all == NULL) {
  62     CREATE_OFFSET_MAPS
  63   }
  64   CDSOffsets* it = _all;
  65   while(it) {
  66     if (!strcmp(name, it->get_name())) {
  67       return it->get_offset();
  68     }
  69     it = it->next();
  70   }
  71   return -1; // not found


  32 #include "memory/allocation.inline.hpp"
  33 #include "prims/cdsoffsets.hpp"
  34 
  35 CDSOffsets::CDSOffsets(const char* name, int offset, CDSOffsets* next) {
  36   _name = NEW_C_HEAP_ARRAY(char, strlen(name) + 1, mtInternal);
  37   strcpy(_name, name);
  38   _offset = offset;
  39   _next = next;
  40 }
  41 
  42 CDSOffsets* CDSOffsets::_all = NULL;
  43 #define ADD_NEXT(list, name, value) \
  44   list->add_end(new CDSOffsets(name, value, NULL))
  45 
  46 #define CREATE_OFFSET_MAPS                                                                  \
  47     _all = new CDSOffsets("size_t_size", sizeof(size_t), NULL);                             \
  48     ADD_NEXT(_all, "int_size", sizeof(int));                                                \
  49     ADD_NEXT(_all, "FileMapHeader::_magic", offset_of(FileMapHeader, _magic));              \
  50     ADD_NEXT(_all, "FileMapHeader::_crc", offset_of(FileMapHeader, _crc));                  \
  51     ADD_NEXT(_all, "FileMapHeader::_version", offset_of(FileMapHeader, _version));          \
  52     ADD_NEXT(_all, "FileMapHeader::_end_magic", offset_of(FileMapHeader, _end_magic));      \
  53     ADD_NEXT(_all, "FileMapHeader::_jvm_ident", offset_of(FileMapHeader, _jvm_ident));      \
  54     ADD_NEXT(_all, "FileMapHeader::_space[0]", offset_of(FileMapHeader, _space));           \
  55     ADD_NEXT(_all, "CDSFileMapRegion::_crc", offset_of(CDSFileMapRegion, _crc));            \
  56     ADD_NEXT(_all, "CDSFileMapRegion::_used", offset_of(CDSFileMapRegion, _used));          \
  57     ADD_NEXT(_all, "FileMapHeader::_paths_misc_info_size", offset_of(FileMapHeader, _paths_misc_info_size)); \
  58     ADD_NEXT(_all, "file_header_size", sizeof(FileMapHeader));                              \
  59     ADD_NEXT(_all, "DynamicArchiveHeader::_base_archive_crc", offset_of(DynamicArchiveHeader, _base_archive_crc)); \
  60     ADD_NEXT(_all, "CDSFileMapRegion_size", sizeof(CDSFileMapRegion));
  61 
  62 int CDSOffsets::find_offset(const char* name) {
  63   if (_all == NULL) {
  64     CREATE_OFFSET_MAPS
  65   }
  66   CDSOffsets* it = _all;
  67   while(it) {
  68     if (!strcmp(name, it->get_name())) {
  69       return it->get_offset();
  70     }
  71     it = it->next();
  72   }
  73   return -1; // not found
< prev index next >