1 /*
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
29 #include "oops/oop.inline.hpp"
30 #include "utilities/stack.inline.hpp"
31
32 inline bool PreservedMarks::should_preserve_mark(oop obj, markOop m) const {
33 return m->must_be_preserved_for_promotion_failure(obj);
34 }
35
36 inline void PreservedMarks::push(oop obj, markOop m) {
37 assert(should_preserve_mark(obj, m), "pre-condition");
38 OopAndMarkOop elem(obj, m);
39 _stack.push(elem);
40 }
41
42 inline void PreservedMarks::push_if_necessary(oop obj, markOop m) {
43 if (should_preserve_mark(obj, m)) {
44 push(obj, m);
45 }
46 }
47
48 inline void PreservedMarks::init_forwarded_mark(oop obj) {
49 obj->init_mark();
50 }
51
52 inline void PreservedMarksSet::restore(RestorePreservedMarksTaskExecutor* executor) {
53 volatile size_t total_size = 0;
54
55 #ifdef ASSERT
56 // This is to make sure the total_size we'll calculate below is correct.
57 size_t total_size_before = 0;
58 for (uint i = 0; i < _num; i += 1) {
59 total_size_before += get(i)->size();
60 }
61 #endif // def ASSERT
62
63 executor->restore(this, &total_size);
64 assert_empty();
65
66 assert(total_size == total_size_before,
67 "total_size = " SIZE_FORMAT " before = " SIZE_FORMAT,
68 total_size, total_size_before);
69
70 log_trace(gc)("Restored " SIZE_FORMAT " marks", total_size);
71 }
72
73 inline PreservedMarks::PreservedMarks()
74 : _stack(OopAndMarkOopStack::default_segment_size(),
75 // This stack should be used very infrequently so there's
76 // no point in caching stack segments (there will be a
77 // waste of space most of the time). So we set the max
78 // cache size to 0.
79 0 /* max_cache_size */) { }
80
81 #endif // SHARE_VM_GC_SHARED_PRESERVEDMARKS_INLINE_HPP
|
1 /*
2 * Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
29 #include "oops/oop.inline.hpp"
30 #include "utilities/stack.inline.hpp"
31
32 inline bool PreservedMarks::should_preserve_mark(oop obj, markOop m) const {
33 return m->must_be_preserved_for_promotion_failure(obj);
34 }
35
36 inline void PreservedMarks::push(oop obj, markOop m) {
37 assert(should_preserve_mark(obj, m), "pre-condition");
38 OopAndMarkOop elem(obj, m);
39 _stack.push(elem);
40 }
41
42 inline void PreservedMarks::push_if_necessary(oop obj, markOop m) {
43 if (should_preserve_mark(obj, m)) {
44 push(obj, m);
45 }
46 }
47
48 inline void PreservedMarks::init_forwarded_mark(oop obj) {
49 obj->init_mark_raw();
50 }
51
52 inline void PreservedMarksSet::restore(RestorePreservedMarksTaskExecutor* executor) {
53 volatile size_t total_size = 0;
54
55 #ifdef ASSERT
56 // This is to make sure the total_size we'll calculate below is correct.
57 size_t total_size_before = 0;
58 for (uint i = 0; i < _num; i += 1) {
59 total_size_before += get(i)->size();
60 }
61 #endif // def ASSERT
62
63 executor->restore(this, &total_size);
64 assert_empty();
65
66 assert(total_size == total_size_before,
67 "total_size = " SIZE_FORMAT " before = " SIZE_FORMAT,
68 total_size, total_size_before);
69
70 log_trace(gc)("Restored " SIZE_FORMAT " marks", total_size);
71 }
72
73 inline PreservedMarks::PreservedMarks()
74 : _stack(OopAndMarkOopStack::default_segment_size(),
75 // This stack should be used very infrequently so there's
76 // no point in caching stack segments (there will be a
77 // waste of space most of the time). So we set the max
78 // cache size to 0.
79 0 /* max_cache_size */) { }
80
81 void PreservedMarks::OopAndMarkOop::set_mark() const {
82 _o->set_mark_raw(_m);
83 }
84
85 #endif // SHARE_VM_GC_SHARED_PRESERVEDMARKS_INLINE_HPP
|