Mercurial > hg > truffle
comparison src/share/vm/classfile/systemDictionary.cpp @ 4970:33df1aeaebbf
Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 27 Feb 2012 13:10:13 +0100 |
parents | 04b9a2566eec b2cd0ee8f778 |
children | 1b8d02e10ee8 |
comparison
equal
deleted
inserted
replaced
4703:2cfb7fb2dce7 | 4970:33df1aeaebbf |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 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 ResolutionErrorTable* SystemDictionary::_resolution_errors = NULL; | 62 ResolutionErrorTable* SystemDictionary::_resolution_errors = NULL; |
63 SymbolPropertyTable* SystemDictionary::_invoke_method_table = NULL; | 63 SymbolPropertyTable* SystemDictionary::_invoke_method_table = NULL; |
64 | 64 |
65 | 65 |
66 int SystemDictionary::_number_of_modifications = 0; | 66 int SystemDictionary::_number_of_modifications = 0; |
67 int SystemDictionary::_sdgeneration = 0; | |
68 const int SystemDictionary::_primelist[_prime_array_size] = {1009,2017,4049,5051,10103, | |
69 20201,40423,99991}; | |
67 | 70 |
68 oop SystemDictionary::_system_loader_lock_obj = NULL; | 71 oop SystemDictionary::_system_loader_lock_obj = NULL; |
69 | 72 |
70 klassOop SystemDictionary::_well_known_klasses[SystemDictionary::WKID_LIMIT] | 73 klassOop SystemDictionary::_well_known_klasses[SystemDictionary::WKID_LIMIT] |
71 = { NULL /*, NULL...*/ }; | 74 = { NULL /*, NULL...*/ }; |
1177 // If there is a shared dictionary, then find the entry for the | 1180 // If there is a shared dictionary, then find the entry for the |
1178 // given shared system class, if any. | 1181 // given shared system class, if any. |
1179 | 1182 |
1180 klassOop SystemDictionary::find_shared_class(Symbol* class_name) { | 1183 klassOop SystemDictionary::find_shared_class(Symbol* class_name) { |
1181 if (shared_dictionary() != NULL) { | 1184 if (shared_dictionary() != NULL) { |
1182 unsigned int d_hash = dictionary()->compute_hash(class_name, Handle()); | 1185 unsigned int d_hash = shared_dictionary()->compute_hash(class_name, Handle()); |
1183 int d_index = dictionary()->hash_to_index(d_hash); | 1186 int d_index = shared_dictionary()->hash_to_index(d_hash); |
1184 return shared_dictionary()->find_shared_class(d_index, d_hash, class_name); | 1187 return shared_dictionary()->find_shared_class(d_index, d_hash, class_name); |
1185 } else { | 1188 } else { |
1186 return NULL; | 1189 return NULL; |
1187 } | 1190 } |
1188 } | 1191 } |
1749 | 1752 |
1750 void SystemDictionary::placeholders_do(OopClosure* blk) { | 1753 void SystemDictionary::placeholders_do(OopClosure* blk) { |
1751 placeholders()->oops_do(blk); | 1754 placeholders()->oops_do(blk); |
1752 } | 1755 } |
1753 | 1756 |
1754 | 1757 // Calculate a "good" systemdictionary size based |
1758 // on predicted or current loaded classes count | |
1759 int SystemDictionary::calculate_systemdictionary_size(int classcount) { | |
1760 int newsize = _old_default_sdsize; | |
1761 if ((classcount > 0) && !DumpSharedSpaces) { | |
1762 int desiredsize = classcount/_average_depth_goal; | |
1763 for (newsize = _primelist[_sdgeneration]; _sdgeneration < _prime_array_size -1; | |
1764 newsize = _primelist[++_sdgeneration]) { | |
1765 if (desiredsize <= newsize) { | |
1766 break; | |
1767 } | |
1768 } | |
1769 } | |
1770 return newsize; | |
1771 } | |
1755 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive) { | 1772 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive) { |
1756 bool result = dictionary()->do_unloading(is_alive); | 1773 bool result = dictionary()->do_unloading(is_alive); |
1757 constraints()->purge_loader_constraints(is_alive); | 1774 constraints()->purge_loader_constraints(is_alive); |
1758 resolution_errors()->purge_resolution_errors(is_alive); | 1775 resolution_errors()->purge_resolution_errors(is_alive); |
1759 return result; | 1776 return result; |
1872 | 1889 |
1873 void SystemDictionary::initialize(TRAPS) { | 1890 void SystemDictionary::initialize(TRAPS) { |
1874 // Allocate arrays | 1891 // Allocate arrays |
1875 assert(dictionary() == NULL, | 1892 assert(dictionary() == NULL, |
1876 "SystemDictionary should only be initialized once"); | 1893 "SystemDictionary should only be initialized once"); |
1877 _dictionary = new Dictionary(_nof_buckets); | 1894 _sdgeneration = 0; |
1895 _dictionary = new Dictionary(calculate_systemdictionary_size(PredictedLoadedClassCount)); | |
1878 _placeholders = new PlaceholderTable(_nof_buckets); | 1896 _placeholders = new PlaceholderTable(_nof_buckets); |
1879 _number_of_modifications = 0; | 1897 _number_of_modifications = 0; |
1880 _loader_constraints = new LoaderConstraintTable(_loader_constraint_size); | 1898 _loader_constraints = new LoaderConstraintTable(_loader_constraint_size); |
1881 _resolution_errors = new ResolutionErrorTable(_resolution_error_size); | 1899 _resolution_errors = new ResolutionErrorTable(_resolution_error_size); |
1882 _invoke_method_table = new SymbolPropertyTable(_invoke_method_size); | 1900 _invoke_method_table = new SymbolPropertyTable(_invoke_method_size); |
2129 // defined, not each time it is referenced from a new class loader | 2147 // defined, not each time it is referenced from a new class loader |
2130 if (k->class_loader() == class_loader()) { | 2148 if (k->class_loader() == class_loader()) { |
2131 k->set_prototype_header(markOopDesc::biased_locking_prototype()); | 2149 k->set_prototype_header(markOopDesc::biased_locking_prototype()); |
2132 } | 2150 } |
2133 } | 2151 } |
2152 | |
2153 // Assign a classid if one has not already been assigned. The | |
2154 // counter does not need to be atomically incremented since this | |
2155 // is only done while holding the SystemDictionary_lock. | |
2156 // All loaded classes get a unique ID. | |
2157 TRACE_INIT_ID(k); | |
2134 | 2158 |
2135 // Check for a placeholder. If there, remove it and make a | 2159 // Check for a placeholder. If there, remove it and make a |
2136 // new system dictionary entry. | 2160 // new system dictionary entry. |
2137 placeholders()->find_and_remove(p_index, p_hash, name, class_loader, THREAD); | 2161 placeholders()->find_and_remove(p_index, p_hash, name, class_loader, THREAD); |
2138 klassOop sd_check = find_class(d_index, d_hash, name, class_loader); | 2162 klassOop sd_check = find_class(d_index, d_hash, name, class_loader); |