hotspot/src/share/vm/memory/filemap.cpp
changeset 46619 a3919f5e8d2b
parent 46560 388aa8d67c80
child 46625 edefffab74e2
equal deleted inserted replaced
46618:d503911aa948 46619:a3919f5e8d2b
   561 
   561 
   562 
   562 
   563 // Align file position to an allocation unit boundary.
   563 // Align file position to an allocation unit boundary.
   564 
   564 
   565 void FileMapInfo::align_file_position() {
   565 void FileMapInfo::align_file_position() {
   566   size_t new_file_offset = align_size_up(_file_offset,
   566   size_t new_file_offset = align_up(_file_offset,
   567                                          os::vm_allocation_granularity());
   567                                          os::vm_allocation_granularity());
   568   if (new_file_offset != _file_offset) {
   568   if (new_file_offset != _file_offset) {
   569     _file_offset = new_file_offset;
   569     _file_offset = new_file_offset;
   570     if (_file_open) {
   570     if (_file_open) {
   571       // Seek one byte back from the target and write a byte to insure
   571       // Seek one byte back from the target and write a byte to insure
   611   if (!si->_read_only) {
   611   if (!si->_read_only) {
   612     // the space is already readwrite so we are done
   612     // the space is already readwrite so we are done
   613     return true;
   613     return true;
   614   }
   614   }
   615   size_t used = si->_used;
   615   size_t used = si->_used;
   616   size_t size = align_size_up(used, os::vm_allocation_granularity());
   616   size_t size = align_up(used, os::vm_allocation_granularity());
   617   if (!open_for_read()) {
   617   if (!open_for_read()) {
   618     return false;
   618     return false;
   619   }
   619   }
   620   char *addr = _header->region_addr(idx);
   620   char *addr = _header->region_addr(idx);
   621   char *base = os::remap_memory(_fd, _full_path, si->_file_offset,
   621   char *base = os::remap_memory(_fd, _full_path, si->_file_offset,
   662 char* FileMapInfo::map_region(int i) {
   662 char* FileMapInfo::map_region(int i) {
   663   assert(!MetaspaceShared::is_string_region(i), "sanity");
   663   assert(!MetaspaceShared::is_string_region(i), "sanity");
   664   struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i];
   664   struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i];
   665   size_t used = si->_used;
   665   size_t used = si->_used;
   666   size_t alignment = os::vm_allocation_granularity();
   666   size_t alignment = os::vm_allocation_granularity();
   667   size_t size = align_size_up(used, alignment);
   667   size_t size = align_up(used, alignment);
   668   char *requested_addr = _header->region_addr(i);
   668   char *requested_addr = _header->region_addr(i);
   669 
   669 
   670   // If a tool agent is in use (debugging enabled), we must map the address space RW
   670   // If a tool agent is in use (debugging enabled), we must map the address space RW
   671   if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space()) {
   671   if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space()) {
   672     si->_read_only = false;
   672     si->_read_only = false;
   829 
   829 
   830 void FileMapInfo::unmap_region(int i) {
   830 void FileMapInfo::unmap_region(int i) {
   831   assert(!MetaspaceShared::is_string_region(i), "sanity");
   831   assert(!MetaspaceShared::is_string_region(i), "sanity");
   832   struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i];
   832   struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i];
   833   size_t used = si->_used;
   833   size_t used = si->_used;
   834   size_t size = align_size_up(used, os::vm_allocation_granularity());
   834   size_t size = align_up(used, os::vm_allocation_granularity());
   835 
   835 
   836   if (used == 0) {
   836   if (used == 0) {
   837     return;
   837     return;
   838   }
   838   }
   839 
   839