src/hotspot/share/gc/z/zNMethodTable.hpp
author stefank
Wed, 20 Feb 2019 10:46:39 +0100
changeset 53888 a858ad440eb9
parent 53887 2e1896987ed8
child 53890 70a6a7b15d36
permissions -rw-r--r--
8219463: ZGC: Remove redundant ZNMethodTable::_iter_lock Reviewed-by: pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     1
/*
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     4
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     7
 * published by the Free Software Foundation.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     8
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    13
 * accompanied this code).
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    14
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    18
 *
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    21
 * questions.
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    22
 */
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    23
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    24
#ifndef SHARE_GC_Z_ZNMETHODTABLE_HPP
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    25
#define SHARE_GC_Z_ZNMETHODTABLE_HPP
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    26
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    27
#include "gc/z/zArray.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    28
#include "gc/z/zGlobals.hpp"
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    29
#include "gc/z/zLock.hpp"
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    30
#include "gc/z/zNMethodTableEntry.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    31
#include "memory/allocation.hpp"
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    32
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    33
class ZWorkers;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    34
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    35
class ZNMethodTableEntryClosure {
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    36
public:
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    37
  virtual void do_nmethod_entry(ZNMethodTableEntry entry) = 0;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    38
};
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    39
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    40
class ZNMethodTable : public AllStatic {
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    41
private:
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    42
  static ZNMethodTableEntry* _table;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    43
  static size_t              _size;
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    44
  static ZNMethodTableEntry* _iter_table;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    45
  static size_t              _iter_table_size;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    46
  static ZArray<void*>       _iter_deferred_deletes;
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    47
  static size_t              _nregistered;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    48
  static size_t              _nunregistered;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    49
  static volatile size_t     _claimed ATTRIBUTE_ALIGNED(ZCacheLineSize);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    50
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    51
  static ZNMethodTableEntry create_entry(nmethod* nm);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    52
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    53
  static size_t first_index(const nmethod* nm, size_t size);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    54
  static size_t next_index(size_t prev_index, size_t size);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    55
53887
2e1896987ed8 8219462: ZGC: Use wait/notify in ZNMethodTable
stefank
parents: 53500
diff changeset
    56
  static void wait_until_iteration_done();
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    57
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    58
  static bool register_entry(ZNMethodTableEntry* table, size_t size, ZNMethodTableEntry entry);
53500
f618cfbaf35b 8217309: ZGC: Fix ZNMethodTable corruption
pliden
parents: 52939
diff changeset
    59
  static void unregister_entry(ZNMethodTableEntry* table, size_t size, nmethod* nm);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    60
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    61
  static void rebuild(size_t new_size);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    62
  static void rebuild_if_needed();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    63
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    64
  static void log_register(const nmethod* nm, ZNMethodTableEntry entry);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    65
  static void log_unregister(const nmethod* nm);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    66
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    67
public:
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    68
  static void safe_delete(void* data);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    69
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    70
  static size_t registered_nmethods();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    71
  static size_t unregistered_nmethods();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    72
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    73
  static void register_nmethod(nmethod* nm);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    74
  static void unregister_nmethod(nmethod* nm);
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    75
  static void disarm_nmethod(nmethod* nm);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    76
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    77
  static ZReentrantLock* lock_for_nmethod(nmethod* nm);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    78
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    79
  static void oops_do(OopClosure* cl);
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    80
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    81
  static void entry_oops_do(ZNMethodTableEntry entry, OopClosure* cl);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    82
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    83
  static void nmethod_entries_do_begin();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    84
  static void nmethod_entries_do_end();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    85
  static void nmethod_entries_do(ZNMethodTableEntryClosure* cl);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    86
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    87
  static void unlink(ZWorkers* workers, bool unloading_occurred);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    88
  static void purge(ZWorkers* workers);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    89
};
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    90
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    91
#endif // SHARE_GC_Z_ZNMETHODTABLE_HPP