| 1 | /* |
| 2 | * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
| 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 | * |
| 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | * or visit www.oracle.com if you need additional information or have any |
| 21 | * questions. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #ifndef SHARE_PRIMS_RESOLVEDMETHODTABLE_HPP |
| 26 | #define SHARE_PRIMS_RESOLVEDMETHODTABLE_HPP |
| 27 | |
| 28 | #include "gc/shared/oopStorage.hpp" |
| 29 | #include "memory/allocation.hpp" |
| 30 | #include "oops/symbol.hpp" |
| 31 | #include "oops/weakHandle.hpp" |
| 32 | |
| 33 | class ResolvedMethodTable; |
| 34 | class ResolvedMethodTableConfig; |
| 35 | |
| 36 | class ResolvedMethodTable : public AllStatic { |
| 37 | static OopStorage* _weak_handles; |
| 38 | |
| 39 | static volatile bool _has_work; |
| 40 | public: |
| 41 | // Initialization |
| 42 | static void create_table(); |
| 43 | |
| 44 | static size_t table_size(); |
| 45 | |
| 46 | // Lookup and inserts |
| 47 | static oop find_method(const Method* method); |
| 48 | static oop add_method(const Method* method, Handle rmethod_name); |
| 49 | |
| 50 | // Callbacks |
| 51 | static void item_added(); |
| 52 | static void item_removed(); |
| 53 | |
| 54 | // Cleaning |
| 55 | static bool has_work() { return _has_work; } |
| 56 | |
| 57 | // GC Support - Backing storage for the oop*s |
| 58 | static OopStorage* weak_storage() { return _weak_handles; } |
| 59 | |
| 60 | // Cleaning and table management |
| 61 | |
| 62 | static double get_load_factor(); |
| 63 | static double get_dead_factor(); |
| 64 | |
| 65 | static void check_concurrent_work(); |
| 66 | static void trigger_concurrent_work(); |
| 67 | static void do_concurrent_work(JavaThread* jt); |
| 68 | |
| 69 | static void grow(JavaThread* jt); |
| 70 | static void clean_dead_entries(JavaThread* jt); |
| 71 | |
| 72 | // GC Notification |
| 73 | |
| 74 | // Must be called before a parallel walk where objects might die. |
| 75 | static void reset_dead_counter(); |
| 76 | // After the parallel walk this method must be called to trigger |
| 77 | // cleaning. Note it might trigger a resize instead. |
| 78 | static void finish_dead_counter(); |
| 79 | // If GC uses ParState directly it should add the number of cleared |
| 80 | // entries to this method. |
| 81 | static void inc_dead_counter(size_t ndead); |
| 82 | |
| 83 | // JVMTI Support - It is called at safepoint only for RedefineClasses |
| 84 | JVMTI_ONLY(static void adjust_method_entries(bool * trace_name_printed);) |
| 85 | |
| 86 | // Debugging |
| 87 | static size_t items_count(); |
| 88 | static void verify(); |
| 89 | }; |
| 90 | |
| 91 | #endif // SHARE_PRIMS_RESOLVEDMETHODTABLE_HPP |
| 92 | |