src/hotspot/share/gc/z/zReferenceProcessor.hpp
changeset 50525 767cdb97f103
child 50622 21b96ce2ed10
equal deleted inserted replaced
50524:04f4e983c2f7 50525:767cdb97f103
       
     1 /*
       
     2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  */
       
    23 
       
    24 #ifndef SHARE_GC_Z_ZREFERENCEPROCESSOR_HPP
       
    25 #define SHARE_GC_Z_ZREFERENCEPROCESSOR_HPP
       
    26 
       
    27 #include "gc/shared/referenceDiscoverer.hpp"
       
    28 #include "gc/z/zValue.hpp"
       
    29 
       
    30 class ReferencePolicy;
       
    31 class ZWorkers;
       
    32 
       
    33 class ZReferenceProcessor : public ReferenceDiscoverer {
       
    34   friend class ZReferenceProcessorTask;
       
    35 
       
    36 private:
       
    37   static const size_t reference_type_count = REF_PHANTOM + 1;
       
    38   typedef size_t Counters[reference_type_count];
       
    39 
       
    40   ZWorkers* const      _workers;
       
    41   ReferencePolicy*     _soft_reference_policy;
       
    42   ZPerWorker<Counters> _encountered_count;
       
    43   ZPerWorker<Counters> _discovered_count;
       
    44   ZPerWorker<Counters> _enqueued_count;
       
    45   ZPerWorker<oop>      _discovered_list;
       
    46   ZContended<oop>      _pending_list;
       
    47   oop*                 _pending_list_tail;
       
    48 
       
    49   void update_soft_reference_clock() const;
       
    50 
       
    51   ReferenceType reference_type(oop obj) const;
       
    52   const char* reference_type_name(ReferenceType type) const;
       
    53   volatile oop* reference_referent_addr(oop obj) const;
       
    54   oop reference_referent(oop obj) const;
       
    55   bool is_reference_inactive(oop obj) const;
       
    56   bool is_referent_alive_or_null(oop obj, ReferenceType type) const;
       
    57   bool is_referent_softly_alive(oop obj, ReferenceType type) const;
       
    58   bool should_drop_reference(oop obj, ReferenceType type) const;
       
    59   bool should_mark_referent(ReferenceType type) const;
       
    60   bool should_clear_referent(ReferenceType type) const;
       
    61   void keep_referent_alive(oop obj, ReferenceType type) const;
       
    62 
       
    63   void discover(oop obj, ReferenceType type);
       
    64   oop drop(oop obj, ReferenceType type);
       
    65   oop* keep(oop obj, ReferenceType type);
       
    66 
       
    67   bool is_empty() const;
       
    68 
       
    69   void work();
       
    70   void collect_statistics();
       
    71 
       
    72 public:
       
    73   ZReferenceProcessor(ZWorkers* workers);
       
    74 
       
    75   void set_soft_reference_policy(bool clear);
       
    76   void reset_statistics();
       
    77 
       
    78   virtual bool discover_reference(oop reference, ReferenceType type);
       
    79   void process_references();
       
    80   void enqueue_references();
       
    81 };
       
    82 
       
    83 #endif // SHARE_GC_Z_ZREFERENCEPROCESSOR_HPP