< prev index next >
src/hotspot/share/runtime/vmThread.cpp
Print this page
@@ -574,10 +574,35 @@
SafepointSynchronize::end();
}
}
}
+// 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();
if (!t->is_VM_thread()) {
SkipGCALot sgcalot(t); // avoid re-entrant attempts to gc-a-lot
< prev index next >