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 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_SPACE_INLINE_HPP
26 #define SHARE_VM_GC_SHARED_SPACE_INLINE_HPP
27
28 #include "gc/shared/blockOffsetTable.inline.hpp"
29 #include "gc/shared/collectedHeap.hpp"
30 #include "gc/shared/generation.hpp"
31 #include "gc/shared/space.hpp"
32 #include "gc/shared/spaceDecorator.hpp"
33 #include "memory/universe.hpp"
34 #include "oops/oopsHierarchy.hpp"
35 #include "oops/oop.inline.hpp"
36 #include "runtime/prefetch.inline.hpp"
37 #include "runtime/safepoint.hpp"
38 #if INCLUDE_SERIALGC
39 #include "gc/serial/markSweep.inline.hpp"
40 #endif
41
42 inline HeapWord* Space::block_start(const void* p) {
43 return block_start_const(p);
44 }
45
46 inline HeapWord* OffsetTableContigSpace::allocate(size_t size) {
47 HeapWord* res = ContiguousSpace::allocate(size);
48 if (res != NULL) {
49 _offsets.alloc_block(res, size);
99 // we don't start compacting before there is a significant gain to be made.
100 // Occasionally, we want to ensure a full compaction, which is determined
101 // by the MarkSweepAlwaysCompactCount parameter.
102 if ((MarkSweep::total_invocations() % MarkSweepAlwaysCompactCount) != 0) {
103 _allowed_deadspace_words = (space->capacity() * ratio / 100) / HeapWordSize;
104 } else {
105 _active = false;
106 }
107 }
108 }
109
110
111 bool insert_deadspace(HeapWord* dead_start, HeapWord* dead_end) {
112 if (!_active) {
113 return false;
114 }
115
116 size_t dead_length = pointer_delta(dead_end, dead_start);
117 if (_allowed_deadspace_words >= dead_length) {
118 _allowed_deadspace_words -= dead_length;
119 CollectedHeap::fill_with_object(dead_start, dead_length);
120 oop obj = oop(dead_start);
121 obj->set_mark_raw(obj->mark_raw()->set_marked());
122
123 assert(dead_length == (size_t)obj->size(), "bad filler object size");
124 log_develop_trace(gc, compaction)("Inserting object to dead space: " PTR_FORMAT ", " PTR_FORMAT ", " SIZE_FORMAT "b",
125 p2i(dead_start), p2i(dead_end), dead_length * HeapWordSize);
126
127 return true;
128 } else {
129 _active = false;
130 return false;
131 }
132 }
133
134 };
135
136 template <class SpaceType>
137 inline void CompactibleSpace::scan_and_forward(SpaceType* space, CompactPoint* cp) {
138 // Compute the new addresses for the live objects and store it in the mark
139 // Used by universe::mark_sweep_phase2()
|
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 *
23 */
24
25 #ifndef SHARE_VM_GC_SHARED_SPACE_INLINE_HPP
26 #define SHARE_VM_GC_SHARED_SPACE_INLINE_HPP
27
28 #include "gc/shared/blockOffsetTable.inline.hpp"
29 #include "gc/shared/collectedHeap.hpp"
30 #include "gc/shared/fill.hpp"
31 #include "gc/shared/generation.hpp"
32 #include "gc/shared/space.hpp"
33 #include "gc/shared/spaceDecorator.hpp"
34 #include "memory/universe.hpp"
35 #include "oops/oopsHierarchy.hpp"
36 #include "oops/oop.inline.hpp"
37 #include "runtime/prefetch.inline.hpp"
38 #include "runtime/safepoint.hpp"
39 #if INCLUDE_SERIALGC
40 #include "gc/serial/markSweep.inline.hpp"
41 #endif
42
43 inline HeapWord* Space::block_start(const void* p) {
44 return block_start_const(p);
45 }
46
47 inline HeapWord* OffsetTableContigSpace::allocate(size_t size) {
48 HeapWord* res = ContiguousSpace::allocate(size);
49 if (res != NULL) {
50 _offsets.alloc_block(res, size);
100 // we don't start compacting before there is a significant gain to be made.
101 // Occasionally, we want to ensure a full compaction, which is determined
102 // by the MarkSweepAlwaysCompactCount parameter.
103 if ((MarkSweep::total_invocations() % MarkSweepAlwaysCompactCount) != 0) {
104 _allowed_deadspace_words = (space->capacity() * ratio / 100) / HeapWordSize;
105 } else {
106 _active = false;
107 }
108 }
109 }
110
111
112 bool insert_deadspace(HeapWord* dead_start, HeapWord* dead_end) {
113 if (!_active) {
114 return false;
115 }
116
117 size_t dead_length = pointer_delta(dead_end, dead_start);
118 if (_allowed_deadspace_words >= dead_length) {
119 _allowed_deadspace_words -= dead_length;
120 Fill::range(dead_start, dead_length);
121 oop obj = oop(dead_start);
122 obj->set_mark_raw(obj->mark_raw()->set_marked());
123
124 assert(dead_length == (size_t)obj->size(), "bad filler object size");
125 log_develop_trace(gc, compaction)("Inserting object to dead space: " PTR_FORMAT ", " PTR_FORMAT ", " SIZE_FORMAT "b",
126 p2i(dead_start), p2i(dead_end), dead_length * HeapWordSize);
127
128 return true;
129 } else {
130 _active = false;
131 return false;
132 }
133 }
134
135 };
136
137 template <class SpaceType>
138 inline void CompactibleSpace::scan_and_forward(SpaceType* space, CompactPoint* cp) {
139 // Compute the new addresses for the live objects and store it in the mark
140 // Used by universe::mark_sweep_phase2()
|