8335007: Inline OopMapCache table

Reviewed-by: stefank, coleenp, shade
This commit is contained in:
Thomas Stuefe
2024-06-27 12:56:26 +00:00
parent 79a23017fc
commit 50dd962b0d
2 changed files with 12 additions and 17 deletions

View File

@@ -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
@@ -445,29 +445,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
@@ -478,7 +474,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
@@ -513,7 +509,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);
@@ -542,7 +538,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)) {

View File

@@ -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
@@ -152,11 +152,10 @@ class InterpreterOopMap: ResourceObj {
class OopMapCache : public CHeapObj<mtClass> {
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;