11/*
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.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * 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
445445OopMapCacheEntry* volatile OopMapCache::_old_entries = nullptr ;
446446
447447OopMapCache::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 ;
450449}
451450
452451
453452OopMapCache::~OopMapCache () {
454- assert (_array != nullptr , " sanity check" );
455453 // Deallocate oop maps that are allocated out-of-line
456454 flush ();
457- // Deallocate array
458- FREE_C_HEAP_ARRAY (OopMapCacheEntry*, _array);
459455}
460456
461457OopMapCacheEntry* OopMapCache::entry_at (int i) const {
462- return Atomic::load_acquire (&(_array[i % _size ]));
458+ return Atomic::load_acquire (&(_array[i % size ]));
463459}
464460
465461bool 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;
467463}
468464
469465void OopMapCache::flush () {
470- for (int i = 0 ; i < _size ; i++) {
466+ for (int i = 0 ; i < size ; i++) {
471467 OopMapCacheEntry* entry = _array[i];
472468 if (entry != nullptr ) {
473469 _array[i] = nullptr ; // no barrier, only called in OopMapCache destructor
@@ -478,7 +474,7 @@ void OopMapCache::flush() {
478474
479475void OopMapCache::flush_obsolete_entries () {
480476 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++) {
482478 OopMapCacheEntry* entry = _array[i];
483479 if (entry != nullptr && !entry->is_empty () && entry->method ()->is_old ()) {
484480 // Cache entry is occupied by an old redefined method and we don't want
@@ -513,7 +509,7 @@ void OopMapCache::lookup(const methodHandle& method,
513509 // Need a critical section to avoid race against concurrent reclamation.
514510 {
515511 GlobalCounter::CriticalSection cs (Thread::current ());
516- for (int i = 0 ; i < _probe_depth ; i++) {
512+ for (int i = 0 ; i < probe_depth ; i++) {
517513 OopMapCacheEntry *entry = entry_at (probe + i);
518514 if (entry != nullptr && !entry->is_empty () && entry->match (method, bci)) {
519515 entry_for->resource_copy (entry);
@@ -542,7 +538,7 @@ void OopMapCache::lookup(const methodHandle& method,
542538 }
543539
544540 // First search for an empty slot
545- for (int i = 0 ; i < _probe_depth ; i++) {
541+ for (int i = 0 ; i < probe_depth ; i++) {
546542 OopMapCacheEntry* entry = entry_at (probe + i);
547543 if (entry == nullptr ) {
548544 if (put_at (probe + i, tmp, nullptr )) {
0 commit comments