64
65 oop_Relocation* r = iter.oop_reloc();
66
67 if (!r->oop_is_immediate()) {
68 // Non-immediate oop found
69 non_immediate_oops = true;
70 continue;
71 }
72
73 if (r->oop_value() != NULL) {
74 // Non-NULL immediate oop found. NULL oops can safely be
75 // ignored since the method will be re-registered if they
76 // are later patched to be non-NULL.
77 immediate_oops.push(r->oop_addr());
78 }
79 }
80
81 // Attach GC data to nmethod
82 ZNMethodData* data = gc_data(nm);
83 if (data == NULL) {
84 data = ZNMethodData::create(nm);
85 set_gc_data(nm, data);
86 }
87
88 // Attach oops in GC data
89 ZNMethodDataOops* const new_oops = ZNMethodDataOops::create(immediate_oops, non_immediate_oops);
90 ZNMethodDataOops* const old_oops = data->swap_oops(new_oops);
91 ZNMethodDataOops::destroy(old_oops);
92 }
93
94 void ZNMethod::detach_gc_data(nmethod* nm) {
95 // Destroy GC data
96 ZNMethodData::destroy(gc_data(nm));
97 set_gc_data(nm, NULL);
98 }
99
100 ZReentrantLock* ZNMethod::lock_for_nmethod(nmethod* nm) {
101 ZNMethodData* const data = gc_data(nm);
102 if (data == NULL) {
103 return NULL;
104 }
105 return data->lock();
106 }
107
108 void ZNMethod::log_register(const nmethod* nm) {
109 LogTarget(Trace, gc, nmethod) log;
110 if (!log.is_enabled()) {
111 return;
112 }
113
114 const ZNMethodDataOops* const oops = gc_data(nm)->oops();
115
116 log.print("Register NMethod: %s.%s (" PTR_FORMAT "), "
117 "Compiler: %s, Oops: %d, ImmediateOops: " SIZE_FORMAT ", NonImmediateOops: %s",
118 nm->method()->method_holder()->external_name(),
119 nm->method()->name()->as_C_string(),
120 p2i(nm),
121 nm->compiler_name(),
122 nm->oops_count() - 1,
123 oops->immediates_count(),
124 oops->has_non_immediates() ? "Yes" : "No");
|
64
65 oop_Relocation* r = iter.oop_reloc();
66
67 if (!r->oop_is_immediate()) {
68 // Non-immediate oop found
69 non_immediate_oops = true;
70 continue;
71 }
72
73 if (r->oop_value() != NULL) {
74 // Non-NULL immediate oop found. NULL oops can safely be
75 // ignored since the method will be re-registered if they
76 // are later patched to be non-NULL.
77 immediate_oops.push(r->oop_addr());
78 }
79 }
80
81 // Attach GC data to nmethod
82 ZNMethodData* data = gc_data(nm);
83 if (data == NULL) {
84 data = new ZNMethodData();
85 set_gc_data(nm, data);
86 }
87
88 // Attach oops in GC data
89 ZNMethodDataOops* const new_oops = ZNMethodDataOops::create(immediate_oops, non_immediate_oops);
90 ZNMethodDataOops* const old_oops = data->swap_oops(new_oops);
91 ZNMethodDataOops::destroy(old_oops);
92 }
93
94 ZReentrantLock* ZNMethod::lock_for_nmethod(nmethod* nm) {
95 return gc_data(nm)->lock();
96 }
97
98 void ZNMethod::log_register(const nmethod* nm) {
99 LogTarget(Trace, gc, nmethod) log;
100 if (!log.is_enabled()) {
101 return;
102 }
103
104 const ZNMethodDataOops* const oops = gc_data(nm)->oops();
105
106 log.print("Register NMethod: %s.%s (" PTR_FORMAT "), "
107 "Compiler: %s, Oops: %d, ImmediateOops: " SIZE_FORMAT ", NonImmediateOops: %s",
108 nm->method()->method_holder()->external_name(),
109 nm->method()->name()->as_C_string(),
110 p2i(nm),
111 nm->compiler_name(),
112 nm->oops_count() - 1,
113 oops->immediates_count(),
114 oops->has_non_immediates() ? "Yes" : "No");
|
172 ZNMethodTable::register_nmethod(nm);
173
174 // Disarm nmethod entry barrier
175 disarm_nmethod(nm);
176 }
177
178 void ZNMethod::unregister_nmethod(nmethod* nm) {
179 assert(CodeCache_lock->owned_by_self(), "Lock must be held");
180
181 if (Thread::current()->is_Code_cache_sweeper_thread()) {
182 // The sweeper must wait for any ongoing iteration to complete
183 // before it can unregister an nmethod.
184 ZNMethodTable::wait_until_iteration_done();
185 }
186
187 ResourceMark rm;
188
189 log_unregister(nm);
190
191 ZNMethodTable::unregister_nmethod(nm);
192
193 // Destroy and detach gc data
194 detach_gc_data(nm);
195 }
196
197 void ZNMethod::disarm_nmethod(nmethod* nm) {
198 BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod();
199 if (bs != NULL) {
200 bs->disarm(nm);
201 }
202 }
203
204 void ZNMethod::nmethod_oops_do(nmethod* nm, OopClosure* cl) {
205 // Process oops table
206 {
207 oop* const begin = nm->oops_begin();
208 oop* const end = nm->oops_end();
209 for (oop* p = begin; p < end; p++) {
210 if (*p != Universe::non_oop_word()) {
211 cl->do_oop(p);
212 }
213 }
|
162 ZNMethodTable::register_nmethod(nm);
163
164 // Disarm nmethod entry barrier
165 disarm_nmethod(nm);
166 }
167
168 void ZNMethod::unregister_nmethod(nmethod* nm) {
169 assert(CodeCache_lock->owned_by_self(), "Lock must be held");
170
171 if (Thread::current()->is_Code_cache_sweeper_thread()) {
172 // The sweeper must wait for any ongoing iteration to complete
173 // before it can unregister an nmethod.
174 ZNMethodTable::wait_until_iteration_done();
175 }
176
177 ResourceMark rm;
178
179 log_unregister(nm);
180
181 ZNMethodTable::unregister_nmethod(nm);
182 }
183
184 void ZNMethod::flush_nmethod(nmethod* nm) {
185 // Destroy GC data
186 delete gc_data(nm);
187 }
188
189 void ZNMethod::disarm_nmethod(nmethod* nm) {
190 BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod();
191 if (bs != NULL) {
192 bs->disarm(nm);
193 }
194 }
195
196 void ZNMethod::nmethod_oops_do(nmethod* nm, OopClosure* cl) {
197 // Process oops table
198 {
199 oop* const begin = nm->oops_begin();
200 oop* const end = nm->oops_end();
201 for (oop* p = begin; p < end; p++) {
202 if (*p != Universe::non_oop_word()) {
203 cl->do_oop(p);
204 }
205 }
|