diff --git a/src/hotspot/share/interpreter/oopMapCache.cpp b/src/hotspot/share/interpreter/oopMapCache.cpp index 4c6f9bac59b..f79877df910 100644 --- a/src/hotspot/share/interpreter/oopMapCache.cpp +++ b/src/hotspot/share/interpreter/oopMapCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * 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 OopMapCacheEntry* volatile OopMapCache::_old_entries = nullptr; OopMapCache::OopMapCache() { - _array = NEW_C_HEAP_ARRAY(OopMapCacheEntry*, _size, mtClass); - for(int i = 0; i < _size; i++) _array[i] = nullptr; + for(int i = 0; i < size; i++) _array[i] = nullptr; } OopMapCache::~OopMapCache() { - assert(_array != nullptr, "sanity check"); // Deallocate oop maps that are allocated out-of-line flush(); - // Deallocate array - FREE_C_HEAP_ARRAY(OopMapCacheEntry*, _array); } OopMapCacheEntry* OopMapCache::entry_at(int i) const { - return Atomic::load_acquire(&(_array[i % _size])); + return Atomic::load_acquire(&(_array[i % size])); } bool OopMapCache::put_at(int i, OopMapCacheEntry* entry, OopMapCacheEntry* old) { - return Atomic::cmpxchg(&_array[i % _size], old, entry) == old; + return Atomic::cmpxchg(&_array[i % size], old, entry) == old; } void OopMapCache::flush() { - for (int i = 0; i < _size; i++) { + for (int i = 0; i < size; i++) { OopMapCacheEntry* entry = _array[i]; if (entry != nullptr) { _array[i] = nullptr; // no barrier, only called in OopMapCache destructor @@ -474,7 +470,7 @@ void OopMapCache::flush() { void OopMapCache::flush_obsolete_entries() { assert(SafepointSynchronize::is_at_safepoint(), "called by RedefineClasses in a safepoint"); - for (int i = 0; i < _size; i++) { + for (int i = 0; i < size; i++) { OopMapCacheEntry* entry = _array[i]; if (entry != nullptr && !entry->is_empty() && entry->method()->is_old()) { // Cache entry is occupied by an old redefined method and we don't want @@ -509,7 +505,7 @@ void OopMapCache::lookup(const methodHandle& method, // Need a critical section to avoid race against concurrent reclamation. { GlobalCounter::CriticalSection cs(Thread::current()); - for (int i = 0; i < _probe_depth; i++) { + for (int i = 0; i < probe_depth; i++) { OopMapCacheEntry *entry = entry_at(probe + i); if (entry != nullptr && !entry->is_empty() && entry->match(method, bci)) { entry_for->resource_copy(entry); @@ -538,7 +534,7 @@ void OopMapCache::lookup(const methodHandle& method, } // First search for an empty slot - for (int i = 0; i < _probe_depth; i++) { + for (int i = 0; i < probe_depth; i++) { OopMapCacheEntry* entry = entry_at(probe + i); if (entry == nullptr) { if (put_at(probe + i, tmp, nullptr)) { diff --git a/src/hotspot/share/interpreter/oopMapCache.hpp b/src/hotspot/share/interpreter/oopMapCache.hpp index e72fcaafc30..563fd236ca0 100644 --- a/src/hotspot/share/interpreter/oopMapCache.hpp +++ b/src/hotspot/share/interpreter/oopMapCache.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -148,11 +148,10 @@ class InterpreterOopMap: ResourceObj { class OopMapCache : public CHeapObj { static OopMapCacheEntry* volatile _old_entries; private: - enum { _size = 32, // Use fixed size for now - _probe_depth = 3 // probe depth in case of collisions - }; + static constexpr int size = 32; // Use fixed size for now + static constexpr int probe_depth = 3; // probe depth in case of collisions - OopMapCacheEntry* volatile * _array; + OopMapCacheEntry* volatile _array[size]; unsigned int hash_value_for(const methodHandle& method, int bci) const; OopMapCacheEntry* entry_at(int i) const;