@@ -66,9 +66,6 @@ class OopMapCacheEntry: private InterpreterOopMap {
6666 public:
6767 OopMapCacheEntry () : InterpreterOopMap() {
6868 _next = nullptr ;
69- #ifdef ASSERT
70- _resource_allocate_bit_mask = false ;
71- #endif
7269 }
7370};
7471
@@ -177,9 +174,13 @@ class VerifyClosure : public OffsetClosure {
177174
178175InterpreterOopMap::InterpreterOopMap () {
179176 initialize ();
180- #ifdef ASSERT
181- _resource_allocate_bit_mask = true ;
182- #endif
177+ }
178+
179+ InterpreterOopMap::~InterpreterOopMap () {
180+ if (has_valid_mask () && mask_size () > small_mask_limit) {
181+ assert (_bit_mask[0 ] != 0 , " should have pointer to C heap" );
182+ FREE_C_HEAP_ARRAY (uintptr_t , _bit_mask[0 ]);
183+ }
183184}
184185
185186bool InterpreterOopMap::is_empty () const {
@@ -399,37 +400,24 @@ void OopMapCacheEntry::deallocate(OopMapCacheEntry* const entry) {
399400
400401// Implementation of OopMapCache
401402
402- void InterpreterOopMap::resource_copy ( OopMapCacheEntry* from ) {
403- assert (_resource_allocate_bit_mask,
404- " Should not resource allocate the _bit_mask " );
405- assert (from-> has_valid_mask (),
406- " Cannot copy entry with an invalid mask" );
403+ void InterpreterOopMap::copy_from ( const OopMapCacheEntry* src ) {
404+ // The expectation is that this InterpreterOopMap is recently created
405+ // and empty. It is used to get a copy of a cached entry.
406+ assert (! has_valid_mask (), " InterpreterOopMap object can only be filled once " );
407+ assert (src-> has_valid_mask (), " Cannot copy entry with an invalid mask" );
407408
408- set_method (from ->method ());
409- set_bci (from ->bci ());
410- set_mask_size (from ->mask_size ());
411- set_expression_stack_size (from ->expression_stack_size ());
412- _num_oops = from ->num_oops ();
409+ set_method (src ->method ());
410+ set_bci (src ->bci ());
411+ set_mask_size (src ->mask_size ());
412+ set_expression_stack_size (src ->expression_stack_size ());
413+ _num_oops = src ->num_oops ();
413414
414415 // Is the bit mask contained in the entry?
415- if (from->mask_size () <= small_mask_limit) {
416- memcpy ((void *)_bit_mask, (void *)from->_bit_mask ,
417- mask_word_size () * BytesPerWord);
416+ if (src->mask_size () <= small_mask_limit) {
417+ memcpy (_bit_mask, src->_bit_mask , mask_word_size () * BytesPerWord);
418418 } else {
419- // The expectation is that this InterpreterOopMap is a recently created
420- // and empty. It is used to get a copy of a cached entry.
421- // If the bit mask has a value, it should be in the
422- // resource area.
423- assert (_bit_mask[0 ] == 0 ||
424- Thread::current ()->resource_area ()->contains ((void *)_bit_mask[0 ]),
425- " The bit mask should have been allocated from a resource area" );
426- // Allocate the bit_mask from a Resource area for performance. Allocating
427- // from the C heap as is done for OopMapCache has a significant
428- // performance impact.
429- _bit_mask[0 ] = (uintptr_t ) NEW_RESOURCE_ARRAY (uintptr_t , mask_word_size ());
430- assert (_bit_mask[0 ] != 0 , " bit mask was not allocated" );
431- memcpy ((void *) _bit_mask[0 ], (void *) from->_bit_mask [0 ],
432- mask_word_size () * BytesPerWord);
419+ _bit_mask[0 ] = (uintptr_t ) NEW_C_HEAP_ARRAY (uintptr_t , mask_word_size (), mtClass);
420+ memcpy ((void *) _bit_mask[0 ], (void *) src->_bit_mask [0 ], mask_word_size () * BytesPerWord);
433421 }
434422}
435423
@@ -512,7 +500,7 @@ void OopMapCache::lookup(const methodHandle& method,
512500 for (int i = 0 ; i < probe_depth; i++) {
513501 OopMapCacheEntry *entry = entry_at (probe + i);
514502 if (entry != nullptr && !entry->is_empty () && entry->match (method, bci)) {
515- entry_for->resource_copy (entry);
503+ entry_for->copy_from (entry);
516504 assert (!entry_for->is_empty (), " A non-empty oop map should be returned" );
517505 log_debug (interpreter, oopmap)(" - found at hash %d" , probe + i);
518506 return ;
@@ -526,7 +514,7 @@ void OopMapCache::lookup(const methodHandle& method,
526514 OopMapCacheEntry* tmp = NEW_C_HEAP_OBJ (OopMapCacheEntry, mtClass);
527515 tmp->initialize ();
528516 tmp->fill (method, bci);
529- entry_for->resource_copy (tmp);
517+ entry_for->copy_from (tmp);
530518
531519 if (method->should_not_be_cached ()) {
532520 // It is either not safe or not a good idea to cache this Method*
@@ -627,7 +615,7 @@ void OopMapCache::compute_one_oop_map(const methodHandle& method, int bci, Inter
627615 tmp->initialize ();
628616 tmp->fill (method, bci);
629617 if (tmp->has_valid_mask ()) {
630- entry->resource_copy (tmp);
618+ entry->copy_from (tmp);
631619 }
632620 OopMapCacheEntry::deallocate (tmp);
633621}
0 commit comments