1 /* |
1 /* |
2 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2010, 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. |
24 |
24 |
25 # include "incls/_precompiled.incl" |
25 # include "incls/_precompiled.incl" |
26 # include "incls/_systemDictionary.cpp.incl" |
26 # include "incls/_systemDictionary.cpp.incl" |
27 |
27 |
28 |
28 |
29 Dictionary* SystemDictionary::_dictionary = NULL; |
29 Dictionary* SystemDictionary::_dictionary = NULL; |
30 PlaceholderTable* SystemDictionary::_placeholders = NULL; |
30 PlaceholderTable* SystemDictionary::_placeholders = NULL; |
31 Dictionary* SystemDictionary::_shared_dictionary = NULL; |
31 Dictionary* SystemDictionary::_shared_dictionary = NULL; |
32 LoaderConstraintTable* SystemDictionary::_loader_constraints = NULL; |
32 LoaderConstraintTable* SystemDictionary::_loader_constraints = NULL; |
33 ResolutionErrorTable* SystemDictionary::_resolution_errors = NULL; |
33 ResolutionErrorTable* SystemDictionary::_resolution_errors = NULL; |
34 SymbolPropertyTable* SystemDictionary::_invoke_method_table = NULL; |
34 SymbolPropertyTable* SystemDictionary::_invoke_method_table = NULL; |
35 |
35 |
36 |
36 |
37 int SystemDictionary::_number_of_modifications = 0; |
37 int SystemDictionary::_number_of_modifications = 0; |
38 |
38 |
39 oop SystemDictionary::_system_loader_lock_obj = NULL; |
39 oop SystemDictionary::_system_loader_lock_obj = NULL; |
1725 // Placeholders. These are *always* strong roots, as they |
1725 // Placeholders. These are *always* strong roots, as they |
1726 // represent classes we're actively loading. |
1726 // represent classes we're actively loading. |
1727 placeholders_do(blk); |
1727 placeholders_do(blk); |
1728 |
1728 |
1729 // Visit extra methods |
1729 // Visit extra methods |
1730 if (invoke_method_table() != NULL) |
1730 invoke_method_table()->oops_do(blk); |
1731 invoke_method_table()->oops_do(blk); |
|
1732 |
1731 |
1733 // Loader constraints. We must keep the symbolOop used in the name alive. |
1732 // Loader constraints. We must keep the symbolOop used in the name alive. |
1734 constraints()->always_strong_classes_do(blk); |
1733 constraints()->always_strong_classes_do(blk); |
1735 |
1734 |
1736 // Resolution errors keep the symbolOop for the error alive |
1735 // Resolution errors keep the symbolOop for the error alive |
1764 |
1763 |
1765 // Adjust dictionary |
1764 // Adjust dictionary |
1766 dictionary()->oops_do(f); |
1765 dictionary()->oops_do(f); |
1767 |
1766 |
1768 // Visit extra methods |
1767 // Visit extra methods |
1769 if (invoke_method_table() != NULL) |
1768 invoke_method_table()->oops_do(f); |
1770 invoke_method_table()->oops_do(f); |
|
1771 |
1769 |
1772 // Partially loaded classes |
1770 // Partially loaded classes |
1773 placeholders()->oops_do(f); |
1771 placeholders()->oops_do(f); |
1774 |
1772 |
1775 // Adjust constraint table |
1773 // Adjust constraint table |
1839 placeholders()->entries_do(f); |
1837 placeholders()->entries_do(f); |
1840 } |
1838 } |
1841 |
1839 |
1842 void SystemDictionary::methods_do(void f(methodOop)) { |
1840 void SystemDictionary::methods_do(void f(methodOop)) { |
1843 dictionary()->methods_do(f); |
1841 dictionary()->methods_do(f); |
1844 if (invoke_method_table() != NULL) |
1842 invoke_method_table()->methods_do(f); |
1845 invoke_method_table()->methods_do(f); |
|
1846 } |
1843 } |
1847 |
1844 |
1848 // ---------------------------------------------------------------------------- |
1845 // ---------------------------------------------------------------------------- |
1849 // Lazily load klasses |
1846 // Lazily load klasses |
1850 |
1847 |
1868 |
1865 |
1869 void SystemDictionary::initialize(TRAPS) { |
1866 void SystemDictionary::initialize(TRAPS) { |
1870 // Allocate arrays |
1867 // Allocate arrays |
1871 assert(dictionary() == NULL, |
1868 assert(dictionary() == NULL, |
1872 "SystemDictionary should only be initialized once"); |
1869 "SystemDictionary should only be initialized once"); |
1873 _dictionary = new Dictionary(_nof_buckets); |
1870 _dictionary = new Dictionary(_nof_buckets); |
1874 _placeholders = new PlaceholderTable(_nof_buckets); |
1871 _placeholders = new PlaceholderTable(_nof_buckets); |
1875 _number_of_modifications = 0; |
1872 _number_of_modifications = 0; |
1876 _loader_constraints = new LoaderConstraintTable(_loader_constraint_size); |
1873 _loader_constraints = new LoaderConstraintTable(_loader_constraint_size); |
1877 _resolution_errors = new ResolutionErrorTable(_resolution_error_size); |
1874 _resolution_errors = new ResolutionErrorTable(_resolution_error_size); |
1878 // _invoke_method_table is allocated lazily in find_method_handle_invoke() |
1875 _invoke_method_table = new SymbolPropertyTable(_invoke_method_size); |
1879 |
1876 |
1880 // Allocate private object used as system class loader lock |
1877 // Allocate private object used as system class loader lock |
1881 _system_loader_lock_obj = oopFactory::new_system_objArray(0, CHECK); |
1878 _system_loader_lock_obj = oopFactory::new_system_objArray(0, CHECK); |
1882 // Initialize basic classes |
1879 // Initialize basic classes |
1883 initialize_preloaded_classes(CHECK); |
1880 initialize_preloaded_classes(CHECK); |
2344 methodOop SystemDictionary::find_method_handle_invoke(symbolHandle name, |
2341 methodOop SystemDictionary::find_method_handle_invoke(symbolHandle name, |
2345 symbolHandle signature, |
2342 symbolHandle signature, |
2346 KlassHandle accessing_klass, |
2343 KlassHandle accessing_klass, |
2347 TRAPS) { |
2344 TRAPS) { |
2348 if (!EnableMethodHandles) return NULL; |
2345 if (!EnableMethodHandles) return NULL; |
2349 if (invoke_method_table() == NULL) { |
|
2350 // create this side table lazily |
|
2351 _invoke_method_table = new SymbolPropertyTable(_invoke_method_size); |
|
2352 } |
|
2353 vmSymbols::SID name_id = vmSymbols::find_sid(name()); |
2346 vmSymbols::SID name_id = vmSymbols::find_sid(name()); |
2354 assert(name_id != vmSymbols::NO_SID, "must be a known name"); |
2347 assert(name_id != vmSymbols::NO_SID, "must be a known name"); |
2355 unsigned int hash = invoke_method_table()->compute_hash(signature, name_id); |
2348 unsigned int hash = invoke_method_table()->compute_hash(signature, name_id); |
2356 int index = invoke_method_table()->hash_to_index(hash); |
2349 int index = invoke_method_table()->hash_to_index(hash); |
2357 SymbolPropertyEntry* spe = invoke_method_table()->find_entry(index, hash, signature, name_id); |
2350 SymbolPropertyEntry* spe = invoke_method_table()->find_entry(index, hash, signature, name_id); |