--- old/src/hotspot/share/runtime/vmThread.cpp 2018-03-22 17:04:17.144829989 +0100 +++ new/src/hotspot/share/runtime/vmThread.cpp 2018-03-22 17:04:16.944829996 +0100 @@ -576,6 +576,31 @@ } } +// A SkipGCALot object is used to elide the usual effect of gc-a-lot +// over a section of execution by a thread. Currently, it's used only to +// prevent re-entrant calls to GC. +class SkipGCALot : public StackObj { + private: + bool _saved; + Thread* _t; + + public: +#ifdef ASSERT + SkipGCALot(Thread* t) : _t(t) { + _saved = _t->skip_gcalot(); + _t->set_skip_gcalot(true); + } + + ~SkipGCALot() { + assert(_t->skip_gcalot(), "Save-restore protocol invariant"); + _t->set_skip_gcalot(_saved); + } +#else + SkipGCALot(Thread* t) { } + ~SkipGCALot() { } +#endif +}; + void VMThread::execute(VM_Operation* op) { Thread* t = Thread::current();