hotspot/src/share/vm/gc/shared/preservedMarks.cpp
author tonyp
Tue, 26 Apr 2016 10:19:57 +0200
changeset 38080 bb02a3ad3b0a
parent 37422 8a7443b5edf8
child 38187 f1879f6d7e63
permissions -rw-r--r--
8154153: PS: Restore preserved marks in parallel Summary: Restore preserved marks after evacuation failure in parallel using the PreservedMark infrastructure. Reviewed-by: tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
     1
/*
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
     4
 *
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
     8
 *
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    13
 * accompanied this code).
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    14
 *
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    18
 *
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    21
 * questions.
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    22
 *
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    23
 */
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    24
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    25
#include "precompiled.hpp"
38080
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
    26
#include "gc/parallel/gcTaskManager.hpp"
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    27
#include "gc/shared/preservedMarks.inline.hpp"
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    28
#include "gc/shared/workgroup.hpp"
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    29
#include "memory/allocation.inline.hpp"
38080
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
    30
#include "memory/resourceArea.hpp"
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    31
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    32
void PreservedMarks::restore() {
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    33
  while (!_stack.is_empty()) {
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    34
    const OopAndMarkOop elem = _stack.pop();
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    35
    elem.set_mark();
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    36
  }
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    37
  assert_empty();
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    38
}
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    39
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    40
#ifndef PRODUCT
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    41
void PreservedMarks::assert_empty() {
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    42
  assert(_stack.is_empty(), "stack expected to be empty, size = "SIZE_FORMAT,
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    43
         _stack.size());
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    44
  assert(_stack.cache_size() == 0,
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    45
         "stack expected to have no cached segments, cache size = "SIZE_FORMAT,
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    46
         _stack.cache_size());
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    47
}
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    48
#endif // ndef PRODUCT
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    49
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    50
void RemoveForwardedPointerClosure::do_object(oop obj) {
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    51
  if (obj->is_forwarded()) {
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    52
    PreservedMarks::init_forwarded_mark(obj);
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    53
  }
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    54
}
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    55
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    56
void PreservedMarksSet::init(uint num) {
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    57
  assert(_stacks == NULL && _num == 0, "do not re-initialize");
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    58
  assert(num > 0, "pre-condition");
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    59
  if (_in_c_heap) {
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    60
    _stacks = NEW_C_HEAP_ARRAY(Padded<PreservedMarks>, num, mtGC);
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    61
  } else {
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    62
    _stacks = NEW_RESOURCE_ARRAY(Padded<PreservedMarks>, num);
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    63
  }
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    64
  for (uint i = 0; i < num; i += 1) {
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    65
    ::new (_stacks + i) PreservedMarks();
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    66
  }
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    67
  _num = num;
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    68
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    69
  assert_empty();
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    70
}
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    71
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    72
class ParRestoreTask : public AbstractGangTask {
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    73
private:
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    74
  PreservedMarksSet* const _preserved_marks_set;
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    75
  SequentialSubTasksDone _sub_tasks;
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    76
  volatile size_t* const _total_size_addr;
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    77
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    78
public:
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    79
  virtual void work(uint worker_id) {
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    80
    uint task_id = 0;
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    81
    while (!_sub_tasks.is_task_claimed(/* reference */ task_id)) {
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    82
      PreservedMarks* const preserved_marks = _preserved_marks_set->get(task_id);
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    83
      const size_t size = preserved_marks->size();
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    84
      preserved_marks->restore();
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    85
      // Only do the atomic add if the size is > 0.
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    86
      if (size > 0) {
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    87
        Atomic::add(size, _total_size_addr);
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    88
      }
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    89
    }
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    90
    _sub_tasks.all_tasks_completed();
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    91
  }
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    92
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    93
  ParRestoreTask(uint worker_num,
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    94
                 PreservedMarksSet* preserved_marks_set,
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    95
                 volatile size_t* total_size_addr)
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    96
      : AbstractGangTask("Parallel Preserved Mark Restoration"),
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    97
        _preserved_marks_set(preserved_marks_set),
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    98
        _total_size_addr(total_size_addr) {
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
    99
    _sub_tasks.set_n_threads(worker_num);
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
   100
    _sub_tasks.set_n_tasks(preserved_marks_set->num());
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
   101
  }
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
   102
};
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
   103
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
   104
void PreservedMarksSet::restore_internal(WorkGang* workers,
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
   105
                                         volatile size_t* total_size_addr) {
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
   106
  assert(workers != NULL, "pre-condition");
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
   107
  ParRestoreTask task(workers->active_workers(), this, total_size_addr);
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
   108
  workers->run_task(&task);
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
   109
}
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
   110
38080
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   111
class ParRestoreGCTask : public GCTask {
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   112
private:
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   113
  const uint _id;
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   114
  PreservedMarksSet* const _preserved_marks_set;
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   115
  volatile size_t* const _total_size_addr;
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   116
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   117
public:
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   118
  virtual char* name() { return (char*) "preserved mark restoration task"; }
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   119
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   120
  virtual void do_it(GCTaskManager* manager, uint which) {
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   121
    PreservedMarks* const preserved_marks = _preserved_marks_set->get(_id);
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   122
    const size_t size = preserved_marks->size();
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   123
    preserved_marks->restore();
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   124
    // Only do the atomic add if the size is > 0.
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   125
    if (size > 0) {
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   126
      Atomic::add(size, _total_size_addr);
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   127
    }
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   128
  }
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   129
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   130
  ParRestoreGCTask(uint id,
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   131
                   PreservedMarksSet* preserved_marks_set,
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   132
                   volatile size_t* total_size_addr)
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   133
    : _id(id),
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   134
      _preserved_marks_set(preserved_marks_set),
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   135
      _total_size_addr(total_size_addr) { }
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   136
};
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   137
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   138
void PreservedMarksSet::restore_internal(GCTaskManager* gc_task_manager,
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   139
                                         volatile size_t* total_size_addr) {
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   140
  // GCTask / GCTaskQueue are ResourceObjs
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   141
  ResourceMark rm;
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   142
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   143
  GCTaskQueue* q = GCTaskQueue::create();
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   144
  for (uint i = 0; i < num(); i += 1) {
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   145
    q->enqueue(new ParRestoreGCTask(i, this, total_size_addr));
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   146
  }
bb02a3ad3b0a 8154153: PS: Restore preserved marks in parallel
tonyp
parents: 37422
diff changeset
   147
  gc_task_manager->execute_and_wait(q);
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   148
}
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   149
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   150
void PreservedMarksSet::reclaim() {
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   151
  assert_empty();
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   152
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   153
  for (uint i = 0; i < _num; i += 1) {
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   154
    _stacks[i].~Padded<PreservedMarks>();
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   155
  }
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   156
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   157
  if (_in_c_heap) {
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   158
    FREE_C_HEAP_ARRAY(Padded<PreservedMarks>, _stacks);
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   159
  } else {
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   160
    // the array was resource-allocated, so nothing to do
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   161
  }
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   162
  _stacks = NULL;
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   163
  _num = 0;
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   164
}
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   165
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   166
#ifndef PRODUCT
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   167
void PreservedMarksSet::assert_empty() {
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   168
  assert(_stacks != NULL && _num > 0, "should have been initialized");
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   169
  for (uint i = 0; i < _num; i += 1) {
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 37045
diff changeset
   170
    get(i)->assert_empty();
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   171
  }
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   172
}
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
   173
#endif // ndef PRODUCT