|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -91,20 +91,12 @@ inline bool G1FullGCMarker::is_empty() {
|
91 | 91 | return _oop_stack.is_empty() && _objarray_stack.is_empty();
|
92 | 92 | }
|
93 | 93 |
|
94 |
| -inline bool G1FullGCMarker::pop_object(oop& oop) { |
95 |
| - return _oop_stack.pop_overflow(oop) || _oop_stack.pop_local(oop); |
96 |
| -} |
97 |
| - |
98 | 94 | inline void G1FullGCMarker::push_objarray(oop obj, size_t index) {
|
99 | 95 | ObjArrayTask task(obj, index);
|
100 | 96 | assert(task.is_valid(), "bad ObjArrayTask");
|
101 | 97 | _objarray_stack.push(task);
|
102 | 98 | }
|
103 | 99 |
|
104 |
| -inline bool G1FullGCMarker::pop_objarray(ObjArrayTask& arr) { |
105 |
| - return _objarray_stack.pop_overflow(arr) || _objarray_stack.pop_local(arr); |
106 |
| -} |
107 |
| - |
108 | 100 | inline void G1FullGCMarker::follow_array(objArrayOop array) {
|
109 | 101 | follow_klass(array->klass());
|
110 | 102 | // Don't push empty arrays to avoid unnecessary work.
|
@@ -159,16 +151,40 @@ inline void G1FullGCMarker::follow_object(oop obj) {
|
159 | 151 | }
|
160 | 152 | }
|
161 | 153 |
|
162 |
| -void G1FullGCMarker::drain_stack() { |
163 |
| - do { |
164 |
| - oop obj; |
165 |
| - while (pop_object(obj)) { |
| 154 | +inline void G1FullGCMarker::drain_oop_stack() { |
| 155 | + oop obj; |
| 156 | + while (_oop_stack.pop_overflow(obj)) { |
| 157 | + if (!_oop_stack.try_push_to_taskqueue(obj)) { |
166 | 158 | assert(_bitmap->is_marked(obj), "must be marked");
|
167 | 159 | follow_object(obj);
|
168 | 160 | }
|
169 |
| - // Process ObjArrays one at a time to avoid marking stack bloat. |
| 161 | + } |
| 162 | + while (_oop_stack.pop_local(obj)) { |
| 163 | + assert(_bitmap->is_marked(obj), "must be marked"); |
| 164 | + follow_object(obj); |
| 165 | + } |
| 166 | +} |
| 167 | + |
| 168 | +inline bool G1FullGCMarker::transfer_objArray_overflow_stack(ObjArrayTask& task) { |
| 169 | + // It is desirable to move as much as possible work from the overflow queue to |
| 170 | + // the shared queue as quickly as possible. |
| 171 | + while (_objarray_stack.pop_overflow(task)) { |
| 172 | + if (!_objarray_stack.try_push_to_taskqueue(task)) { |
| 173 | + return true; |
| 174 | + } |
| 175 | + } |
| 176 | + return false; |
| 177 | +} |
| 178 | + |
| 179 | +void G1FullGCMarker::drain_stack() { |
| 180 | + do { |
| 181 | + // First, drain regular oop stack. |
| 182 | + drain_oop_stack(); |
| 183 | + |
| 184 | + // Then process ObjArrays one at a time to avoid marking stack bloat. |
170 | 185 | ObjArrayTask task;
|
171 |
| - if (pop_objarray(task)) { |
| 186 | + if (transfer_objArray_overflow_stack(task) || |
| 187 | + _objarray_stack.pop_local(task)) { |
172 | 188 | follow_array_chunk(objArrayOop(task.obj()), task.index());
|
173 | 189 | }
|
174 | 190 | } while (!is_empty());
|
|
0 commit comments