23 */ |
23 */ |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "classfile/javaClasses.hpp" |
26 #include "classfile/javaClasses.hpp" |
27 #include "gc/shared/oopStorage.inline.hpp" |
27 #include "gc/shared/oopStorage.inline.hpp" |
|
28 #include "gc/shared/oopStorageSet.hpp" |
28 #include "logging/log.hpp" |
29 #include "logging/log.hpp" |
29 #include "memory/allocation.hpp" |
30 #include "memory/allocation.hpp" |
30 #include "memory/resourceArea.hpp" |
31 #include "memory/resourceArea.hpp" |
31 #include "memory/universe.hpp" |
32 #include "memory/universe.hpp" |
32 #include "oops/access.inline.hpp" |
33 #include "oops/access.inline.hpp" |
|
34 #include "oops/method.hpp" |
33 #include "oops/oop.inline.hpp" |
35 #include "oops/oop.inline.hpp" |
34 #include "oops/method.hpp" |
|
35 #include "oops/weakHandle.inline.hpp" |
36 #include "oops/weakHandle.inline.hpp" |
36 #include "prims/resolvedMethodTable.hpp" |
37 #include "prims/resolvedMethodTable.hpp" |
37 #include "runtime/handles.inline.hpp" |
38 #include "runtime/handles.inline.hpp" |
38 #include "runtime/interfaceSupport.inline.hpp" |
39 #include "runtime/interfaceSupport.inline.hpp" |
39 #include "runtime/mutexLocker.hpp" |
40 #include "runtime/mutexLocker.hpp" |
54 unsigned int name_hash = method->name()->identity_hash(); |
55 unsigned int name_hash = method->name()->identity_hash(); |
55 unsigned int signature_hash = method->signature()->identity_hash(); |
56 unsigned int signature_hash = method->signature()->identity_hash(); |
56 return name_hash ^ signature_hash; |
57 return name_hash ^ signature_hash; |
57 } |
58 } |
58 |
59 |
59 typedef ConcurrentHashTable<WeakHandle<vm_resolved_method_table_data>, |
60 typedef ConcurrentHashTable<ResolvedMethodTableConfig, |
60 ResolvedMethodTableConfig, |
|
61 mtClass> ResolvedMethodTableHash; |
61 mtClass> ResolvedMethodTableHash; |
62 |
62 |
63 class ResolvedMethodTableConfig : public ResolvedMethodTableHash::BaseConfig { |
63 class ResolvedMethodTableConfig : public AllStatic { |
64 private: |
64 private: |
65 public: |
65 public: |
66 static uintx get_hash(WeakHandle<vm_resolved_method_table_data> const& value, |
66 typedef WeakHandle<vm_resolved_method_table_data> Value; |
67 bool* is_dead) { |
67 |
|
68 static uintx get_hash(Value const& value, bool* is_dead) { |
68 oop val_oop = value.peek(); |
69 oop val_oop = value.peek(); |
69 if (val_oop == NULL) { |
70 if (val_oop == NULL) { |
70 *is_dead = true; |
71 *is_dead = true; |
71 return 0; |
72 return 0; |
72 } |
73 } |
74 Method* method = java_lang_invoke_ResolvedMethodName::vmtarget(val_oop); |
75 Method* method = java_lang_invoke_ResolvedMethodName::vmtarget(val_oop); |
75 return method_hash(method); |
76 return method_hash(method); |
76 } |
77 } |
77 |
78 |
78 // We use default allocation/deallocation but counted |
79 // We use default allocation/deallocation but counted |
79 static void* allocate_node(size_t size, WeakHandle<vm_resolved_method_table_data> const& value) { |
80 static void* allocate_node(size_t size, Value const& value) { |
80 ResolvedMethodTable::item_added(); |
81 ResolvedMethodTable::item_added(); |
81 return ResolvedMethodTableHash::BaseConfig::allocate_node(size, value); |
82 return AllocateHeap(size, mtClass); |
82 } |
83 } |
83 static void free_node(void* memory, WeakHandle<vm_resolved_method_table_data> const& value) { |
84 static void free_node(void* memory, Value const& value) { |
84 value.release(); |
85 value.release(); |
85 ResolvedMethodTableHash::BaseConfig::free_node(memory, value); |
86 FreeHeap(memory); |
86 ResolvedMethodTable::item_removed(); |
87 ResolvedMethodTable::item_removed(); |
87 } |
88 } |
88 }; |
89 }; |
89 |
90 |
90 static ResolvedMethodTableHash* _local_table = NULL; |
91 static ResolvedMethodTableHash* _local_table = NULL; |
91 static size_t _current_size = (size_t)1 << ResolvedMethodTableSizeLog; |
92 static size_t _current_size = (size_t)1 << ResolvedMethodTableSizeLog; |
92 |
93 |
93 OopStorage* ResolvedMethodTable::_weak_handles = NULL; |
|
94 volatile bool ResolvedMethodTable::_has_work = false; |
94 volatile bool ResolvedMethodTable::_has_work = false; |
95 |
95 |
96 volatile size_t _items_count = 0; |
96 volatile size_t _items_count = 0; |
97 volatile size_t _uncleaned_items_count = 0; |
97 volatile size_t _uncleaned_items_count = 0; |
98 |
98 |
99 void ResolvedMethodTable::create_table() { |
99 void ResolvedMethodTable::create_table() { |
100 _local_table = new ResolvedMethodTableHash(ResolvedMethodTableSizeLog, END_SIZE, GROW_HINT); |
100 _local_table = new ResolvedMethodTableHash(ResolvedMethodTableSizeLog, END_SIZE, GROW_HINT); |
101 _weak_handles = new OopStorage("ResolvedMethodTable weak", |
|
102 ResolvedMethodTableWeakAlloc_lock, |
|
103 ResolvedMethodTableWeakActive_lock); |
|
104 log_trace(membername, table)("Start size: " SIZE_FORMAT " (" SIZE_FORMAT ")", |
101 log_trace(membername, table)("Start size: " SIZE_FORMAT " (" SIZE_FORMAT ")", |
105 _current_size, ResolvedMethodTableSizeLog); |
102 _current_size, ResolvedMethodTableSizeLog); |
106 } |
103 } |
107 |
104 |
108 size_t ResolvedMethodTable::table_size() { |
105 size_t ResolvedMethodTable::table_size() { |