src/hotspot/share/gc/shared/preservedMarks.inline.hpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 57812 9bb28ccc6106
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
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
/*
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 47216
diff changeset
     2
 * Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved.
36202
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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49982
diff changeset
    25
#ifndef SHARE_GC_SHARED_PRESERVEDMARKS_INLINE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49982
diff changeset
    26
#define SHARE_GC_SHARED_PRESERVEDMARKS_INLINE_HPP
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    27
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    28
#include "gc/shared/preservedMarks.hpp"
49982
9042ffe5b7fe 8200729: Conditional compilation of GCs
stefank
parents: 49722
diff changeset
    29
#include "logging/log.hpp"
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    30
#include "oops/oop.inline.hpp"
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    31
#include "utilities/stack.inline.hpp"
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    32
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    33
inline bool PreservedMarks::should_preserve_mark(oop obj, markWord m) const {
57812
9bb28ccc6106 8229839: Break circular dependency between oop.inline.hpp and markWord.inline.hpp
stefank
parents: 57777
diff changeset
    34
  return obj->mark_must_be_preserved_for_promotion_failure(m);
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    35
}
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    36
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    37
inline void PreservedMarks::push(oop obj, markWord m) {
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    38
  assert(should_preserve_mark(obj, m), "pre-condition");
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    39
  OopAndMarkWord elem(obj, m);
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    40
  _stack.push(elem);
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    41
}
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    42
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    43
inline void PreservedMarks::push_if_necessary(oop obj, markWord m) {
36202
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    44
  if (should_preserve_mark(obj, m)) {
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    45
    push(obj, m);
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    46
  }
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    47
}
219f8808c3bd 8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff changeset
    48
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    49
inline void PreservedMarks::init_forwarded_mark(oop obj) {
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 47216
diff changeset
    50
  obj->init_mark_raw();
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    51
}
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    52
39228
32ce84798166 8156032: Clean up parallel GC specific code from vm/gc/shared/preservedMarks.cpp
lmesnik
parents: 37422
diff changeset
    53
inline void PreservedMarksSet::restore(RestorePreservedMarksTaskExecutor* executor) {
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    54
  volatile size_t total_size = 0;
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    55
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    56
#ifdef ASSERT
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    57
  // This is to make sure the total_size we'll calculate below is correct.
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    58
  size_t total_size_before = 0;
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    59
  for (uint i = 0; i < _num; i += 1) {
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    60
    total_size_before += get(i)->size();
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    61
  }
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    62
#endif // def ASSERT
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    63
39228
32ce84798166 8156032: Clean up parallel GC specific code from vm/gc/shared/preservedMarks.cpp
lmesnik
parents: 37422
diff changeset
    64
  executor->restore(this, &total_size);
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    65
  assert_empty();
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    66
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    67
  assert(total_size == total_size_before,
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    68
         "total_size = " SIZE_FORMAT " before = " SIZE_FORMAT,
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    69
         total_size, total_size_before);
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    70
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    71
  log_trace(gc)("Restored " SIZE_FORMAT " marks", total_size);
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    72
}
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    73
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    74
inline PreservedMarks::PreservedMarks()
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    75
    : _stack(OopAndMarkWordStack::default_segment_size(),
37422
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    76
             // This stack should be used very infrequently so there's
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    77
             // no point in caching stack segments (there will be a
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    78
             // waste of space most of the time). So we set the max
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    79
             // cache size to 0.
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    80
             0 /* max_cache_size */) { }
8a7443b5edf8 8152312: ParNew: Restore preserved marks in parallel
tonyp
parents: 36202
diff changeset
    81
57777
90ead0febf56 8229258: Rework markOop and markOopDesc into a simpler mark word value carrier
stefank
parents: 53244
diff changeset
    82
void PreservedMarks::OopAndMarkWord::set_mark() const {
49722
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 47216
diff changeset
    83
  _o->set_mark_raw(_m);
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 47216
diff changeset
    84
}
a47d1e21b3f1 8199735: Mark word updates need to use Access API
rkennke
parents: 47216
diff changeset
    85
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49982
diff changeset
    86
#endif // SHARE_GC_SHARED_PRESERVEDMARKS_INLINE_HPP