@@ -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
@@ -516,7 +504,7 @@ void OopMapCache::lookup(const methodHandle& method,
516504 for (int i = 0 ; i < _probe_depth; i++) {
517505 OopMapCacheEntry *entry = entry_at (probe + i);
518506 if (entry != nullptr && !entry->is_empty () && entry->match (method, bci)) {
519- entry_for->resource_copy (entry);
507+ entry_for->copy_from (entry);
520508 assert (!entry_for->is_empty (), " A non-empty oop map should be returned" );
521509 log_debug (interpreter, oopmap)(" - found at hash %d" , probe + i);
522510 return ;
@@ -530,7 +518,7 @@ void OopMapCache::lookup(const methodHandle& method,
530518 OopMapCacheEntry* tmp = NEW_C_HEAP_OBJ (OopMapCacheEntry, mtClass);
531519 tmp->initialize ();
532520 tmp->fill (method, bci);
533- entry_for->resource_copy (tmp);
521+ entry_for->copy_from (tmp);
534522
535523 if (method->should_not_be_cached ()) {
536524 // It is either not safe or not a good idea to cache this Method*
@@ -631,7 +619,7 @@ void OopMapCache::compute_one_oop_map(const methodHandle& method, int bci, Inter
631619 tmp->initialize ();
632620 tmp->fill (method, bci);
633621 if (tmp->has_valid_mask ()) {
634- entry->resource_copy (tmp);
622+ entry->copy_from (tmp);
635623 }
636624 OopMapCacheEntry::deallocate (tmp);
637625}
0 commit comments