comparison src/share/vm/classfile/resolutionErrors.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents d2a62e0f25eb
children
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
1 /* 1 /*
2 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
62 _error = e; 62 _error = e;
63 if (_error != NULL) _error->increment_refcount(); 63 if (_error != NULL) _error->increment_refcount();
64 } 64 }
65 65
66 // create new error entry 66 // create new error entry
67 ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, constantPoolOop pool, 67 ResolutionErrorEntry* ResolutionErrorTable::new_entry(int hash, ConstantPool* pool,
68 int cp_index, Symbol* error) 68 int cp_index, Symbol* error)
69 { 69 {
70 ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<constantPoolOop, mtClass>::new_entry(hash, pool); 70 ResolutionErrorEntry* entry = (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::new_entry(hash, pool);
71 entry->set_cp_index(cp_index); 71 entry->set_cp_index(cp_index);
72 NOT_PRODUCT(entry->set_error(NULL);) 72 NOT_PRODUCT(entry->set_error(NULL);)
73 entry->set_error(error); 73 entry->set_error(error);
74 74
75 return entry; 75 return entry;
77 77
78 void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) { 78 void ResolutionErrorTable::free_entry(ResolutionErrorEntry *entry) {
79 // decrement error refcount 79 // decrement error refcount
80 assert(entry->error() != NULL, "error should be set"); 80 assert(entry->error() != NULL, "error should be set");
81 entry->error()->decrement_refcount(); 81 entry->error()->decrement_refcount();
82 Hashtable<constantPoolOop, mtClass>::free_entry(entry); 82 Hashtable<ConstantPool*, mtClass>::free_entry(entry);
83 } 83 }
84 84
85 85
86 // create resolution error table 86 // create resolution error table
87 ResolutionErrorTable::ResolutionErrorTable(int table_size) 87 ResolutionErrorTable::ResolutionErrorTable(int table_size)
88 : Hashtable<constantPoolOop, mtClass>(table_size, sizeof(ResolutionErrorEntry)) { 88 : Hashtable<ConstantPool*, mtClass>(table_size, sizeof(ResolutionErrorEntry)) {
89 } 89 }
90 90
91 // GC support 91 // RedefineClasses support - remove matching entry of a
92 void ResolutionErrorTable::oops_do(OopClosure* f) { 92 // constant pool that is going away
93 void ResolutionErrorTable::delete_entry(ConstantPool* c) {
94 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
93 for (int i = 0; i < table_size(); i++) { 95 for (int i = 0; i < table_size(); i++) {
94 for (ResolutionErrorEntry* probe = bucket(i); 96 for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) {
95 probe != NULL; 97 ResolutionErrorEntry* entry = *p;
96 probe = probe->next()) { 98 assert(entry->pool() != NULL, "resolution error table is corrupt");
97 assert(probe->pool() != (constantPoolOop)NULL, "resolution error table is corrupt"); 99 if (entry->pool() == c) {
98 assert(probe->error() != (Symbol*)NULL, "resolution error table is corrupt"); 100 *p = entry->next();
99 probe->oops_do(f); 101 free_entry(entry);
102 } else {
103 p = entry->next_addr();
104 }
100 } 105 }
101 } 106 }
102 } 107 }
103 108
104 // GC support
105 void ResolutionErrorEntry::oops_do(OopClosure* blk) {
106 blk->do_oop((oop*)pool_addr());
107 }
108 109
109 // Remove unloaded entries from the table 110 // Remove unloaded entries from the table
110 void ResolutionErrorTable::purge_resolution_errors(BoolObjectClosure* is_alive) { 111 void ResolutionErrorTable::purge_resolution_errors() {
111 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint"); 112 assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
112 for (int i = 0; i < table_size(); i++) { 113 for (int i = 0; i < table_size(); i++) {
113 for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) { 114 for (ResolutionErrorEntry** p = bucket_addr(i); *p != NULL; ) {
114 ResolutionErrorEntry* entry = *p; 115 ResolutionErrorEntry* entry = *p;
115 assert(entry->pool() != (constantPoolOop)NULL, "resolution error table is corrupt"); 116 assert(entry->pool() != (ConstantPool*)NULL, "resolution error table is corrupt");
116 constantPoolOop pool = entry->pool(); 117 ConstantPool* pool = entry->pool();
117 if (is_alive->do_object_b(pool)) { 118 assert(pool->pool_holder() != NULL, "Constant pool without a class?");
119 ClassLoaderData* loader_data =
120 pool->pool_holder()->class_loader_data();
121 if (!loader_data->is_unloading()) {
118 p = entry->next_addr(); 122 p = entry->next_addr();
119 } else { 123 } else {
120 *p = entry->next(); 124 *p = entry->next();
121 free_entry(entry); 125 free_entry(entry);
122 } 126 }