hotspot/src/share/vm/memory/filemap.cpp
changeset 15100 0ae85ac7c8b0
parent 14577 fd68d810d86b
child 15101 58d43bf04c45
equal deleted inserted replaced
15099:b31d40895bbb 15100:0ae85ac7c8b0
   209     tty->print_cr("   %s", _full_path);
   209     tty->print_cr("   %s", _full_path);
   210   }
   210   }
   211 
   211 
   212   // Remove the existing file in case another process has it open.
   212   // Remove the existing file in case another process has it open.
   213   remove(_full_path);
   213   remove(_full_path);
       
   214 #ifdef _WINDOWS  // if 0444 is used on Windows, then remove() will fail.
       
   215   int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0744);
       
   216 #else
   214   int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444);
   217   int fd = open(_full_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0444);
       
   218 #endif
   215   if (fd < 0) {
   219   if (fd < 0) {
   216     fail_stop("Unable to create shared archive file %s.", _full_path);
   220     fail_stop("Unable to create shared archive file %s.", _full_path);
   217   }
   221   }
   218   _fd = fd;
   222   _fd = fd;
   219   _file_offset = 0;
   223   _file_offset = 0;
   368   if (!rs.is_reserved()) {
   372   if (!rs.is_reserved()) {
   369     fail_continue(err_msg("Unable to reserved shared space at required address " INTPTR_FORMAT, requested_addr));
   373     fail_continue(err_msg("Unable to reserved shared space at required address " INTPTR_FORMAT, requested_addr));
   370     return rs;
   374     return rs;
   371   }
   375   }
   372   // the reserved virtual memory is for mapping class data sharing archive
   376   // the reserved virtual memory is for mapping class data sharing archive
   373   if (MemTracker::is_on()) {
   377   MemTracker::record_virtual_memory_type((address)rs.base(), mtClassShared);
   374     MemTracker::record_virtual_memory_type((address)rs.base(), mtClassShared);
   378 
   375   }
       
   376   return rs;
   379   return rs;
   377 }
   380 }
   378 
   381 
   379 // Memory map a region in the address space.
   382 // Memory map a region in the address space.
   380 static const char* shared_region_name[] = { "ReadOnly", "ReadWrite", "MiscData", "MiscCode"};
   383 static const char* shared_region_name[] = { "ReadOnly", "ReadWrite", "MiscData", "MiscCode"};
   392                               si->_allow_exec);
   395                               si->_allow_exec);
   393   if (base == NULL || base != si->_base) {
   396   if (base == NULL || base != si->_base) {
   394     fail_continue(err_msg("Unable to map %s shared space at required address.", shared_region_name[i]));
   397     fail_continue(err_msg("Unable to map %s shared space at required address.", shared_region_name[i]));
   395     return NULL;
   398     return NULL;
   396   }
   399   }
       
   400 #ifdef _WINDOWS
       
   401   // This call is Windows-only because the memory_type gets recorded for the other platforms
       
   402   // in method FileMapInfo::reserve_shared_memory(), which is not called on Windows.
       
   403   MemTracker::record_virtual_memory_type((address)base, mtClassShared);
       
   404 #endif
   397   return base;
   405   return base;
   398 }
   406 }
   399 
   407 
   400 
   408 
   401 // Unmap a memory region in the address space.
   409 // Unmap a memory region in the address space.