< prev index next >

src/hotspot/share/gc/z/zNMethod.cpp

Print this page

  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
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 #include "precompiled.hpp"

 25 #include "code/relocInfo.hpp"
 26 #include "code/nmethod.hpp"
 27 #include "code/icBuffer.hpp"
 28 #include "gc/shared/barrierSet.hpp"
 29 #include "gc/shared/barrierSetNMethod.hpp"
 30 #include "gc/shared/suspendibleThreadSet.hpp"
 31 #include "gc/z/zBarrier.inline.hpp"
 32 #include "gc/z/zGlobals.hpp"
 33 #include "gc/z/zLock.inline.hpp"
 34 #include "gc/z/zNMethod.hpp"
 35 #include "gc/z/zNMethodData.hpp"
 36 #include "gc/z/zNMethodTable.hpp"
 37 #include "gc/z/zTask.hpp"
 38 #include "gc/z/zWorkers.hpp"
 39 #include "logging/log.hpp"
 40 #include "memory/allocation.inline.hpp"
 41 #include "memory/iterator.hpp"
 42 #include "memory/resourceArea.hpp"
 43 #include "memory/universe.hpp"
 44 #include "oops/oop.inline.hpp"

189 void ZNMethod::flush_nmethod(nmethod* nm) {
190   // Destroy GC data
191   delete gc_data(nm);
192 }
193 
194 bool ZNMethod::supports_entry_barrier(nmethod* nm) {
195   BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod();
196   return bs->supports_entry_barrier(nm);
197 }
198 
199 bool ZNMethod::is_armed(nmethod* nm) {
200   BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod();
201   return bs->is_armed(nm);
202 }
203 
204 void ZNMethod::disarm(nmethod* nm) {
205   BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod();
206   bs->disarm(nm);
207 }
208 







209 void ZNMethod::nmethod_oops_do(nmethod* nm, OopClosure* cl) {
210   ZLocker<ZReentrantLock> locker(ZNMethod::lock_for_nmethod(nm));
211   if (!nm->is_alive()) {
212     return;
213   }
214 
215   ZNMethod::nmethod_oops_do_inner(nm, cl);
216 }
217 
218 void ZNMethod::nmethod_oops_do_inner(nmethod* nm, OopClosure* cl) {
219   // Process oops table
220   {
221     oop* const begin = nm->oops_begin();
222     oop* const end = nm->oops_end();
223     for (oop* p = begin; p < end; p++) {
224       if (!Universe::contains_non_oop_word(p)) {
225         cl->do_oop(p);
226       }
227     }
228   }

314   virtual void do_nmethod(nmethod* nm) {
315     if (failed()) {
316       return;
317     }
318 
319     if (!nm->is_alive()) {
320       return;
321     }
322 
323     if (nm->is_unloading()) {
324       ZLocker<ZReentrantLock> locker(ZNMethod::lock_for_nmethod(nm));
325       unlink(nm);
326       return;
327     }
328 
329     ZLocker<ZReentrantLock> locker(ZNMethod::lock_for_nmethod(nm));
330 
331     if (ZNMethod::is_armed(nm)) {
332       // Heal oops and disarm
333       ZNMethod::nmethod_oops_barrier(nm);
334       ZNMethod::disarm(nm);
335     }
336 
337     // Clear compiled ICs and exception caches
338     if (!nm->unload_nmethod_caches(_unloading_occurred)) {
339       set_failed();
340     }
341   }
342 
343   bool failed() const {
344     return Atomic::load(&_failed);
345   }
346 };
347 
348 class ZNMethodUnlinkTask : public ZTask {
349 private:
350   ZNMethodUnlinkClosure _cl;
351   ICRefillVerifier*     _verifier;
352 
353 public:
354   ZNMethodUnlinkTask(bool unloading_occurred, ICRefillVerifier* verifier) :

  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
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 #include "precompiled.hpp"
 25 #include "code/compiledMethod.inline.hpp"
 26 #include "code/relocInfo.hpp"
 27 #include "code/nmethod.hpp"
 28 #include "code/icBuffer.hpp"
 29 #include "gc/shared/barrierSet.hpp"
 30 #include "gc/shared/barrierSetNMethod.hpp"
 31 #include "gc/shared/suspendibleThreadSet.hpp"
 32 #include "gc/z/zBarrier.inline.hpp"
 33 #include "gc/z/zGlobals.hpp"
 34 #include "gc/z/zLock.inline.hpp"
 35 #include "gc/z/zNMethod.hpp"
 36 #include "gc/z/zNMethodData.hpp"
 37 #include "gc/z/zNMethodTable.hpp"
 38 #include "gc/z/zTask.hpp"
 39 #include "gc/z/zWorkers.hpp"
 40 #include "logging/log.hpp"
 41 #include "memory/allocation.inline.hpp"
 42 #include "memory/iterator.hpp"
 43 #include "memory/resourceArea.hpp"
 44 #include "memory/universe.hpp"
 45 #include "oops/oop.inline.hpp"

190 void ZNMethod::flush_nmethod(nmethod* nm) {
191   // Destroy GC data
192   delete gc_data(nm);
193 }
194 
195 bool ZNMethod::supports_entry_barrier(nmethod* nm) {
196   BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod();
197   return bs->supports_entry_barrier(nm);
198 }
199 
200 bool ZNMethod::is_armed(nmethod* nm) {
201   BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod();
202   return bs->is_armed(nm);
203 }
204 
205 void ZNMethod::disarm(nmethod* nm) {
206   BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod();
207   bs->disarm(nm);
208 }
209 
210 void ZNMethod::arm(nmethod* nm, int arm_value) {
211   BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod();
212   if (bs != NULL) {
213     bs->arm(nm, arm_value);
214   }
215 }
216 
217 void ZNMethod::nmethod_oops_do(nmethod* nm, OopClosure* cl) {
218   ZLocker<ZReentrantLock> locker(ZNMethod::lock_for_nmethod(nm));
219   if (!nm->is_alive()) {
220     return;
221   }
222 
223   ZNMethod::nmethod_oops_do_inner(nm, cl);
224 }
225 
226 void ZNMethod::nmethod_oops_do_inner(nmethod* nm, OopClosure* cl) {
227   // Process oops table
228   {
229     oop* const begin = nm->oops_begin();
230     oop* const end = nm->oops_end();
231     for (oop* p = begin; p < end; p++) {
232       if (!Universe::contains_non_oop_word(p)) {
233         cl->do_oop(p);
234       }
235     }
236   }

322   virtual void do_nmethod(nmethod* nm) {
323     if (failed()) {
324       return;
325     }
326 
327     if (!nm->is_alive()) {
328       return;
329     }
330 
331     if (nm->is_unloading()) {
332       ZLocker<ZReentrantLock> locker(ZNMethod::lock_for_nmethod(nm));
333       unlink(nm);
334       return;
335     }
336 
337     ZLocker<ZReentrantLock> locker(ZNMethod::lock_for_nmethod(nm));
338 
339     if (ZNMethod::is_armed(nm)) {
340       // Heal oops and disarm
341       ZNMethod::nmethod_oops_barrier(nm);
342       ZNMethod::arm(nm, 0);
343     }
344 
345     // Clear compiled ICs and exception caches
346     if (!nm->unload_nmethod_caches(_unloading_occurred)) {
347       set_failed();
348     }
349   }
350 
351   bool failed() const {
352     return Atomic::load(&_failed);
353   }
354 };
355 
356 class ZNMethodUnlinkTask : public ZTask {
357 private:
358   ZNMethodUnlinkClosure _cl;
359   ICRefillVerifier*     _verifier;
360 
361 public:
362   ZNMethodUnlinkTask(bool unloading_occurred, ICRefillVerifier* verifier) :
< prev index next >