src/hotspot/share/gc/z/zNMethodTable.hpp
author pliden
Thu, 24 Jan 2019 12:23:01 +0100
changeset 53500 f618cfbaf35b
parent 52939 9a8585f60c32
child 53887 2e1896987ed8
permissions -rw-r--r--
8217309: ZGC: Fix ZNMethodTable corruption Reviewed-by: eosterlund, stefank
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 ZLock               _iter_lock;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    45
  static ZNMethodTableEntry* _iter_table;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    46
  static size_t              _iter_table_size;
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    47
  static ZArray<void*>       _iter_deferred_deletes;
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    48
  static size_t              _nregistered;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    49
  static size_t              _nunregistered;
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    50
  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
    51
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    52
  static ZNMethodTableEntry create_entry(nmethod* nm);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    53
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    54
  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
    55
  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
    56
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    57
  static void sweeper_wait_for_iteration();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    58
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    59
  static bool register_entry(ZNMethodTableEntry* table, size_t size, ZNMethodTableEntry entry);
53500
f618cfbaf35b 8217309: ZGC: Fix ZNMethodTable corruption
pliden
parents: 52939
diff changeset
    60
  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
    61
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    62
  static void rebuild(size_t new_size);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    63
  static void rebuild_if_needed();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    64
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    65
  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
    66
  static void log_unregister(const nmethod* nm);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    67
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    68
public:
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    69
  static void safe_delete(void* data);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    70
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    71
  static size_t registered_nmethods();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    72
  static size_t unregistered_nmethods();
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    73
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    74
  static void register_nmethod(nmethod* nm);
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    75
  static void unregister_nmethod(nmethod* nm);
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    76
  static void disarm_nmethod(nmethod* nm);
50525
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    77
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    78
  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
    79
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    80
  static void oops_do(OopClosure* cl);
52939
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    81
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    82
  static void entry_oops_do(ZNMethodTableEntry entry, OopClosure* cl);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    83
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    84
  static void nmethod_entries_do_begin();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    85
  static void nmethod_entries_do_end();
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    86
  static void nmethod_entries_do(ZNMethodTableEntryClosure* cl);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    87
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    88
  static void unlink(ZWorkers* workers, bool unloading_occurred);
9a8585f60c32 8214897: ZGC: Concurrent Class Unloading
eosterlund
parents: 50525
diff changeset
    89
  static void purge(ZWorkers* workers);
50525
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
767cdb97f103 8204210: Implementation: JEP 333: ZGC: A Scalable Low-Latency Garbage Collector (Experimental)
pliden
parents:
diff changeset
    92
#endif // SHARE_GC_Z_ZNMETHODTABLE_HPP