Mercurial > hg > graal-compiler
diff src/share/vm/gc_implementation/g1/g1OopClosures.hpp @ 14909:4ca6dc0799b6
Backout jdk9 merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 01 Apr 2014 13:57:07 +0200 |
parents | 97300b6165f8 |
children | 52b4284cb496 |
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/g1OopClosures.hpp Tue Apr 01 14:09:03 2014 +0200 +++ b/src/share/vm/gc_implementation/g1/g1OopClosures.hpp Tue Apr 01 13:57:07 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,7 @@ // A class that scans oops in a given heap region (much as OopsInGenClosure // scans oops in a generation.) -class OopsInHeapRegionClosure: public ExtendedOopClosure { +class OopsInHeapRegionClosure: public OopsInGenClosure { protected: HeapRegion* _from; public: @@ -48,8 +48,12 @@ class G1ParClosureSuper : public OopsInHeapRegionClosure { protected: G1CollectedHeap* _g1; + G1RemSet* _g1_rem; + ConcurrentMark* _cm; G1ParScanThreadState* _par_scan_state; uint _worker_id; + bool _during_initial_mark; + bool _mark_in_progress; public: G1ParClosureSuper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); bool apply_to_weak_ref_discovered_field() { return true; } @@ -82,26 +86,13 @@ #define G1_PARTIAL_ARRAY_MASK 0x2 -inline bool has_partial_array_mask(oop* ref) { +template <class T> inline bool has_partial_array_mask(T* ref) { return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; } -// We never encode partial array oops as narrowOop*, so return false immediately. -// This allows the compiler to create optimized code when popping references from -// the work queue. -inline bool has_partial_array_mask(narrowOop* ref) { - assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*"); - return false; -} - -// Only implement set_partial_array_mask() for regular oops, not for narrowOops. -// We always encode partial arrays as regular oop, to allow the -// specialization for has_partial_array_mask() for narrowOops above. -// This means that unintentional use of this method with narrowOops are caught -// by the compiler. -inline oop* set_partial_array_mask(oop obj) { +template <class T> inline T* set_partial_array_mask(T obj) { assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); - return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK); + return (T*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK); } template <class T> inline oop clear_partial_array_mask(T* ref) { @@ -129,10 +120,23 @@ // Add back base class for metadata class G1ParCopyHelper : public G1ParClosureSuper { + Klass* _scanned_klass; + + public: + G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : + _scanned_klass(NULL), + G1ParClosureSuper(g1, par_scan_state) {} + + void set_scanned_klass(Klass* k) { _scanned_klass = k; } + template <class T> void do_klass_barrier(T* p, oop new_obj); +}; + +template <bool do_gen_barrier, G1Barrier barrier, bool do_mark_object> +class G1ParCopyClosure : public G1ParCopyHelper { + G1ParScanClosure _scanner; + template <class T> void do_oop_work(T* p); + protected: - Klass* _scanned_klass; - ConcurrentMark* _cm; - // Mark the object if it's not already marked. This is used to mark // objects pointed to by roots that are guaranteed not to move // during the GC (i.e., non-CSet objects). It is MT-safe. @@ -142,40 +146,42 @@ // objects pointed to by roots that have been forwarded during a // GC. It is MT-safe. void mark_forwarded_object(oop from_obj, oop to_obj); - public: - G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state); - void set_scanned_klass(Klass* k) { _scanned_klass = k; } - template <class T> void do_klass_barrier(T* p, oop new_obj); -}; - -template <G1Barrier barrier, bool do_mark_object> -class G1ParCopyClosure : public G1ParCopyHelper { -private: - template <class T> void do_oop_work(T* p); + oop copy_to_survivor_space(oop obj); public: G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) : + _scanner(g1, par_scan_state, rp), G1ParCopyHelper(g1, par_scan_state) { assert(_ref_processor == NULL, "sanity"); } - template <class T> void do_oop_nv(T* p) { do_oop_work(p); } + G1ParScanClosure* scanner() { return &_scanner; } + + template <class T> void do_oop_nv(T* p) { + do_oop_work(p); + } virtual void do_oop(oop* p) { do_oop_nv(p); } virtual void do_oop(narrowOop* p) { do_oop_nv(p); } }; -typedef G1ParCopyClosure<G1BarrierNone, false> G1ParScanExtRootClosure; -typedef G1ParCopyClosure<G1BarrierKlass, false> G1ParScanMetadataClosure; +typedef G1ParCopyClosure<false, G1BarrierNone, false> G1ParScanExtRootClosure; +typedef G1ParCopyClosure<false, G1BarrierKlass, false> G1ParScanMetadataClosure; -typedef G1ParCopyClosure<G1BarrierNone, true> G1ParScanAndMarkExtRootClosure; -typedef G1ParCopyClosure<G1BarrierKlass, true> G1ParScanAndMarkMetadataClosure; +typedef G1ParCopyClosure<false, G1BarrierNone, true> G1ParScanAndMarkExtRootClosure; +typedef G1ParCopyClosure<true, G1BarrierNone, true> G1ParScanAndMarkClosure; +typedef G1ParCopyClosure<false, G1BarrierKlass, true> G1ParScanAndMarkMetadataClosure; + +// The following closure types are no longer used but are retained +// for historical reasons: +// typedef G1ParCopyClosure<false, G1BarrierRS, false> G1ParScanHeapRSClosure; +// typedef G1ParCopyClosure<false, G1BarrierRS, true> G1ParScanAndMarkHeapRSClosure; // The following closure type is defined in g1_specialized_oop_closures.hpp: // -// typedef G1ParCopyClosure<G1BarrierEvac, false> G1ParScanHeapEvacClosure; +// typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacClosure; // We use a separate closure to handle references during evacuation // failure processing. @@ -183,7 +189,7 @@ // (since that closure no longer assumes that the references it // handles point into the collection set). -typedef G1ParCopyClosure<G1BarrierEvac, false> G1ParScanHeapEvacFailureClosure; +typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacFailureClosure; class FilterIntoCSClosure: public ExtendedOopClosure { G1CollectedHeap* _g1;