src/hotspot/share/prims/resolvedMethodTable.hpp
author ihse
Mon, 26 Nov 2018 14:18:22 +0100
branchihse-manpages-branch
changeset 57043 23d7457ca4c6
parent 51567 0c4f2b26849e
child 53244 9807daeb47c4
permissions -rw-r--r--
Clean up login in when running which kind of man page creation.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
     1
/*
49818
e57e6addb978 8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents: 48615
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
     4
 *
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
     8
 *
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    13
 * accompanied this code).
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    14
 *
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    18
 *
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    21
 * questions.
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    22
 *
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    23
 */
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    24
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    25
#ifndef SHARE_VM_PRIMS_RESOLVEDMETHOD_HPP
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    26
#define SHARE_VM_PRIMS_RESOLVEDMETHOD_HPP
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    27
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    28
#include "oops/symbol.hpp"
49818
e57e6addb978 8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents: 48615
diff changeset
    29
#include "oops/weakHandle.hpp"
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    30
#include "utilities/hashtable.hpp"
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    31
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    32
// Hashtable to record Method* used in ResolvedMethods, via. ResolvedMethod oops.
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    33
// This is needed for redefinition to replace Method* with redefined versions.
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    34
49818
e57e6addb978 8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents: 48615
diff changeset
    35
// Entry in a ResolvedMethodTable, mapping a ClassLoaderWeakHandle for a single oop of
e57e6addb978 8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents: 48615
diff changeset
    36
// java_lang_invoke_ResolvedMethodName which holds JVM Method* in vmtarget.
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    37
49818
e57e6addb978 8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents: 48615
diff changeset
    38
class ResolvedMethodEntry : public HashtableEntry<ClassLoaderWeakHandle, mtClass> {
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    39
 public:
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    40
  ResolvedMethodEntry* next() const {
49818
e57e6addb978 8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents: 48615
diff changeset
    41
    return (ResolvedMethodEntry*)HashtableEntry<ClassLoaderWeakHandle, mtClass>::next();
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    42
  }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    43
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    44
  ResolvedMethodEntry** next_addr() {
49818
e57e6addb978 8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents: 48615
diff changeset
    45
    return (ResolvedMethodEntry**)HashtableEntry<ClassLoaderWeakHandle, mtClass>::next_addr();
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    46
  }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    47
48615
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    48
  oop object();
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    49
  oop object_no_keepalive();
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    50
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    51
  void print_on(outputStream* st) const;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    52
};
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    53
49818
e57e6addb978 8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents: 48615
diff changeset
    54
class ResolvedMethodTable : public Hashtable<ClassLoaderWeakHandle, mtClass> {
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    55
  enum Constants {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    56
    _table_size  = 1007
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    57
  };
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    58
51567
0c4f2b26849e 8209844: MemberNameLeak.java fails when ResolvedMethod entry is not removed
pchilanomate
parents: 51472
diff changeset
    59
  static int _total_oops_removed;
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    60
51472
eb97d1a319f9 8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents: 49818
diff changeset
    61
  static bool _dead_entries;
eb97d1a319f9 8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents: 49818
diff changeset
    62
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    63
  static ResolvedMethodTable* _the_table;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    64
private:
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    65
  ResolvedMethodEntry* bucket(int i) {
49818
e57e6addb978 8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents: 48615
diff changeset
    66
    return (ResolvedMethodEntry*) Hashtable<ClassLoaderWeakHandle, mtClass>::bucket(i);
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    67
  }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    68
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    69
  ResolvedMethodEntry** bucket_addr(int i) {
49818
e57e6addb978 8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents: 48615
diff changeset
    70
    return (ResolvedMethodEntry**) Hashtable<ClassLoaderWeakHandle, mtClass>::bucket_addr(i);
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    71
  }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    72
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    73
  unsigned int compute_hash(Method* method);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    74
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    75
  // need not be locked; no state change
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    76
  oop lookup(int index, unsigned int hash, Method* method);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    77
  oop lookup(Method* method);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    78
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    79
  // must be done under ResolvedMethodTable_lock
49818
e57e6addb978 8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents: 48615
diff changeset
    80
  oop basic_add(Method* method, Handle rmethod_name);
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    81
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    82
public:
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    83
  ResolvedMethodTable();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    84
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    85
  static void create_table() {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    86
    assert(_the_table == NULL, "One symbol table allowed.");
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    87
    _the_table = new ResolvedMethodTable();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    88
  }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    89
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    90
  // Called from java_lang_invoke_ResolvedMethodName
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    91
  static oop find_method(Method* method);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    92
  static oop add_method(Handle rmethod_name);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    93
51472
eb97d1a319f9 8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents: 49818
diff changeset
    94
  static bool has_work() { return _dead_entries; }
eb97d1a319f9 8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents: 49818
diff changeset
    95
  static void trigger_cleanup();
eb97d1a319f9 8206423: Use locking for cleaning ResolvedMethodTable
pchilanomate
parents: 49818
diff changeset
    96
51567
0c4f2b26849e 8209844: MemberNameLeak.java fails when ResolvedMethod entry is not removed
pchilanomate
parents: 51472
diff changeset
    97
  static int removed_entries_count() { return _total_oops_removed; };
0c4f2b26849e 8209844: MemberNameLeak.java fails when ResolvedMethod entry is not removed
pchilanomate
parents: 51472
diff changeset
    98
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    99
#if INCLUDE_JVMTI
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   100
  // It is called at safepoint only for RedefineClasses
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   101
  static void adjust_method_entries(bool * trace_name_printed);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   102
#endif // INCLUDE_JVMTI
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   103
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   104
  // Cleanup cleared entries
49818
e57e6addb978 8201505: Use WeakHandle for ProtectionDomainCacheTable and ResolvedMethodTable
coleenp
parents: 48615
diff changeset
   105
  static void unlink();
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   106
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   107
#ifndef PRODUCT
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   108
  void print();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   109
#endif
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   110
  void verify();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   111
};
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   112
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   113
#endif // SHARE_VM_PRIMS_RESOLVEDMETHOD_HPP