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