35 // Interface for creating and resolving local/global JNI handles |
35 // Interface for creating and resolving local/global JNI handles |
36 |
36 |
37 class JNIHandles : AllStatic { |
37 class JNIHandles : AllStatic { |
38 friend class VMStructs; |
38 friend class VMStructs; |
39 private: |
39 private: |
|
40 // These are used by the serviceability agent. |
40 static OopStorage* _global_handles; |
41 static OopStorage* _global_handles; |
41 static OopStorage* _weak_global_handles; |
42 static OopStorage* _weak_global_handles; |
|
43 friend void jni_handles_init(); |
42 |
44 |
43 inline static bool is_jweak(jobject handle); |
45 inline static bool is_jweak(jobject handle); |
44 inline static oop* jobject_ptr(jobject handle); // NOT jweak! |
46 inline static oop* jobject_ptr(jobject handle); // NOT jweak! |
45 inline static oop* jweak_ptr(jobject handle); |
47 inline static oop* jweak_ptr(jobject handle); |
46 |
48 |
120 static void oops_do(OopClosure* f); |
122 static void oops_do(OopClosure* f); |
121 // Traversal of weak global handles. Unreachable oops are cleared. |
123 // Traversal of weak global handles. Unreachable oops are cleared. |
122 static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f); |
124 static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* f); |
123 // Traversal of weak global handles. |
125 // Traversal of weak global handles. |
124 static void weak_oops_do(OopClosure* f); |
126 static void weak_oops_do(OopClosure* f); |
125 |
|
126 static OopStorage* global_handles(); |
|
127 static OopStorage* weak_global_handles(); |
|
128 }; |
127 }; |
129 |
128 |
130 |
129 |
131 |
130 |
132 // JNI handle blocks holding local/global JNI handles |
131 // JNI handle blocks holding local/global JNI handles |
138 private: |
137 private: |
139 enum SomeConstants { |
138 enum SomeConstants { |
140 block_size_in_oops = 32 // Number of handles per handle block |
139 block_size_in_oops = 32 // Number of handles per handle block |
141 }; |
140 }; |
142 |
141 |
143 oop _handles[block_size_in_oops]; // The handles |
142 uintptr_t _handles[block_size_in_oops]; // The handles |
144 int _top; // Index of next unused handle |
143 int _top; // Index of next unused handle |
145 JNIHandleBlock* _next; // Link to next block |
144 JNIHandleBlock* _next; // Link to next block |
146 |
145 |
147 // The following instance variables are only used by the first block in a chain. |
146 // The following instance variables are only used by the first block in a chain. |
148 // Having two types of blocks complicates the code and the space overhead in negligible. |
147 // Having two types of blocks complicates the code and the space overhead in negligible. |
149 JNIHandleBlock* _last; // Last block in use |
148 JNIHandleBlock* _last; // Last block in use |
150 JNIHandleBlock* _pop_frame_link; // Block to restore on PopLocalFrame call |
149 JNIHandleBlock* _pop_frame_link; // Block to restore on PopLocalFrame call |
151 oop* _free_list; // Handle free list |
150 uintptr_t* _free_list; // Handle free list |
152 int _allocate_before_rebuild; // Number of blocks to allocate before rebuilding free list |
151 int _allocate_before_rebuild; // Number of blocks to allocate before rebuilding free list |
153 |
152 |
154 // Check JNI, "planned capacity" for current frame (or push/ensure) |
153 // Check JNI, "planned capacity" for current frame (or push/ensure) |
155 size_t _planned_capacity; |
154 size_t _planned_capacity; |
156 |
155 |