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
@@ -445,29 +445,25 @@ inline unsigned int OopMapCache::hash_value_for(const methodHandle& method, int
445
445
OopMapCacheEntry* volatile OopMapCache::_old_entries = nullptr ;
446
446
447
447
OopMapCache::OopMapCache () {
448
- _array = NEW_C_HEAP_ARRAY (OopMapCacheEntry*, _size, mtClass);
449
- for (int i = 0 ; i < _size; i++) _array[i] = nullptr ;
448
+ for (int i = 0 ; i < size; i++) _array[i] = nullptr ;
450
449
}
451
450
452
451
453
452
OopMapCache::~OopMapCache () {
454
- assert (_array != nullptr , " sanity check" );
455
453
// Deallocate oop maps that are allocated out-of-line
456
454
flush ();
457
- // Deallocate array
458
- FREE_C_HEAP_ARRAY (OopMapCacheEntry*, _array);
459
455
}
460
456
461
457
OopMapCacheEntry* OopMapCache::entry_at (int i) const {
462
- return Atomic::load_acquire (&(_array[i % _size ]));
458
+ return Atomic::load_acquire (&(_array[i % size ]));
463
459
}
464
460
465
461
bool OopMapCache::put_at (int i, OopMapCacheEntry* entry, OopMapCacheEntry* old) {
466
- return Atomic::cmpxchg (&_array[i % _size ], old, entry) == old;
462
+ return Atomic::cmpxchg (&_array[i % size ], old, entry) == old;
467
463
}
468
464
469
465
void OopMapCache::flush () {
470
- for (int i = 0 ; i < _size ; i++) {
466
+ for (int i = 0 ; i < size ; i++) {
471
467
OopMapCacheEntry* entry = _array[i];
472
468
if (entry != nullptr ) {
473
469
_array[i] = nullptr ; // no barrier, only called in OopMapCache destructor
@@ -478,7 +474,7 @@ void OopMapCache::flush() {
478
474
479
475
void OopMapCache::flush_obsolete_entries () {
480
476
assert (SafepointSynchronize::is_at_safepoint (), " called by RedefineClasses in a safepoint" );
481
- for (int i = 0 ; i < _size ; i++) {
477
+ for (int i = 0 ; i < size ; i++) {
482
478
OopMapCacheEntry* entry = _array[i];
483
479
if (entry != nullptr && !entry->is_empty () && entry->method ()->is_old ()) {
484
480
// Cache entry is occupied by an old redefined method and we don't want
@@ -513,7 +509,7 @@ void OopMapCache::lookup(const methodHandle& method,
513
509
// Need a critical section to avoid race against concurrent reclamation.
514
510
{
515
511
GlobalCounter::CriticalSection cs (Thread::current ());
516
- for (int i = 0 ; i < _probe_depth ; i++) {
512
+ for (int i = 0 ; i < probe_depth ; i++) {
517
513
OopMapCacheEntry *entry = entry_at (probe + i);
518
514
if (entry != nullptr && !entry->is_empty () && entry->match (method, bci)) {
519
515
entry_for->resource_copy (entry);
@@ -542,7 +538,7 @@ void OopMapCache::lookup(const methodHandle& method,
542
538
}
543
539
544
540
// First search for an empty slot
545
- for (int i = 0 ; i < _probe_depth ; i++) {
541
+ for (int i = 0 ; i < probe_depth ; i++) {
546
542
OopMapCacheEntry* entry = entry_at (probe + i);
547
543
if (entry == nullptr ) {
548
544
if (put_at (probe + i, tmp, nullptr )) {
0 commit comments