src/hotspot/share/gc/z/zUnload.cpp
author pliden
Tue, 10 Sep 2019 11:11:31 +0200
changeset 58066 8407928b9fe5
parent 54623 1126f0607c70
child 58063 bdf136b8ae0e
child 59040 1251d78fafbf
permissions -rw-r--r--
8230566: ZGC: Don't substitute klass pointer during array clearing Reviewed-by: stefank, eosterlund
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
     1
/*
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 54567
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
     4
 *
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
     8
 *
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    13
 * accompanied this code).
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    14
 *
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    18
 *
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    21
 * questions.
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    22
 */
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    23
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    24
#include "precompiled.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    25
#include "classfile/classLoaderDataGraph.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    26
#include "classfile/systemDictionary.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    27
#include "code/codeBehaviours.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    28
#include "code/codeCache.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    29
#include "code/dependencyContext.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    30
#include "gc/shared/gcBehaviours.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    31
#include "gc/shared/suspendibleThreadSet.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    32
#include "gc/z/zLock.inline.hpp"
53894
bf1133e7dfba 8219469: ZGC: Extract functions out from ZNMethodTable into new ZNMethod class
stefank
parents: 52939
diff changeset
    33
#include "gc/z/zNMethod.hpp"
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    34
#include "gc/z/zOopClosures.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    35
#include "gc/z/zStat.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    36
#include "gc/z/zUnload.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    37
#include "oops/access.inline.hpp"
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    38
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    39
static const ZStatSubPhase ZSubPhaseConcurrentClassesUnload("Concurrent Classes Unload");
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    40
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    41
class ZIsUnloadingOopClosure : public OopClosure {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    42
private:
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    43
  ZPhantomIsAliveObjectClosure _is_alive;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    44
  bool                         _is_unloading;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    45
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    46
public:
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    47
  ZIsUnloadingOopClosure() :
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    48
      _is_alive(),
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    49
      _is_unloading(false) {}
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    50
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    51
  virtual void do_oop(oop* p) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    52
    const oop o = RawAccess<>::oop_load(p);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    53
    if (o != NULL && !_is_alive.do_object_b(o)) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    54
      _is_unloading = true;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    55
    }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    56
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    57
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    58
  virtual void do_oop(narrowOop* p) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    59
    ShouldNotReachHere();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    60
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    61
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    62
  bool is_unloading() const {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    63
    return _is_unloading;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    64
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    65
};
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    66
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    67
class ZIsUnloadingBehaviour : public IsUnloadingBehaviour {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    68
public:
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    69
  virtual bool is_unloading(CompiledMethod* method) const {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    70
    nmethod* const nm = method->as_nmethod();
53894
bf1133e7dfba 8219469: ZGC: Extract functions out from ZNMethodTable into new ZNMethod class
stefank
parents: 52939
diff changeset
    71
    ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
53921
a590b6107ab3 8218974: Free GC native structures in nmethod::flush
eosterlund
parents: 53894
diff changeset
    72
    ZLocker<ZReentrantLock> locker(lock);
a590b6107ab3 8218974: Free GC native structures in nmethod::flush
eosterlund
parents: 53894
diff changeset
    73
    ZIsUnloadingOopClosure cl;
54567
224515275cf9 8219718: ZGC: Make nmethod entry barriers and nmethod::is_unloading use ZNMethodDataOops
eosterlund
parents: 53921
diff changeset
    74
    ZNMethod::nmethod_oops_do(nm, &cl);
53921
a590b6107ab3 8218974: Free GC native structures in nmethod::flush
eosterlund
parents: 53894
diff changeset
    75
    return cl.is_unloading();
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    76
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    77
};
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    78
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    79
class ZCompiledICProtectionBehaviour : public CompiledICProtectionBehaviour {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    80
public:
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    81
  virtual bool lock(CompiledMethod* method) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    82
    nmethod* const nm = method->as_nmethod();
53894
bf1133e7dfba 8219469: ZGC: Extract functions out from ZNMethodTable into new ZNMethod class
stefank
parents: 52939
diff changeset
    83
    ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
53921
a590b6107ab3 8218974: Free GC native structures in nmethod::flush
eosterlund
parents: 53894
diff changeset
    84
    lock->lock();
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    85
    return true;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    86
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    87
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    88
  virtual void unlock(CompiledMethod* method) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    89
    nmethod* const nm = method->as_nmethod();
53894
bf1133e7dfba 8219469: ZGC: Extract functions out from ZNMethodTable into new ZNMethod class
stefank
parents: 52939
diff changeset
    90
    ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
53921
a590b6107ab3 8218974: Free GC native structures in nmethod::flush
eosterlund
parents: 53894
diff changeset
    91
    lock->unlock();
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    92
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    93
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    94
  virtual bool is_safe(CompiledMethod* method) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    95
    if (SafepointSynchronize::is_at_safepoint()) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    96
      return true;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    97
    }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    98
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
    99
    nmethod* const nm = method->as_nmethod();
53894
bf1133e7dfba 8219469: ZGC: Extract functions out from ZNMethodTable into new ZNMethod class
stefank
parents: 52939
diff changeset
   100
    ZReentrantLock* const lock = ZNMethod::lock_for_nmethod(nm);
53921
a590b6107ab3 8218974: Free GC native structures in nmethod::flush
eosterlund
parents: 53894
diff changeset
   101
    return lock->is_owned();
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   102
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   103
};
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   104
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   105
ZUnload::ZUnload(ZWorkers* workers) :
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   106
    _workers(workers) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   107
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   108
  if (!ClassUnloading) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   109
    return;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   110
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   111
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   112
  static ZIsUnloadingBehaviour is_unloading_behaviour;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   113
  IsUnloadingBehaviour::set_current(&is_unloading_behaviour);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   114
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   115
  static ZCompiledICProtectionBehaviour ic_protection_behaviour;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   116
  CompiledICProtectionBehaviour::set_current(&ic_protection_behaviour);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   117
}
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   118
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   119
void ZUnload::prepare() {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   120
  if (!ClassUnloading) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   121
    return;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   122
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   123
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   124
  CodeCache::increment_unloading_cycle();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   125
  DependencyContext::cleaning_start();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   126
}
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   127
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   128
void ZUnload::unlink() {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   129
  SuspendibleThreadSetJoiner sts;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   130
  bool unloading_occurred;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   131
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   132
  {
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 54567
diff changeset
   133
    MutexLocker ml(ClassLoaderDataGraph_lock);
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   134
    unloading_occurred = SystemDictionary::do_unloading(ZStatPhase::timer());
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   135
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   136
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   137
  Klass::clean_weak_klass_links(unloading_occurred);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   138
53894
bf1133e7dfba 8219469: ZGC: Extract functions out from ZNMethodTable into new ZNMethod class
stefank
parents: 52939
diff changeset
   139
  ZNMethod::unlink(_workers, unloading_occurred);
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   140
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   141
  DependencyContext::cleaning_end();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   142
}
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   143
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   144
void ZUnload::purge() {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   145
  {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   146
    SuspendibleThreadSetJoiner sts;
53894
bf1133e7dfba 8219469: ZGC: Extract functions out from ZNMethodTable into new ZNMethod class
stefank
parents: 52939
diff changeset
   147
    ZNMethod::purge(_workers);
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   148
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   149
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   150
  ClassLoaderDataGraph::purge();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   151
  CodeCache::purge_exception_caches();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   152
}
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   153
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   154
class ZUnloadRendezvousClosure : public ThreadClosure {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   155
public:
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   156
  void do_thread(Thread* thread) {}
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   157
};
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   158
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   159
void ZUnload::unload() {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   160
  if (!ClassUnloading) {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   161
    return;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   162
  }
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   163
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   164
  ZStatTimer timer(ZSubPhaseConcurrentClassesUnload);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   165
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   166
  // Unlink stale metadata and nmethods
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   167
  unlink();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   168
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   169
  // Make sure stale metadata and nmethods are no longer observable
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   170
  ZUnloadRendezvousClosure cl;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   171
  Handshake::execute(&cl);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   172
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   173
  // Purge stale metadata and nmethods that were unlinked
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   174
  purge();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   175
}
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   176
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   177
void ZUnload::finish() {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   178
  // Resize and verify metaspace
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   179
  MetaspaceGC::compute_new_size();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   180
  MetaspaceUtils::verify_metrics();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents:
diff changeset
   181
}