src/hotspot/share/prims/resolvedMethodTable.cpp
author stefank
Thu, 15 Mar 2018 21:29:36 +0100
changeset 49593 4dd58ecc9912
parent 48615 31cd0c16f4d2
child 49594 898ef81cbc0e
permissions -rw-r--r--
8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp Reviewed-by: coleenp, kbarrett
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
/*
49593
4dd58ecc9912 8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
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
#include "precompiled.hpp"
49593
4dd58ecc9912 8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents: 48615
diff changeset
    26
#include "classfile/javaClasses.hpp"
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    27
#include "gc/shared/gcLocker.hpp"
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    28
#include "memory/allocation.hpp"
49593
4dd58ecc9912 8200105: Remove cyclic dependency between oop.inline.hpp and collectedHeap.inline.hpp
stefank
parents: 48615
diff changeset
    29
#include "memory/resourceArea.hpp"
48615
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    30
#include "oops/access.inline.hpp"
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    31
#include "oops/oop.inline.hpp"
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    32
#include "oops/method.hpp"
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    33
#include "oops/symbol.hpp"
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    34
#include "prims/resolvedMethodTable.hpp"
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    35
#include "runtime/handles.inline.hpp"
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    36
#include "runtime/mutexLocker.hpp"
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    37
#include "utilities/hashtable.inline.hpp"
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    38
#include "utilities/macros.hpp"
48615
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    39
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    40
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    41
oop ResolvedMethodEntry::object() {
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    42
  return RootAccess<ON_PHANTOM_OOP_REF>::oop_load(literal_addr());
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    43
}
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    44
48615
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    45
oop ResolvedMethodEntry::object_no_keepalive() {
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    46
  // The AS_NO_KEEPALIVE peeks at the oop without keeping it alive.
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    47
  // This is dangerous in general but is okay if the loaded oop does
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    48
  // not leak out past a thread transition where a safepoint can happen.
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    49
  // A subsequent oop_load without AS_NO_KEEPALIVE (the object() accessor)
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    50
  // keeps the oop alive before doing so.
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    51
  return RootAccess<ON_PHANTOM_OOP_REF | AS_NO_KEEPALIVE>::oop_load(literal_addr());
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    52
}
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    53
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    54
ResolvedMethodTable::ResolvedMethodTable()
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    55
  : Hashtable<oop, mtClass>(_table_size, sizeof(ResolvedMethodEntry)) { }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    56
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    57
oop ResolvedMethodTable::lookup(int index, unsigned int hash, Method* method) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    58
  for (ResolvedMethodEntry* p = bucket(index); p != NULL; p = p->next()) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    59
    if (p->hash() == hash) {
48615
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    60
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    61
      // Peek the object to check if it is the right target.
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    62
      oop target = p->object_no_keepalive();
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    63
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    64
      // The method is in the table as a target already
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    65
      if (java_lang_invoke_ResolvedMethodName::vmtarget(target) == method) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    66
        ResourceMark rm;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    67
        log_debug(membername, table) ("ResolvedMethod entry found for %s index %d",
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    68
                                       method->name_and_sig_as_C_string(), index);
48615
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    69
        // The object() accessor makes sure the target object is kept alive before
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    70
        // leaking out.
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
    71
        return p->object();
46505
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
    }
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
  return NULL;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    76
}
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    77
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    78
unsigned int ResolvedMethodTable::compute_hash(Method* method) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    79
  unsigned int name_hash = method->name()->identity_hash();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    80
  unsigned int signature_hash = method->signature()->identity_hash();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    81
  return name_hash ^ signature_hash;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    82
}
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    83
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
oop ResolvedMethodTable::lookup(Method* method) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    86
  unsigned int hash = compute_hash(method);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    87
  int index = hash_to_index(hash);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    88
  return lookup(index, hash, method);
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
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    91
oop ResolvedMethodTable::basic_add(Method* method, oop rmethod_name) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    92
  assert_locked_or_safepoint(ResolvedMethodTable_lock);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    93
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    94
  unsigned int hash = compute_hash(method);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    95
  int index = hash_to_index(hash);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    96
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    97
  // One was added while aquiring the lock
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    98
  oop entry = lookup(index, hash, method);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
    99
  if (entry != NULL) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   100
    return entry;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   101
  }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   102
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   103
  ResolvedMethodEntry* p = (ResolvedMethodEntry*) Hashtable<oop, mtClass>::new_entry(hash, rmethod_name);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   104
  Hashtable<oop, mtClass>::add_entry(index, p);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   105
  ResourceMark rm;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   106
  log_debug(membername, table) ("ResolvedMethod entry added for %s index %d",
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   107
                                 method->name_and_sig_as_C_string(), index);
48615
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
   108
  return rmethod_name;
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   109
}
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   110
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   111
ResolvedMethodTable* ResolvedMethodTable::_the_table = NULL;
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
oop ResolvedMethodTable::find_method(Method* method) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   114
  oop entry = _the_table->lookup(method);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   115
  return entry;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   116
}
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   117
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   118
oop ResolvedMethodTable::add_method(Handle resolved_method_name) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   119
  MutexLocker ml(ResolvedMethodTable_lock);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   120
  DEBUG_ONLY(NoSafepointVerifier nsv);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   121
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   122
  // Check if method has been redefined while taking out ResolvedMethodTable_lock, if so
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   123
  // use new method.
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   124
  Method* method = (Method*)java_lang_invoke_ResolvedMethodName::vmtarget(resolved_method_name());
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   125
  assert(method->is_method(), "must be method");
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   126
  if (method->is_old()) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   127
    // Replace method with redefined version
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   128
    InstanceKlass* holder = method->method_holder();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   129
    method = holder->method_with_idnum(method->method_idnum());
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   130
    java_lang_invoke_ResolvedMethodName::set_vmtarget(resolved_method_name(), method);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   131
  }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   132
  // Set flag in class to indicate this InstanceKlass has entries in the table
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   133
  // to avoid walking table during redefinition if none of the redefined classes
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   134
  // have any membernames in the table.
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   135
  method->method_holder()->set_has_resolved_methods();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   136
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   137
  return _the_table->basic_add(method, resolved_method_name());
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   138
}
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   139
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   140
// Removing entries
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   141
int ResolvedMethodTable::_oops_removed = 0;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   142
int ResolvedMethodTable::_oops_counted = 0;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   143
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   144
// Serially invoke removed unused oops from the table.
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   145
// This is done late during GC.
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   146
void ResolvedMethodTable::unlink(BoolObjectClosure* is_alive) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   147
  _oops_removed = 0;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   148
  _oops_counted = 0;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   149
  for (int i = 0; i < _the_table->table_size(); ++i) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   150
    ResolvedMethodEntry** p = _the_table->bucket_addr(i);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   151
    ResolvedMethodEntry* entry = _the_table->bucket(i);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   152
    while (entry != NULL) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   153
      _oops_counted++;
48615
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
   154
      if (is_alive->do_object_b(entry->object_no_keepalive())) {
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   155
        p = entry->next_addr();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   156
      } else {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   157
        _oops_removed++;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   158
        if (log_is_enabled(Debug, membername, table)) {
48615
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
   159
          Method* m = (Method*)java_lang_invoke_ResolvedMethodName::vmtarget(entry->object_no_keepalive());
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   160
          ResourceMark rm;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   161
          log_debug(membername, table) ("ResolvedMethod entry removed for %s index %d",
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   162
                                           m->name_and_sig_as_C_string(), i);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   163
        }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   164
        *p = entry->next();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   165
        _the_table->free_entry(entry);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   166
      }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   167
      // get next entry
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   168
      entry = (ResolvedMethodEntry*)HashtableEntry<oop, mtClass>::make_ptr(*p);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   169
    }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   170
  }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   171
  log_debug(membername, table) ("ResolvedMethod entries counted %d removed %d",
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   172
                                _oops_counted, _oops_removed);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   173
}
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   174
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   175
// Serially invoke "f->do_oop" on the locations of all oops in the table.
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   176
void ResolvedMethodTable::oops_do(OopClosure* f) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   177
  for (int i = 0; i < _the_table->table_size(); ++i) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   178
    ResolvedMethodEntry* entry = _the_table->bucket(i);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   179
    while (entry != NULL) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   180
      f->do_oop(entry->literal_addr());
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   181
      entry = entry->next();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   182
    }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   183
  }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   184
}
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   185
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   186
#ifndef PRODUCT
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   187
void ResolvedMethodTable::print() {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   188
  for (int i = 0; i < table_size(); ++i) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   189
    ResolvedMethodEntry* entry = bucket(i);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   190
    while (entry != NULL) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   191
      tty->print("%d : ", i);
48615
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
   192
      oop rmethod_name = entry->object_no_keepalive();
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   193
      rmethod_name->print();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   194
      Method* m = (Method*)java_lang_invoke_ResolvedMethodName::vmtarget(rmethod_name);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   195
      m->print();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   196
      entry = entry->next();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   197
    }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   198
  }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   199
}
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   200
#endif // PRODUCT
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   201
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   202
#if INCLUDE_JVMTI
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   203
// It is called at safepoint only for RedefineClasses
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   204
void ResolvedMethodTable::adjust_method_entries(bool * trace_name_printed) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   205
  assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   206
  // For each entry in RMT, change to new method
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   207
  for (int i = 0; i < _the_table->table_size(); ++i) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   208
    ResolvedMethodEntry* entry = _the_table->bucket(i);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   209
    while (entry != NULL) {
48615
31cd0c16f4d2 8191904: Refactor weak oops in ResolvedMethodTable to use the Access API
eosterlund
parents: 47216
diff changeset
   210
      oop mem_name = entry->object_no_keepalive();
46505
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   211
      Method* old_method = (Method*)java_lang_invoke_ResolvedMethodName::vmtarget(mem_name);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   212
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   213
      if (old_method->is_old()) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   214
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   215
        if (old_method->is_deleted()) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   216
          // leave deleted method in ResolvedMethod for now (this is a bug that we don't mark
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   217
          // these on_stack)
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   218
          continue;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   219
        }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   220
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   221
        InstanceKlass* holder = old_method->method_holder();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   222
        Method* new_method = holder->method_with_idnum(old_method->orig_method_idnum());
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   223
        assert(holder == new_method->method_holder(), "call after swapping redefined guts");
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   224
        assert(new_method != NULL, "method_with_idnum() should not be NULL");
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   225
        assert(old_method != new_method, "sanity check");
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   226
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   227
        java_lang_invoke_ResolvedMethodName::set_vmtarget(mem_name, new_method);
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   228
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   229
        ResourceMark rm;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   230
        if (!(*trace_name_printed)) {
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   231
          log_info(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name());
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   232
           *trace_name_printed = true;
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   233
        }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   234
        log_debug(redefine, class, update, constantpool)
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   235
          ("ResolvedMethod method update: %s(%s)",
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   236
           new_method->name()->as_C_string(), new_method->signature()->as_C_string());
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   237
      }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   238
      entry = entry->next();
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   239
    }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   240
  }
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   241
}
fd4bc78630b1 8174749: Use hash table/oops for MemberName table
coleenp
parents:
diff changeset
   242
#endif // INCLUDE_JVMTI