1 /* |
1 /* |
2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2003, 2018, 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. |
657 |
657 |
658 // Memory map a region in the address space. |
658 // Memory map a region in the address space. |
659 static const char* shared_region_name[] = { "MiscData", "ReadWrite", "ReadOnly", "MiscCode", "OptionalData", |
659 static const char* shared_region_name[] = { "MiscData", "ReadWrite", "ReadOnly", "MiscCode", "OptionalData", |
660 "String1", "String2", "OpenArchive1", "OpenArchive2" }; |
660 "String1", "String2", "OpenArchive1", "OpenArchive2" }; |
661 |
661 |
662 char* FileMapInfo::map_region(int i) { |
662 char* FileMapInfo::map_region(int i, char** top_ret) { |
663 assert(!MetaspaceShared::is_heap_region(i), "sanity"); |
663 assert(!MetaspaceShared::is_heap_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_up(used, alignment); |
667 size_t size = align_up(used, alignment); |
684 // This call is Windows-only because the memory_type gets recorded for the other platforms |
684 // This call is Windows-only because the memory_type gets recorded for the other platforms |
685 // in method FileMapInfo::reserve_shared_memory(), which is not called on Windows. |
685 // in method FileMapInfo::reserve_shared_memory(), which is not called on Windows. |
686 MemTracker::record_virtual_memory_type((address)base, mtClassShared); |
686 MemTracker::record_virtual_memory_type((address)base, mtClassShared); |
687 #endif |
687 #endif |
688 |
688 |
|
689 |
|
690 if (!verify_region_checksum(i)) { |
|
691 return NULL; |
|
692 } |
|
693 |
|
694 *top_ret = base + size; |
689 return base; |
695 return base; |
690 } |
696 } |
691 |
697 |
692 static MemRegion *string_ranges = NULL; |
698 static MemRegion *string_ranges = NULL; |
693 static MemRegion *open_archive_heap_ranges = NULL; |
699 static MemRegion *open_archive_heap_ranges = NULL; |
1038 _paths_misc_info = NULL; |
1044 _paths_misc_info = NULL; |
1039 } |
1045 } |
1040 return status; |
1046 return status; |
1041 } |
1047 } |
1042 |
1048 |
1043 // The following method is provided to see whether a given pointer |
|
1044 // falls in the mapped shared metadata space. |
|
1045 // Param: |
|
1046 // p, The given pointer |
|
1047 // Return: |
|
1048 // True if the p is within the mapped shared space, otherwise, false. |
|
1049 bool FileMapInfo::is_in_shared_space(const void* p) { |
|
1050 for (int i = 0; i < MetaspaceShared::num_non_heap_spaces; i++) { |
|
1051 char *base; |
|
1052 if (_header->_space[i]._used == 0) { |
|
1053 continue; |
|
1054 } |
|
1055 base = _header->region_addr(i); |
|
1056 if (p >= base && p < base + _header->_space[i]._used) { |
|
1057 return true; |
|
1058 } |
|
1059 } |
|
1060 |
|
1061 return false; |
|
1062 } |
|
1063 |
|
1064 // Check if a given address is within one of the shared regions |
1049 // Check if a given address is within one of the shared regions |
1065 bool FileMapInfo::is_in_shared_region(const void* p, int idx) { |
1050 bool FileMapInfo::is_in_shared_region(const void* p, int idx) { |
1066 assert(idx == MetaspaceShared::ro || |
1051 assert(idx == MetaspaceShared::ro || |
1067 idx == MetaspaceShared::rw || |
1052 idx == MetaspaceShared::rw || |
1068 idx == MetaspaceShared::mc || |
1053 idx == MetaspaceShared::mc || |