39 #include "logging/log.hpp"
40
41 static const ZStatCounter ZCounterRelocationContention("Contention", "Relocation Contention", ZStatUnitOpsPerSecond);
42
43 ZRelocate::ZRelocate(ZWorkers* workers) :
44 _workers(workers) {}
45
46 class ZRelocateRootsIteratorClosure : public ZRootsIteratorClosure {
47 public:
48 virtual void do_thread(Thread* thread) {
49 // Update thread local address bad mask
50 ZThreadLocalData::set_address_bad_mask(thread, ZAddressBadMask);
51
52 // Relocate invisible root
53 ZThreadLocalData::do_invisible_root(thread, ZBarrier::relocate_barrier_on_root_oop_field);
54
55 // Remap TLAB
56 ZThreadLocalAllocBuffer::remap(thread);
57 }
58
59 virtual void do_oop(oop* p) {
60 ZBarrier::relocate_barrier_on_root_oop_field(p);
61 }
62
63 virtual void do_oop(narrowOop* p) {
64 ShouldNotReachHere();
65 }
66 };
67
68 class ZRelocateRootsTask : public ZTask {
69 private:
70 ZRootsIterator _roots;
71 ZRelocateRootsIteratorClosure _cl;
72
73 public:
74 ZRelocateRootsTask() :
75 ZTask("ZRelocateRootsTask"),
76 _roots(true /* visit_jvmti_weak_export */, true /* disarm_nmethods */) {}
77
78 virtual void work() {
79 // During relocation we need to visit the JVMTI
80 // export weak roots to rehash the JVMTI tag map
81 _roots.oops_do(&_cl);
82 }
83 };
84
85 void ZRelocate::start() {
86 ZRelocateRootsTask task;
87 _workers->run_parallel(&task);
88 }
89
90 uintptr_t ZRelocate::relocate_object_inner(ZForwarding* forwarding, uintptr_t from_index, uintptr_t from_offset) const {
91 ZForwardingCursor cursor;
92
93 // Lookup forwarding entry
94 const ZForwardingEntry entry = forwarding->find(from_index, &cursor);
95 if (entry.populated() && entry.from_index() == from_index) {
96 // Already relocated, return new address
|
39 #include "logging/log.hpp"
40
41 static const ZStatCounter ZCounterRelocationContention("Contention", "Relocation Contention", ZStatUnitOpsPerSecond);
42
43 ZRelocate::ZRelocate(ZWorkers* workers) :
44 _workers(workers) {}
45
46 class ZRelocateRootsIteratorClosure : public ZRootsIteratorClosure {
47 public:
48 virtual void do_thread(Thread* thread) {
49 // Update thread local address bad mask
50 ZThreadLocalData::set_address_bad_mask(thread, ZAddressBadMask);
51
52 // Relocate invisible root
53 ZThreadLocalData::do_invisible_root(thread, ZBarrier::relocate_barrier_on_root_oop_field);
54
55 // Remap TLAB
56 ZThreadLocalAllocBuffer::remap(thread);
57 }
58
59 virtual bool should_disarm_nmethods() const {
60 return true;
61 }
62
63 virtual void do_oop(oop* p) {
64 ZBarrier::relocate_barrier_on_root_oop_field(p);
65 }
66
67 virtual void do_oop(narrowOop* p) {
68 ShouldNotReachHere();
69 }
70 };
71
72 class ZRelocateRootsTask : public ZTask {
73 private:
74 ZRootsIterator _roots;
75 ZRelocateRootsIteratorClosure _cl;
76
77 public:
78 ZRelocateRootsTask() :
79 ZTask("ZRelocateRootsTask"),
80 _roots(true /* visit_jvmti_weak_export */) {}
81
82 virtual void work() {
83 // During relocation we need to visit the JVMTI
84 // export weak roots to rehash the JVMTI tag map
85 _roots.oops_do(&_cl);
86 }
87 };
88
89 void ZRelocate::start() {
90 ZRelocateRootsTask task;
91 _workers->run_parallel(&task);
92 }
93
94 uintptr_t ZRelocate::relocate_object_inner(ZForwarding* forwarding, uintptr_t from_index, uintptr_t from_offset) const {
95 ZForwardingCursor cursor;
96
97 // Lookup forwarding entry
98 const ZForwardingEntry entry = forwarding->find(from_index, &cursor);
99 if (entry.populated() && entry.from_index() == from_index) {
100 // Already relocated, return new address
|