hotspot/src/share/vm/classfile/resolutionErrors.cpp
author dcubed
Wed, 12 Mar 2008 18:07:46 -0700
changeset 221 ec745a0fe922
parent 1 489c9b5090e2
child 5402 c51fd0c1d005
permissions -rw-r--r--
6599425: 4/3 OopMapCache::lookup() can cause later crash or assert() failure Summary: Add should_not_be_cached() to markOop and methodOop and query that status inOopMapCache::lookup() Reviewed-by: coleenp, sspitsyn, jmasa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_resolutionErrors.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// add new entry to the table
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
void ResolutionErrorTable::add_entry(int index, unsigned int hash,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
                                     constantPoolHandle pool, int cp_index, symbolHandle error)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  assert_locked_or_safepoint(SystemDictionary_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  assert(!pool.is_null() && !error.is_null(), "adding NULL obj");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  add_entry(index, entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// find entry in the table
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
ResolutionErrorEntry* ResolutionErrorTable::find_entry(int index, unsigned int hash,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
                                                       constantPoolHandle pool, int cp_index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  assert_locked_or_safepoint(SystemDictionary_lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  for (ResolutionErrorEntry *error_probe = bucket(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
                         error_probe != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
                         error_probe = error_probe->next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  if (error_probe->hash() == hash && error_probe->pool() == pool()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
      return error_probe;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// create new error entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, constantPoolOop pool,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
                                                      int cp_index, symbolOop error)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable::new_entry(hash, pool);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  entry->set_cp_index(cp_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  entry->set_error(error);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
// create resolution error table
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
ResolutionErrorTable::ResolutionErrorTable(int table_size)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    : Hashtable(table_size, sizeof(ResolutionErrorEntry)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
// GC support
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
void ResolutionErrorTable::oops_do(OopClosure* f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  for (int i = 0; i < table_size(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    for (ResolutionErrorEntry* probe = bucket(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
                           probe != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
                           probe = probe->next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      assert(probe->pool() != (constantPoolOop)NULL, "resolution error table is corrupt");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
      assert(probe->error() != (symbolOop)NULL, "resolution error table is corrupt");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
      probe->oops_do(f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
// GC support
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
void ResolutionErrorEntry::oops_do(OopClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  blk->do_oop((oop*)pool_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  blk->do_oop((oop*)error_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
// We must keep the symbolOop used in the error alive. The constantPoolOop will
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
// decide when the entry can be purged.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
void ResolutionErrorTable::always_strong_classes_do(OopClosure* blk) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  for (int i = 0; i < table_size(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    for (ResolutionErrorEntry* probe = bucket(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
                           probe != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
                           probe = probe->next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      assert(probe->error() != (symbolOop)NULL, "resolution error table is corrupt");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
      blk->do_oop((oop*)probe->error_addr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// Remove unloaded entries from the table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
void ResolutionErrorTable::purge_resolution_errors(BoolObjectClosure* is_alive) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint")
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  for (int i = 0; i < table_size(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
      ResolutionErrorEntry* entry = *p;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
      assert(entry->pool() != (constantPoolOop)NULL, "resolution error table is corrupt");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
      constantPoolOop pool = entry->pool();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
      if (is_alive->do_object_b(pool)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
        p = entry->next_addr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
        *p = entry->next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
        free_entry(entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
}