250 #else
251 oop* allocate_handle(oop obj) { return real_allocate_handle(obj); }
252 #endif
253
254 // Garbage collection support
255 void oops_do(OopClosure* f);
256
257 // Number of handles in use
258 size_t used() const { return Arena::used() / oopSize; }
259
260 debug_only(bool no_handle_mark_active() { return _no_handle_mark_nesting > 0; })
261 };
262
263
264 //------------------------------------------------------------------------------------------------------------------------
265 // Handles are allocated in a (growable) thread local handle area. Deallocation
266 // is managed using a HandleMark. It should normally not be necessary to use
267 // HandleMarks manually.
268 //
269 // A HandleMark constructor will record the current handle area top, and the
270 // desctructor will reset the top, destroying all handles allocated in between.
271 // The following code will therefore NOT work:
272 //
273 // Handle h;
274 // {
275 // HandleMark hm;
276 // h = Handle(obj);
277 // }
278 // h()->print(); // WRONG, h destroyed by HandleMark destructor.
279 //
280 // If h has to be preserved, it can be converted to an oop or a local JNI handle
281 // across the HandleMark boundary.
282
283 // The base class of HandleMark should have been StackObj but we also heap allocate
284 // a HandleMark when a thread is created. The operator new is for this special case.
285
286 class HandleMark {
287 private:
288 Thread *_thread; // thread that owns this mark
289 HandleArea *_area; // saved handle area
290 Chunk *_chunk; // saved arena chunk
|
250 #else
251 oop* allocate_handle(oop obj) { return real_allocate_handle(obj); }
252 #endif
253
254 // Garbage collection support
255 void oops_do(OopClosure* f);
256
257 // Number of handles in use
258 size_t used() const { return Arena::used() / oopSize; }
259
260 debug_only(bool no_handle_mark_active() { return _no_handle_mark_nesting > 0; })
261 };
262
263
264 //------------------------------------------------------------------------------------------------------------------------
265 // Handles are allocated in a (growable) thread local handle area. Deallocation
266 // is managed using a HandleMark. It should normally not be necessary to use
267 // HandleMarks manually.
268 //
269 // A HandleMark constructor will record the current handle area top, and the
270 // destructor will reset the top, destroying all handles allocated in between.
271 // The following code will therefore NOT work:
272 //
273 // Handle h;
274 // {
275 // HandleMark hm;
276 // h = Handle(obj);
277 // }
278 // h()->print(); // WRONG, h destroyed by HandleMark destructor.
279 //
280 // If h has to be preserved, it can be converted to an oop or a local JNI handle
281 // across the HandleMark boundary.
282
283 // The base class of HandleMark should have been StackObj but we also heap allocate
284 // a HandleMark when a thread is created. The operator new is for this special case.
285
286 class HandleMark {
287 private:
288 Thread *_thread; // thread that owns this mark
289 HandleArea *_area; // saved handle area
290 Chunk *_chunk; // saved arena chunk
|