Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
/ jdk23u Public archive

Commit 045c990

Browse files
committed
8335007: Inline OopMapCache table
Backport-of: 50dd962
1 parent 5098e8c commit 045c990

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
@@ -433,29 +433,25 @@ inline unsigned int OopMapCache::hash_value_for(const methodHandle& method, int
433433
OopMapCacheEntry* volatile OopMapCache::_old_entries = nullptr;
434434

435435
OopMapCache::OopMapCache() {
436-
_array = NEW_C_HEAP_ARRAY(OopMapCacheEntry*, _size, mtClass);
437-
for(int i = 0; i < _size; i++) _array[i] = nullptr;
436+
for(int i = 0; i < size; i++) _array[i] = nullptr;
438437
}
439438

440439

441440
OopMapCache::~OopMapCache() {
442-
assert(_array != nullptr, "sanity check");
443441
// Deallocate oop maps that are allocated out-of-line
444442
flush();
445-
// Deallocate array
446-
FREE_C_HEAP_ARRAY(OopMapCacheEntry*, _array);
447443
}
448444

449445
OopMapCacheEntry* OopMapCache::entry_at(int i) const {
450-
return Atomic::load_acquire(&(_array[i % _size]));
446+
return Atomic::load_acquire(&(_array[i % size]));
451447
}
452448

453449
bool OopMapCache::put_at(int i, OopMapCacheEntry* entry, OopMapCacheEntry* old) {
454-
return Atomic::cmpxchg(&_array[i % _size], old, entry) == old;
450+
return Atomic::cmpxchg(&_array[i % size], old, entry) == old;
455451
}
456452

457453
void OopMapCache::flush() {
458-
for (int i = 0; i < _size; i++) {
454+
for (int i = 0; i < size; i++) {
459455
OopMapCacheEntry* entry = _array[i];
460456
if (entry != nullptr) {
461457
_array[i] = nullptr; // no barrier, only called in OopMapCache destructor
@@ -466,7 +462,7 @@ void OopMapCache::flush() {
466462

467463
void OopMapCache::flush_obsolete_entries() {
468464
assert(SafepointSynchronize::is_at_safepoint(), "called by RedefineClasses in a safepoint");
469-
for (int i = 0; i < _size; i++) {
465+
for (int i = 0; i < size; i++) {
470466
OopMapCacheEntry* entry = _array[i];
471467
if (entry != nullptr && !entry->is_empty() && entry->method()->is_old()) {
472468
// Cache entry is occupied by an old redefined method and we don't want
@@ -501,7 +497,7 @@ void OopMapCache::lookup(const methodHandle& method,
501497
// Need a critical section to avoid race against concurrent reclamation.
502498
{
503499
GlobalCounter::CriticalSection cs(Thread::current());
504-
for (int i = 0; i < _probe_depth; i++) {
500+
for (int i = 0; i < probe_depth; i++) {
505501
OopMapCacheEntry *entry = entry_at(probe + i);
506502
if (entry != nullptr && !entry->is_empty() && entry->match(method, bci)) {
507503
entry_for->copy_from(entry);
@@ -530,7 +526,7 @@ void OopMapCache::lookup(const methodHandle& method,
530526
}
531527

532528
// First search for an empty slot
533-
for (int i = 0; i < _probe_depth; i++) {
529+
for (int i = 0; i < probe_depth; i++) {
534530
OopMapCacheEntry* entry = entry_at(probe + i);
535531
if (entry == nullptr) {
536532
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
@@ -151,11 +151,10 @@ class InterpreterOopMap: ResourceObj {
151151
class OopMapCache : public CHeapObj<mtClass> {
152152
static OopMapCacheEntry* volatile _old_entries;
153153
private:
154-
enum { _size = 32, // Use fixed size for now
155-
_probe_depth = 3 // probe depth in case of collisions
156-
};
154+
static constexpr int size = 32; // Use fixed size for now
155+
static constexpr int probe_depth = 3; // probe depth in case of collisions
157156

158-
OopMapCacheEntry* volatile * _array;
157+
OopMapCacheEntry* volatile _array[size];
159158

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

0 commit comments

Comments
 (0)