@@ -66,9 +66,6 @@ class OopMapCacheEntry: private InterpreterOopMap {
66
66
public:
67
67
OopMapCacheEntry () : InterpreterOopMap() {
68
68
_next = nullptr ;
69
- #ifdef ASSERT
70
- _resource_allocate_bit_mask = false ;
71
- #endif
72
69
}
73
70
};
74
71
@@ -177,9 +174,13 @@ class VerifyClosure : public OffsetClosure {
177
174
178
175
InterpreterOopMap::InterpreterOopMap () {
179
176
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
+ }
183
184
}
184
185
185
186
bool InterpreterOopMap::is_empty () const {
@@ -399,37 +400,24 @@ void OopMapCacheEntry::deallocate(OopMapCacheEntry* const entry) {
399
400
400
401
// Implementation of OopMapCache
401
402
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" );
407
408
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 ();
413
414
414
415
// 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);
418
418
} 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);
433
421
}
434
422
}
435
423
@@ -516,7 +504,7 @@ void OopMapCache::lookup(const methodHandle& method,
516
504
for (int i = 0 ; i < _probe_depth; i++) {
517
505
OopMapCacheEntry *entry = entry_at (probe + i);
518
506
if (entry != nullptr && !entry->is_empty () && entry->match (method, bci)) {
519
- entry_for->resource_copy (entry);
507
+ entry_for->copy_from (entry);
520
508
assert (!entry_for->is_empty (), " A non-empty oop map should be returned" );
521
509
log_debug (interpreter, oopmap)(" - found at hash %d" , probe + i);
522
510
return ;
@@ -530,7 +518,7 @@ void OopMapCache::lookup(const methodHandle& method,
530
518
OopMapCacheEntry* tmp = NEW_C_HEAP_OBJ (OopMapCacheEntry, mtClass);
531
519
tmp->initialize ();
532
520
tmp->fill (method, bci);
533
- entry_for->resource_copy (tmp);
521
+ entry_for->copy_from (tmp);
534
522
535
523
if (method->should_not_be_cached ()) {
536
524
// 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
631
619
tmp->initialize ();
632
620
tmp->fill (method, bci);
633
621
if (tmp->has_valid_mask ()) {
634
- entry->resource_copy (tmp);
622
+ entry->copy_from (tmp);
635
623
}
636
624
OopMapCacheEntry::deallocate (tmp);
637
625
}
0 commit comments