author | twisti |
Thu, 08 Sep 2011 05:11:31 -0700 | |
changeset 10540 | 92d59dba2407 |
parent 8921 | 14bfe81f2a9d |
child 13195 | be27e1b6a4b9 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
8921
14bfe81f2a9d
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
8076
diff
changeset
|
2 |
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5402
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:
5402
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "classfile/resolutionErrors.hpp" |
|
27 |
#include "memory/resourceArea.hpp" |
|
28 |
#include "oops/oop.inline.hpp" |
|
29 |
#include "runtime/handles.inline.hpp" |
|
30 |
#include "runtime/safepoint.hpp" |
|
31 |
#include "utilities/hashtable.inline.hpp" |
|
1 | 32 |
|
33 |
// add new entry to the table |
|
34 |
void ResolutionErrorTable::add_entry(int index, unsigned int hash, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
35 |
constantPoolHandle pool, int cp_index, Symbol* error) |
1 | 36 |
{ |
37 |
assert_locked_or_safepoint(SystemDictionary_lock); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
38 |
assert(!pool.is_null() && error != NULL, "adding NULL obj"); |
1 | 39 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
40 |
ResolutionErrorEntry* entry = new_entry(hash, pool(), cp_index, error); |
1 | 41 |
add_entry(index, entry); |
42 |
} |
|
43 |
||
44 |
// find entry in the table |
|
45 |
ResolutionErrorEntry* ResolutionErrorTable::find_entry(int index, unsigned int hash, |
|
46 |
constantPoolHandle pool, int cp_index) |
|
47 |
{ |
|
48 |
assert_locked_or_safepoint(SystemDictionary_lock); |
|
49 |
||
50 |
for (ResolutionErrorEntry *error_probe = bucket(index); |
|
51 |
error_probe != NULL; |
|
52 |
error_probe = error_probe->next()) { |
|
53 |
if (error_probe->hash() == hash && error_probe->pool() == pool()) { |
|
54 |
return error_probe;; |
|
55 |
} |
|
56 |
} |
|
57 |
return NULL; |
|
58 |
} |
|
59 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
60 |
void ResolutionErrorEntry::set_error(Symbol* e) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
61 |
assert(e == NULL || _error == NULL, "cannot reset error"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
62 |
_error = e; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
63 |
if (_error != NULL) _error->increment_refcount(); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
64 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
65 |
|
1 | 66 |
// create new error entry |
67 |
ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, constantPoolOop pool, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
68 |
int cp_index, Symbol* error) |
1 | 69 |
{ |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
70 |
ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<constantPoolOop>::new_entry(hash, pool); |
1 | 71 |
entry->set_cp_index(cp_index); |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
72 |
NOT_PRODUCT(entry->set_error(NULL);) |
1 | 73 |
entry->set_error(error); |
74 |
||
75 |
return entry; |
|
76 |
} |
|
77 |
||
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
78 |
void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
79 |
// decrement error refcount |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
80 |
assert(entry->error() != NULL, "error should be set"); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
81 |
entry->error()->decrement_refcount(); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
82 |
Hashtable<constantPoolOop>::free_entry(entry); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
83 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
84 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
85 |
|
1 | 86 |
// create resolution error table |
87 |
ResolutionErrorTable::ResolutionErrorTable(int table_size) |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
88 |
: Hashtable<constantPoolOop>(table_size, sizeof(ResolutionErrorEntry)) { |
1 | 89 |
} |
90 |
||
91 |
// GC support |
|
92 |
void ResolutionErrorTable::oops_do(OopClosure* f) { |
|
93 |
for (int i = 0; i < table_size(); i++) { |
|
94 |
for (ResolutionErrorEntry* probe = bucket(i); |
|
95 |
probe != NULL; |
|
96 |
probe = probe->next()) { |
|
97 |
assert(probe->pool() != (constantPoolOop)NULL, "resolution error table is corrupt"); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
98 |
assert(probe->error() != (Symbol*)NULL, "resolution error table is corrupt"); |
1 | 99 |
probe->oops_do(f); |
100 |
} |
|
101 |
} |
|
102 |
} |
|
103 |
||
104 |
// GC support |
|
105 |
void ResolutionErrorEntry::oops_do(OopClosure* blk) { |
|
106 |
blk->do_oop((oop*)pool_addr()); |
|
107 |
} |
|
108 |
||
109 |
// Remove unloaded entries from the table |
|
110 |
void ResolutionErrorTable::purge_resolution_errors(BoolObjectClosure* is_alive) { |
|
5402
c51fd0c1d005
6888953: some calls to function-like macros are missing semicolons
jcoomes
parents:
1
diff
changeset
|
111 |
assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); |
1 | 112 |
for (int i = 0; i < table_size(); i++) { |
113 |
for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) { |
|
114 |
ResolutionErrorEntry* entry = *p; |
|
115 |
assert(entry->pool() != (constantPoolOop)NULL, "resolution error table is corrupt"); |
|
116 |
constantPoolOop pool = entry->pool(); |
|
117 |
if (is_alive->do_object_b(pool)) { |
|
118 |
p = entry->next_addr(); |
|
119 |
} else { |
|
120 |
*p = entry->next(); |
|
121 |
free_entry(entry); |
|
122 |
} |
|
123 |
} |
|
124 |
} |
|
125 |
} |