1 /* 2 * Copyright (c) 2015, 2017, 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 typedef size_t Counters[REF_COUNT]; 38 39 ZWorkers* const _workers; 40 ReferencePolicy* _soft_reference_policy; 41 ZPerWorker<Counters> _encountered_count; 42 ZPerWorker<Counters> _discovered_count; 43 ZPerWorker<Counters> _enqueued_count; 44 ZPerWorker<oop> _discovered_list; 45 ZContended<oop> _pending_list; 46 oop* _pending_list_tail; 47 48 void update_soft_reference_clock() const; 49 50 ReferenceType reference_type(oop obj) const; 51 volatile oop* reference_referent_addr(oop obj) const; 52 oop reference_referent(oop obj) const; 53 bool is_reference_inactive(oop obj) const; 54 bool is_referent_alive_or_null(oop obj, ReferenceType type) const; 55 bool is_referent_softly_alive(oop obj, ReferenceType type) const; 56 bool should_drop_reference(oop obj, ReferenceType type) const; 57 bool should_mark_referent(ReferenceType type) const; 58 bool should_clear_referent(ReferenceType type) const; 59 void keep_referent_alive(oop obj, ReferenceType type) const; 60 61 void discover(oop obj, ReferenceType type); 62 oop drop(oop obj, ReferenceType type); 63 oop* keep(oop obj, ReferenceType type); 64 65 bool is_empty() const; 66 67 void work(); 68 void collect_statistics(); 69 70 void process_references(); 71 void enqueue_references(); 72 73 public: 74 ZReferenceProcessor(ZWorkers* workers); 75 76 void set_soft_reference_policy(bool clear); 77 void reset_statistics(); 78 virtual bool discover_reference(oop reference, ReferenceType type); 79 void process_and_enqueue_references(); 80 }; 81 82 #endif // SHARE_GC_Z_ZREFERENCEPROCESSOR_HPP