26 #include "gc/z/zPhysicalMemory.inline.hpp" |
26 #include "gc/z/zPhysicalMemory.inline.hpp" |
27 #include "gc/z/zVirtualMemory.inline.hpp" |
27 #include "gc/z/zVirtualMemory.inline.hpp" |
28 #include "utilities/align.hpp" |
28 #include "utilities/align.hpp" |
29 #include "utilities/debug.hpp" |
29 #include "utilities/debug.hpp" |
30 |
30 |
31 ZPage::ZPage(uint8_t type, ZVirtualMemory vmem, ZPhysicalMemory pmem) : |
31 ZPage::ZPage(const ZVirtualMemory& vmem, const ZPhysicalMemory& pmem) : |
|
32 _type(type_from_size(vmem.size())), |
|
33 _numa_id((uint8_t)-1), |
|
34 _seqnum(0), |
|
35 _virtual(vmem), |
|
36 _top(start()), |
|
37 _livemap(object_max_count()), |
|
38 _last_used(0), |
|
39 _physical(pmem) { |
|
40 assert_initialized(); |
|
41 } |
|
42 |
|
43 ZPage::ZPage(uint8_t type, const ZVirtualMemory& vmem, const ZPhysicalMemory& pmem) : |
32 _type(type), |
44 _type(type), |
33 _numa_id((uint8_t)-1), |
45 _numa_id((uint8_t)-1), |
34 _seqnum(0), |
46 _seqnum(0), |
35 _virtual(vmem), |
47 _virtual(vmem), |
36 _top(start()), |
48 _top(start()), |
37 _livemap(object_max_count()), |
49 _livemap(object_max_count()), |
|
50 _last_used(0), |
38 _physical(pmem) { |
51 _physical(pmem) { |
39 assert(!_physical.is_null(), "Should not be null"); |
52 assert_initialized(); |
40 assert(!_virtual.is_null(), "Should not be null"); |
|
41 assert((type == ZPageTypeSmall && size() == ZPageSizeSmall) || |
|
42 (type == ZPageTypeMedium && size() == ZPageSizeMedium) || |
|
43 (type == ZPageTypeLarge && is_aligned(size(), ZGranuleSize)), |
|
44 "Page type/size mismatch"); |
|
45 } |
53 } |
46 |
54 |
47 ZPage::~ZPage() { |
55 void ZPage::assert_initialized() const { |
48 assert(_physical.is_null(), "Should be null"); |
56 assert(!_virtual.is_null(), "Should not be null"); |
|
57 assert(!_physical.is_null(), "Should not be null"); |
|
58 assert((_type == ZPageTypeSmall && size() == ZPageSizeSmall) || |
|
59 (_type == ZPageTypeMedium && size() == ZPageSizeMedium) || |
|
60 (_type == ZPageTypeLarge && is_aligned(size(), ZGranuleSize)), |
|
61 "Page type/size mismatch"); |
49 } |
62 } |
50 |
63 |
51 void ZPage::reset() { |
64 void ZPage::reset() { |
52 _seqnum = ZGlobalSeqNum; |
65 _seqnum = ZGlobalSeqNum; |
53 _top = start(); |
66 _top = start(); |
54 _livemap.reset(); |
67 _livemap.reset(); |
|
68 _last_used = 0; |
|
69 } |
|
70 |
|
71 ZPage* ZPage::retype(uint8_t type) { |
|
72 assert(_type != type, "Invalid retype"); |
|
73 _type = type; |
|
74 _livemap.resize(object_max_count()); |
|
75 return this; |
|
76 } |
|
77 |
|
78 ZPage* ZPage::split(size_t size) { |
|
79 return split(type_from_size(size), size); |
|
80 } |
|
81 |
|
82 ZPage* ZPage::split(uint8_t type, size_t size) { |
|
83 assert(_virtual.size() > size, "Invalid split"); |
|
84 |
|
85 // Resize this page, keep _numa_id, _seqnum, and _last_used |
|
86 const ZVirtualMemory vmem = _virtual.split(size); |
|
87 const ZPhysicalMemory pmem = _physical.split(size); |
|
88 _type = type_from_size(_virtual.size()); |
|
89 _top = start(); |
|
90 _livemap.resize(object_max_count()); |
|
91 |
|
92 // Create new page, inherit _seqnum and _last_used |
|
93 ZPage* const page = new ZPage(type, vmem, pmem); |
|
94 page->_seqnum = _seqnum; |
|
95 page->_last_used = _last_used; |
|
96 return page; |
55 } |
97 } |
56 |
98 |
57 void ZPage::print_on(outputStream* out) const { |
99 void ZPage::print_on(outputStream* out) const { |
58 out->print_cr(" %-6s " PTR_FORMAT " " PTR_FORMAT " " PTR_FORMAT " %s%s", |
100 out->print_cr(" %-6s " PTR_FORMAT " " PTR_FORMAT " " PTR_FORMAT " %s%s", |
59 type_to_string(), start(), top(), end(), |
101 type_to_string(), start(), top(), end(), |