Skip to content

Commit 50dd962

Browse files
committed
8335007: Inline OopMapCache table
Reviewed-by: stefank, coleenp, shade
1 parent 79a2301 commit 50dd962

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

src/hotspot/share/interpreter/oopMapCache.cpp

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
445445
OopMapCacheEntry* volatile OopMapCache::_old_entries = nullptr;
446446

447447
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;
450449
}
451450

452451

453452
OopMapCache::~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

461457
OopMapCacheEntry* OopMapCache::entry_at(int i) const {
462-
return Atomic::load_acquire(&(_array[i % _size]));
458+
return Atomic::load_acquire(&(_array[i % size]));
463459
}
464460

465461
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;
467463
}
468464

469465
void 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

479475
void 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)) {

src/hotspot/share/interpreter/oopMapCache.hpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
@@ -152,11 +152,10 @@ class InterpreterOopMap: ResourceObj {
152152
class OopMapCache : public CHeapObj<mtClass> {
153153
static OopMapCacheEntry* volatile _old_entries;
154154
private:
155-
enum { _size = 32, // Use fixed size for now
156-
_probe_depth = 3 // probe depth in case of collisions
157-
};
155+
static constexpr int size = 32; // Use fixed size for now
156+
static constexpr int probe_depth = 3; // probe depth in case of collisions
158157

159-
OopMapCacheEntry* volatile * _array;
158+
OopMapCacheEntry* volatile _array[size];
160159

161160
unsigned int hash_value_for(const methodHandle& method, int bci) const;
162161
OopMapCacheEntry* entry_at(int i) const;

0 commit comments

Comments
 (0)