--- a/src/hotspot/share/runtime/vmThread.cpp Thu Mar 15 21:29:36 2018 +0100
+++ b/src/hotspot/share/runtime/vmThread.cpp Fri Mar 23 18:54:12 2018 +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();