1
1
/*
2
- * Copyright (c) 1997, 2023 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 1997, 2024 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -433,29 +433,25 @@ inline unsigned int OopMapCache::hash_value_for(const methodHandle& method, int
433
433
OopMapCacheEntry* volatile OopMapCache::_old_entries = nullptr ;
434
434
435
435
OopMapCache::OopMapCache () {
436
- _array = NEW_C_HEAP_ARRAY (OopMapCacheEntry*, _size, mtClass);
437
- for (int i = 0 ; i < _size; i++) _array[i] = nullptr ;
436
+ for (int i = 0 ; i < size; i++) _array[i] = nullptr ;
438
437
}
439
438
440
439
441
440
OopMapCache::~OopMapCache () {
442
- assert (_array != nullptr , " sanity check" );
443
441
// Deallocate oop maps that are allocated out-of-line
444
442
flush ();
445
- // Deallocate array
446
- FREE_C_HEAP_ARRAY (OopMapCacheEntry*, _array);
447
443
}
448
444
449
445
OopMapCacheEntry* OopMapCache::entry_at (int i) const {
450
- return Atomic::load_acquire (&(_array[i % _size ]));
446
+ return Atomic::load_acquire (&(_array[i % size ]));
451
447
}
452
448
453
449
bool OopMapCache::put_at (int i, OopMapCacheEntry* entry, OopMapCacheEntry* old) {
454
- return Atomic::cmpxchg (&_array[i % _size ], old, entry) == old;
450
+ return Atomic::cmpxchg (&_array[i % size ], old, entry) == old;
455
451
}
456
452
457
453
void OopMapCache::flush () {
458
- for (int i = 0 ; i < _size ; i++) {
454
+ for (int i = 0 ; i < size ; i++) {
459
455
OopMapCacheEntry* entry = _array[i];
460
456
if (entry != nullptr ) {
461
457
_array[i] = nullptr ; // no barrier, only called in OopMapCache destructor
@@ -466,7 +462,7 @@ void OopMapCache::flush() {
466
462
467
463
void OopMapCache::flush_obsolete_entries () {
468
464
assert (SafepointSynchronize::is_at_safepoint (), " called by RedefineClasses in a safepoint" );
469
- for (int i = 0 ; i < _size ; i++) {
465
+ for (int i = 0 ; i < size ; i++) {
470
466
OopMapCacheEntry* entry = _array[i];
471
467
if (entry != nullptr && !entry->is_empty () && entry->method ()->is_old ()) {
472
468
// Cache entry is occupied by an old redefined method and we don't want
@@ -501,7 +497,7 @@ void OopMapCache::lookup(const methodHandle& method,
501
497
// Need a critical section to avoid race against concurrent reclamation.
502
498
{
503
499
GlobalCounter::CriticalSection cs (Thread::current ());
504
- for (int i = 0 ; i < _probe_depth ; i++) {
500
+ for (int i = 0 ; i < probe_depth ; i++) {
505
501
OopMapCacheEntry *entry = entry_at (probe + i);
506
502
if (entry != nullptr && !entry->is_empty () && entry->match (method, bci)) {
507
503
entry_for->copy_from (entry);
@@ -530,7 +526,7 @@ void OopMapCache::lookup(const methodHandle& method,
530
526
}
531
527
532
528
// First search for an empty slot
533
- for (int i = 0 ; i < _probe_depth ; i++) {
529
+ for (int i = 0 ; i < probe_depth ; i++) {
534
530
OopMapCacheEntry* entry = entry_at (probe + i);
535
531
if (entry == nullptr ) {
536
532
if (put_at (probe + i, tmp, nullptr )) {
0 commit comments