src/share/vm/memory/gcLocker.hpp

changeset 1241
821269eca479
parent 631
d1605aabd0a1
child 1279
bd02caa94611
     1.1 --- a/src/share/vm/memory/gcLocker.hpp	Wed Jun 10 14:57:21 2009 -0700
     1.2 +++ b/src/share/vm/memory/gcLocker.hpp	Thu Jun 11 12:40:00 2009 -0700
     1.3 @@ -242,6 +242,31 @@
     1.4  #endif
     1.5  };
     1.6  
     1.7 +// A SkipGCALot object is used to elide the usual effect of gc-a-lot
     1.8 +// over a section of execution by a thread. Currently, it's used only to
     1.9 +// prevent re-entrant calls to GC.
    1.10 +class SkipGCALot : public StackObj {
    1.11 +  private:
    1.12 +   bool _saved;
    1.13 +   Thread* _t;
    1.14 +
    1.15 +  public:
    1.16 +#ifdef ASSERT
    1.17 +    SkipGCALot(Thread* t) : _t(t) {
    1.18 +      _saved = _t->skip_gcalot();
    1.19 +      _t->set_skip_gcalot(true);
    1.20 +    }
    1.21 +
    1.22 +    ~SkipGCALot() {
    1.23 +      assert(_t->skip_gcalot(), "Save-restore protocol invariant");
    1.24 +      _t->set_skip_gcalot(_saved);
    1.25 +    }
    1.26 +#else
    1.27 +    SkipGCALot(Thread* t) { }
    1.28 +    ~SkipGCALot() { }
    1.29 +#endif
    1.30 +};
    1.31 +
    1.32  // JRT_LEAF currently can be called from either _thread_in_Java or
    1.33  // _thread_in_native mode. In _thread_in_native, it is ok
    1.34  // for another thread to trigger GC. The rest of the JRT_LEAF

mercurial