< prev index next >

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

Print this page
rev 56205 : imported patch 8226705-v1
   1 /*
   2  * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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  */


 249 
 250 void ZNMethod::oops_do(OopClosure* cl) {
 251   ZNMethodToOopsDoClosure nmethod_cl(cl);
 252   ZNMethodTable::nmethods_do(&nmethod_cl);
 253 }
 254 
 255 class ZNMethodUnlinkClosure : public NMethodClosure {
 256 private:
 257   bool          _unloading_occurred;
 258   volatile bool _failed;
 259 
 260   void set_failed() {
 261     Atomic::store(true, &_failed);
 262   }
 263 
 264   void unlink(nmethod* nm) {
 265     // Unlinking of the dependencies must happen before the
 266     // handshake separating unlink and purge.
 267     nm->flush_dependencies(false /* delete_immediately */);
 268 
 269     // We don't need to take the lock when unlinking nmethods from

 270     // the Method, because it is only concurrently unlinked by
 271     // the entry barrier, which acquires the per nmethod lock.
 272     nm->unlink_from_method(false /* acquire_lock */);
 273 
 274     if (nm->is_osr_method()) {
 275       // Invalidate the osr nmethod before the handshake. The nmethod
 276       // will be made unloaded after the handshake. Then invalidate_osr_method()
 277       // will be called again, which will be a no-op.
 278       nm->invalidate_osr_method();
 279     }
 280   }
 281 
 282 public:
 283   ZNMethodUnlinkClosure(bool unloading_occurred) :
 284       _unloading_occurred(unloading_occurred),
 285       _failed(false) {}
 286 
 287   virtual void do_nmethod(nmethod* nm) {
 288     if (failed()) {
 289       return;
 290     }
 291 
 292     if (!nm->is_alive()) {


   1 /*
   2  * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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  */


 249 
 250 void ZNMethod::oops_do(OopClosure* cl) {
 251   ZNMethodToOopsDoClosure nmethod_cl(cl);
 252   ZNMethodTable::nmethods_do(&nmethod_cl);
 253 }
 254 
 255 class ZNMethodUnlinkClosure : public NMethodClosure {
 256 private:
 257   bool          _unloading_occurred;
 258   volatile bool _failed;
 259 
 260   void set_failed() {
 261     Atomic::store(true, &_failed);
 262   }
 263 
 264   void unlink(nmethod* nm) {
 265     // Unlinking of the dependencies must happen before the
 266     // handshake separating unlink and purge.
 267     nm->flush_dependencies(false /* delete_immediately */);
 268 
 269     // unlink_from_method will take the CompiledMethod_lock.
 270     // In this case we don't strictly need it when unlinking nmethods from
 271     // the Method, because it is only concurrently unlinked by
 272     // the entry barrier, which acquires the per nmethod lock.
 273     nm->unlink_from_method();
 274 
 275     if (nm->is_osr_method()) {
 276       // Invalidate the osr nmethod before the handshake. The nmethod
 277       // will be made unloaded after the handshake. Then invalidate_osr_method()
 278       // will be called again, which will be a no-op.
 279       nm->invalidate_osr_method();
 280     }
 281   }
 282 
 283 public:
 284   ZNMethodUnlinkClosure(bool unloading_occurred) :
 285       _unloading_occurred(unloading_occurred),
 286       _failed(false) {}
 287 
 288   virtual void do_nmethod(nmethod* nm) {
 289     if (failed()) {
 290       return;
 291     }
 292 
 293     if (!nm->is_alive()) {


< prev index next >