hotspot/src/share/vm/memory/filemap.cpp
changeset 31332 dc17890f352d
parent 28950 693ae3d5e1ff
child 31345 1bba15125d8d
equal deleted inserted replaced
31331:a7c714b6cfb3 31332:dc17890f352d
    30 #include "classfile/altHashing.hpp"
    30 #include "classfile/altHashing.hpp"
    31 #include "memory/filemap.hpp"
    31 #include "memory/filemap.hpp"
    32 #include "memory/metadataFactory.hpp"
    32 #include "memory/metadataFactory.hpp"
    33 #include "memory/oopFactory.hpp"
    33 #include "memory/oopFactory.hpp"
    34 #include "oops/objArrayOop.hpp"
    34 #include "oops/objArrayOop.hpp"
       
    35 #include "prims/jvmtiExport.hpp"
    35 #include "runtime/arguments.hpp"
    36 #include "runtime/arguments.hpp"
    36 #include "runtime/java.hpp"
    37 #include "runtime/java.hpp"
    37 #include "runtime/os.hpp"
    38 #include "runtime/os.hpp"
    38 #include "runtime/vm_version.hpp"
    39 #include "runtime/vm_version.hpp"
    39 #include "services/memTracker.hpp"
    40 #include "services/memTracker.hpp"
   566   struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i];
   567   struct FileMapInfo::FileMapHeader::space_info* si = &_header->_space[i];
   567   size_t used = si->_used;
   568   size_t used = si->_used;
   568   size_t alignment = os::vm_allocation_granularity();
   569   size_t alignment = os::vm_allocation_granularity();
   569   size_t size = align_size_up(used, alignment);
   570   size_t size = align_size_up(used, alignment);
   570   char *requested_addr = si->_base;
   571   char *requested_addr = si->_base;
       
   572   bool read_only;
       
   573 
       
   574   // If a tool agent is in use (debugging enabled), we must map the address space RW
       
   575   if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space()) {
       
   576     read_only = false;
       
   577   } else {
       
   578     read_only = si->_read_only;
       
   579   }
       
   580 
   571 
   581 
   572   // map the contents of the CDS archive in this memory
   582   // map the contents of the CDS archive in this memory
   573   char *base = os::map_memory(_fd, _full_path, si->_file_offset,
   583   char *base = os::map_memory(_fd, _full_path, si->_file_offset,
   574                               requested_addr, size, si->_read_only,
   584                               requested_addr, size, read_only,
   575                               si->_allow_exec);
   585                               si->_allow_exec);
   576   if (base == NULL || base != si->_base) {
   586   if (base == NULL || base != si->_base) {
   577     fail_continue("Unable to map %s shared space at required address.", shared_region_name[i]);
   587     fail_continue("Unable to map %s shared space at required address.", shared_region_name[i]);
   578     return NULL;
   588     return NULL;
   579   }
   589   }
   635 // [2] validate_classpath_entry_table - this is done later, because the table is in the RW
   645 // [2] validate_classpath_entry_table - this is done later, because the table is in the RW
   636 //     region of the archive, which is not mapped yet.
   646 //     region of the archive, which is not mapped yet.
   637 bool FileMapInfo::initialize() {
   647 bool FileMapInfo::initialize() {
   638   assert(UseSharedSpaces, "UseSharedSpaces expected.");
   648   assert(UseSharedSpaces, "UseSharedSpaces expected.");
   639 
   649 
   640   if (JvmtiExport::can_modify_any_class() || JvmtiExport::can_walk_any_space()) {
       
   641     fail_continue("Tool agent requires sharing to be disabled.");
       
   642     return false;
       
   643   }
       
   644 
       
   645   if (!open_for_read()) {
   650   if (!open_for_read()) {
   646     return false;
   651     return false;
   647   }
   652   }
   648 
   653 
   649   init_from_file(_fd);
   654   init_from_file(_fd);