hotspot/src/share/vm/utilities/hashtable.inline.hpp
author minqi
Mon, 12 Nov 2012 14:03:53 -0800
changeset 14477 95e66ea71f71
parent 13195 be27e1b6a4b9
child 24351 61b33cc6d3cf
permissions -rw-r--r--
6830717: replay of compilations would help with debugging Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method. Reviewed-by: kvn, twisti, sspitsyn Contributed-by: yumin.qi@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
13087
673ea6efaf18 7158800: Improve storage of symbol tables
coleenp
parents: 8921
diff changeset
     2
 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
1
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
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_UTILITIES_HASHTABLE_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_UTILITIES_HASHTABLE_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "utilities/hashtable.hpp"
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
    30
#include "utilities/dtrace.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// Inline function definitions for hashtable.hpp.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// --------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// Initialize a table.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
    38
template <MEMFLAGS F> inline BasicHashtable<F>::BasicHashtable(int table_size, int entry_size) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  // Called on startup, no locking needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  initialize(table_size, entry_size, 0);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
    41
  _buckets = NEW_C_HEAP_ARRAY2(HashtableBucket<F>, table_size, F, CURRENT_PC);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  for (int index = 0; index < _table_size; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    _buckets[index].clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
    48
template <MEMFLAGS F> inline BasicHashtable<F>::BasicHashtable(int table_size, int entry_size,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
    49
                                      HashtableBucket<F>* buckets,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
                                      int number_of_entries) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // Called on startup, no locking needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  initialize(table_size, entry_size, number_of_entries);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  _buckets = buckets;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
    57
template <MEMFLAGS F> inline void BasicHashtable<F>::initialize(int table_size, int entry_size,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
                                       int number_of_entries) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  // Called on startup, no locking needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  _table_size = table_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  _entry_size = entry_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  _free_list = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  _first_free_entry = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  _end_block = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  _number_of_entries = number_of_entries;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  _lookup_count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  _lookup_length = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
// The following method is MT-safe and may be used with caution.
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
    74
template <MEMFLAGS F> inline BasicHashtableEntry<F>* BasicHashtable<F>::bucket(int i) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  return _buckets[i].get_entry();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
    79
template <MEMFLAGS F> inline void HashtableBucket<F>::set_entry(BasicHashtableEntry<F>* l) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // Warning: Preserve store ordering.  The SystemDictionary is read
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  //          without locks.  The new SystemDictionaryEntry must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  //          complete before other threads can be allowed to see it
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  //          via a store to _buckets[index].
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  OrderAccess::release_store_ptr(&_entry, l);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
    88
template <MEMFLAGS F> inline BasicHashtableEntry<F>* HashtableBucket<F>::get_entry() const {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // Warning: Preserve load ordering.  The SystemDictionary is read
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  //          without locks.  The new SystemDictionaryEntry must be
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  //          complete before other threads can be allowed to see it
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  //          via a store to _buckets[index].
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
    93
  return (BasicHashtableEntry<F>*) OrderAccess::load_ptr_acquire(&_entry);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
    97
template <MEMFLAGS F> inline void BasicHashtable<F>::set_entry(int index, BasicHashtableEntry<F>* entry) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  _buckets[index].set_entry(entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
   102
template <MEMFLAGS F> inline void BasicHashtable<F>::add_entry(int index, BasicHashtableEntry<F>* entry) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  entry->set_next(bucket(index));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  _buckets[index].set_entry(entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  ++_number_of_entries;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 13087
diff changeset
   108
template <MEMFLAGS F> inline void BasicHashtable<F>::free_entry(BasicHashtableEntry<F>* entry) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  entry->set_next(_free_list);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  _free_list = entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  --_number_of_entries;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
}
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   113
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   114
#endif // SHARE_VM_UTILITIES_HASHTABLE_INLINE_HPP