src/hotspot/share/gc/shared/parallelCleaning.cpp
author tschatzl
Tue, 29 Jan 2019 11:30:17 +0100
changeset 53536 482109fae02b
parent 52661 4f45c682eab0
child 54122 4b1426ed1c44
permissions -rw-r--r--
8213229: Investigate treating StringTable as weak in young collections Reviewed-by: zgu, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
     1
/*
53536
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
     4
 *
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
     8
 *
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    13
 * accompanied this code).
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    14
 *
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    18
 *
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    21
 * questions.
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    22
 *
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    23
 */
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    24
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    25
#include "precompiled.hpp"
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    26
#include "classfile/symbolTable.hpp"
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    27
#include "classfile/stringTable.hpp"
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    28
#include "code/codeCache.hpp"
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    29
#include "gc/shared/parallelCleaning.hpp"
52385
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents: 51537
diff changeset
    30
#include "logging/log.hpp"
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    31
#include "memory/resourceArea.hpp"
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    32
#include "logging/log.hpp"
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    33
53536
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    34
StringDedupCleaningTask::StringDedupCleaningTask(BoolObjectClosure* is_alive,
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    35
                                                 OopClosure* keep_alive,
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    36
                                                 bool resize_table) :
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    37
  AbstractGangTask("String Dedup Cleaning"),
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    38
  _dedup_closure(is_alive, keep_alive) {
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    39
53536
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    40
  if (StringDedup::is_enabled()) {
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    41
    StringDedup::gc_prologue(resize_table);
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    42
  }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    43
}
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    44
53536
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    45
StringDedupCleaningTask::~StringDedupCleaningTask() {
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    46
  if (StringDedup::is_enabled()) {
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    47
    StringDedup::gc_epilogue();
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    48
  }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    49
}
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    50
53536
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    51
void StringDedupCleaningTask::work(uint worker_id) {
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    52
  if (StringDedup::is_enabled()) {
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    53
    StringDedup::parallel_unlink(&_dedup_closure, worker_id);
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    54
  }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    55
}
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    56
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    57
CodeCacheUnloadingTask::CodeCacheUnloadingTask(uint num_workers, BoolObjectClosure* is_alive, bool unloading_occurred) :
53536
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    58
  _unloading_scope(is_alive),
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    59
  _unloading_occurred(unloading_occurred),
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    60
  _num_workers(num_workers),
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    61
  _first_nmethod(NULL),
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
    62
  _claimed_nmethod(NULL) {
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    63
  // Get first alive nmethod
52661
4f45c682eab0 8213755: Let nmethods be is_unloading() outside of safepoints
eosterlund
parents: 52448
diff changeset
    64
  CompiledMethodIterator iter(CompiledMethodIterator::only_alive);
4f45c682eab0 8213755: Let nmethods be is_unloading() outside of safepoints
eosterlund
parents: 52448
diff changeset
    65
  if(iter.next()) {
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    66
    _first_nmethod = iter.method();
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    67
  }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    68
  _claimed_nmethod = _first_nmethod;
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    69
}
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    70
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    71
CodeCacheUnloadingTask::~CodeCacheUnloadingTask() {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    72
  CodeCache::verify_clean_inline_caches();
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    73
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    74
  guarantee(CodeCache::scavenge_root_nmethods() == NULL, "Must be");
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    75
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    76
  CodeCache::verify_icholder_relocations();
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    77
}
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    78
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    79
void CodeCacheUnloadingTask::claim_nmethods(CompiledMethod** claimed_nmethods, int *num_claimed_nmethods) {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    80
  CompiledMethod* first;
52661
4f45c682eab0 8213755: Let nmethods be is_unloading() outside of safepoints
eosterlund
parents: 52448
diff changeset
    81
  CompiledMethodIterator last(CompiledMethodIterator::only_alive);
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    82
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    83
  do {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    84
    *num_claimed_nmethods = 0;
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    85
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    86
    first = _claimed_nmethod;
52661
4f45c682eab0 8213755: Let nmethods be is_unloading() outside of safepoints
eosterlund
parents: 52448
diff changeset
    87
    last = CompiledMethodIterator(CompiledMethodIterator::only_alive, first);
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    88
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    89
    if (first != NULL) {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    90
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    91
      for (int i = 0; i < MaxClaimNmethods; i++) {
52661
4f45c682eab0 8213755: Let nmethods be is_unloading() outside of safepoints
eosterlund
parents: 52448
diff changeset
    92
        if (!last.next()) {
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    93
          break;
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    94
        }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    95
        claimed_nmethods[i] = last.method();
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    96
        (*num_claimed_nmethods)++;
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    97
      }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    98
    }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
    99
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   100
  } while (Atomic::cmpxchg(last.method(), &_claimed_nmethod, first) != first);
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   101
}
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   102
52385
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents: 51537
diff changeset
   103
void CodeCacheUnloadingTask::work(uint worker_id) {
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   104
  // The first nmethods is claimed by the first worker.
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   105
  if (worker_id == 0 && _first_nmethod != NULL) {
52385
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents: 51537
diff changeset
   106
    _first_nmethod->do_unloading(_unloading_occurred);
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   107
    _first_nmethod = NULL;
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   108
  }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   109
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   110
  int num_claimed_nmethods;
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   111
  CompiledMethod* claimed_nmethods[MaxClaimNmethods];
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   112
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   113
  while (true) {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   114
    claim_nmethods(claimed_nmethods, &num_claimed_nmethods);
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   115
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   116
    if (num_claimed_nmethods == 0) {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   117
      break;
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   118
    }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   119
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   120
    for (int i = 0; i < num_claimed_nmethods; i++) {
52385
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents: 51537
diff changeset
   121
      claimed_nmethods[i]->do_unloading(_unloading_occurred);
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   122
    }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   123
  }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   124
}
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   125
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   126
KlassCleaningTask::KlassCleaningTask() :
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   127
  _clean_klass_tree_claimed(0),
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   128
  _klass_iterator() {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   129
}
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   130
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   131
bool KlassCleaningTask::claim_clean_klass_tree_task() {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   132
  if (_clean_klass_tree_claimed) {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   133
    return false;
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   134
  }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   135
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   136
  return Atomic::cmpxchg(1, &_clean_klass_tree_claimed, 0) == 0;
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   137
}
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   138
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   139
InstanceKlass* KlassCleaningTask::claim_next_klass() {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   140
  Klass* klass;
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   141
  do {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   142
    klass =_klass_iterator.next_klass();
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   143
  } while (klass != NULL && !klass->is_instance_klass());
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   144
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   145
  // this can be null so don't call InstanceKlass::cast
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   146
  return static_cast<InstanceKlass*>(klass);
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   147
}
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   148
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   149
void KlassCleaningTask::work() {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   150
  ResourceMark rm;
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   151
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   152
  // One worker will clean the subklass/sibling klass tree.
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   153
  if (claim_clean_klass_tree_task()) {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   154
    Klass::clean_subklass_tree();
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   155
  }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   156
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   157
  // All workers will help cleaning the classes,
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   158
  InstanceKlass* klass;
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   159
  while ((klass = claim_next_klass()) != NULL) {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   160
    clean_klass(klass);
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   161
  }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   162
}
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   163
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   164
ParallelCleaningTask::ParallelCleaningTask(BoolObjectClosure* is_alive,
53536
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
   165
                                           uint num_workers,
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
   166
                                           bool unloading_occurred,
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
   167
                                           bool resize_dedup_table) :
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   168
  AbstractGangTask("Parallel Cleaning"),
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   169
  _unloading_occurred(unloading_occurred),
53536
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
   170
  _string_dedup_task(is_alive, NULL, resize_dedup_table),
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   171
  _code_cache_task(num_workers, is_alive, unloading_occurred),
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   172
  _klass_cleaning_task() {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   173
}
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   174
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   175
// The parallel work done by all worker threads.
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   176
void ParallelCleaningTask::work(uint worker_id) {
52385
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents: 51537
diff changeset
   177
  // Do first pass of code cache cleaning.
5c679ec60888 8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents: 51537
diff changeset
   178
  _code_cache_task.work(worker_id);
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   179
53536
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
   180
  // Clean the string dedup data structures.
482109fae02b 8213229: Investigate treating StringTable as weak in young collections
tschatzl
parents: 52661
diff changeset
   181
  _string_dedup_task.work(worker_id);
51524
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   182
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   183
  // Clean all klasses that were not unloaded.
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   184
  // The weak metadata in klass doesn't need to be
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   185
  // processed if there was no unloading.
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   186
  if (_unloading_occurred) {
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   187
    _klass_cleaning_task.work();
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   188
  }
9d01ad46daef 8209841: [REDO] Refactor G1ParallelCleaningTask into shared
zgu
parents:
diff changeset
   189
}