mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
4396719: Mark Sweep stack overflow on deeply nested Object arrays
Use an explicit stack for object arrays and process them in chunks. Reviewed-by: iveresov, apetrusenko
This commit is contained in:
parent
5fdec09798
commit
4f82340476
26 changed files with 419 additions and 182 deletions
|
@ -25,8 +25,9 @@
|
|||
#include "incls/_precompiled.incl"
|
||||
#include "incls/_markSweep.cpp.incl"
|
||||
|
||||
GrowableArray<oop>* MarkSweep::_marking_stack = NULL;
|
||||
GrowableArray<Klass*>* MarkSweep::_revisit_klass_stack = NULL;
|
||||
GrowableArray<oop>* MarkSweep::_marking_stack = NULL;
|
||||
GrowableArray<ObjArrayTask>* MarkSweep::_objarray_stack = NULL;
|
||||
GrowableArray<Klass*>* MarkSweep::_revisit_klass_stack = NULL;
|
||||
GrowableArray<DataLayout*>* MarkSweep::_revisit_mdo_stack = NULL;
|
||||
|
||||
GrowableArray<oop>* MarkSweep::_preserved_oop_stack = NULL;
|
||||
|
@ -104,11 +105,18 @@ void MarkSweep::MarkAndPushClosure::do_oop(oop* p) { mark_and_push(p); }
|
|||
void MarkSweep::MarkAndPushClosure::do_oop(narrowOop* p) { mark_and_push(p); }
|
||||
|
||||
void MarkSweep::follow_stack() {
|
||||
while (!_marking_stack->is_empty()) {
|
||||
oop obj = _marking_stack->pop();
|
||||
assert (obj->is_gc_marked(), "p must be marked");
|
||||
obj->follow_contents();
|
||||
}
|
||||
do {
|
||||
while (!_marking_stack->is_empty()) {
|
||||
oop obj = _marking_stack->pop();
|
||||
assert (obj->is_gc_marked(), "p must be marked");
|
||||
obj->follow_contents();
|
||||
}
|
||||
while (!_objarray_stack->is_empty()) {
|
||||
ObjArrayTask task = _objarray_stack->pop();
|
||||
objArrayKlass* const k = (objArrayKlass*)task.obj()->blueprint();
|
||||
k->oop_follow_contents(task.obj(), task.index());
|
||||
}
|
||||
} while (!_marking_stack->is_empty() || !_objarray_stack->is_empty());
|
||||
}
|
||||
|
||||
MarkSweep::FollowStackClosure MarkSweep::follow_stack_closure;
|
||||
|
|
|
@ -110,8 +110,9 @@ class MarkSweep : AllStatic {
|
|||
// Vars
|
||||
//
|
||||
protected:
|
||||
// Traversal stack used during phase1
|
||||
// Traversal stacks used during phase1
|
||||
static GrowableArray<oop>* _marking_stack;
|
||||
static GrowableArray<ObjArrayTask>* _objarray_stack;
|
||||
// Stack for live klasses to revisit at end of marking phase
|
||||
static GrowableArray<Klass*>* _revisit_klass_stack;
|
||||
// Set (stack) of MDO's to revisit at end of marking phase
|
||||
|
@ -188,6 +189,7 @@ class MarkSweep : AllStatic {
|
|||
template <class T> static inline void mark_and_follow(T* p);
|
||||
// Check mark and maybe push on marking stack
|
||||
template <class T> static inline void mark_and_push(T* p);
|
||||
static inline void push_objarray(oop obj, size_t index);
|
||||
|
||||
static void follow_stack(); // Empty marking stack.
|
||||
|
||||
|
|
|
@ -77,6 +77,12 @@ template <class T> inline void MarkSweep::mark_and_push(T* p) {
|
|||
}
|
||||
}
|
||||
|
||||
void MarkSweep::push_objarray(oop obj, size_t index) {
|
||||
ObjArrayTask task(obj, index);
|
||||
assert(task.is_valid(), "bad ObjArrayTask");
|
||||
_objarray_stack->push(task);
|
||||
}
|
||||
|
||||
template <class T> inline void MarkSweep::adjust_pointer(T* p, bool isroot) {
|
||||
T heap_oop = oopDesc::load_heap_oop(p);
|
||||
if (!oopDesc::is_null(heap_oop)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue