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