author | sjohanss |
Thu, 21 Sep 2017 14:32:05 +0200 | |
changeset 47546 | 64ba55ba8516 |
parent 47216 | 71c04702a3d5 |
child 49722 | a47d1e21b3f1 |
permissions | -rw-r--r-- |
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 |
#ifndef SHARE_VM_GC_SHARED_PRESERVEDMARKS_INLINE_HPP |
219f8808c3bd
8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff
changeset
|
26 |
#define SHARE_VM_GC_SHARED_PRESERVEDMARKS_INLINE_HPP |
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" |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
29 |
#include "oops/oop.inline.hpp" |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
30 |
#include "utilities/stack.inline.hpp" |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
31 |
|
36202
219f8808c3bd
8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff
changeset
|
32 |
inline bool PreservedMarks::should_preserve_mark(oop obj, markOop m) const { |
219f8808c3bd
8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff
changeset
|
33 |
return m->must_be_preserved_for_promotion_failure(obj); |
219f8808c3bd
8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff
changeset
|
34 |
} |
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 |
inline void PreservedMarks::push(oop obj, markOop m) { |
219f8808c3bd
8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff
changeset
|
37 |
assert(should_preserve_mark(obj, m), "pre-condition"); |
219f8808c3bd
8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff
changeset
|
38 |
OopAndMarkOop elem(obj, m); |
219f8808c3bd
8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff
changeset
|
39 |
_stack.push(elem); |
219f8808c3bd
8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff
changeset
|
40 |
} |
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 |
inline void PreservedMarks::push_if_necessary(oop obj, markOop m) { |
219f8808c3bd
8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff
changeset
|
43 |
if (should_preserve_mark(obj, m)) { |
219f8808c3bd
8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff
changeset
|
44 |
push(obj, m); |
219f8808c3bd
8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff
changeset
|
45 |
} |
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 |
|
37422
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
48 |
inline void PreservedMarks::init_forwarded_mark(oop obj) { |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
49 |
obj->init_mark(); |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
50 |
} |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
51 |
|
39228
32ce84798166
8156032: Clean up parallel GC specific code from vm/gc/shared/preservedMarks.cpp
lmesnik
parents:
37422
diff
changeset
|
52 |
inline void PreservedMarksSet::restore(RestorePreservedMarksTaskExecutor* executor) { |
37422
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
53 |
volatile size_t total_size = 0; |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
54 |
|
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
55 |
#ifdef ASSERT |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
56 |
// 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
|
57 |
size_t total_size_before = 0; |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
58 |
for (uint i = 0; i < _num; i += 1) { |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
59 |
total_size_before += get(i)->size(); |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
60 |
} |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
61 |
#endif // def ASSERT |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
62 |
|
39228
32ce84798166
8156032: Clean up parallel GC specific code from vm/gc/shared/preservedMarks.cpp
lmesnik
parents:
37422
diff
changeset
|
63 |
executor->restore(this, &total_size); |
37422
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
64 |
assert_empty(); |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
65 |
|
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
66 |
assert(total_size == total_size_before, |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
67 |
"total_size = " SIZE_FORMAT " before = " SIZE_FORMAT, |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
68 |
total_size, total_size_before); |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
69 |
|
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
70 |
log_trace(gc)("Restored " SIZE_FORMAT " marks", total_size); |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
71 |
} |
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 |
inline PreservedMarks::PreservedMarks() |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
74 |
: _stack(OopAndMarkOopStack::default_segment_size(), |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
75 |
// This stack should be used very infrequently so there's |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
76 |
// no point in caching stack segments (there will be a |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
77 |
// 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
|
78 |
// cache size to 0. |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
79 |
0 /* max_cache_size */) { } |
8a7443b5edf8
8152312: ParNew: Restore preserved marks in parallel
tonyp
parents:
36202
diff
changeset
|
80 |
|
36202
219f8808c3bd
8146989: Introduce per-worker preserved mark stacks in ParNew
tonyp
parents:
diff
changeset
|
81 |
#endif // SHARE_VM_GC_SHARED_PRESERVEDMARKS_INLINE_HPP |