Skip to content

Commit 38eeb50

Browse files
committed
8335007: Inline OopMapCache table
Backport-of: 50dd962b0d0fe36634d96dbbd9d94fbc34d9ff7f
1 parent affb895 commit 38eeb50

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

443443
OopMapCache::OopMapCache() {
444-
_array = NEW_C_HEAP_ARRAY(OopMapCacheEntry*, _size, mtClass);
445-
for(int i = 0; i < _size; i++) _array[i] = nullptr;
444+
for(int i = 0; i < size; i++) _array[i] = nullptr;
446445
}
447446

448447

449448
OopMapCache::~OopMapCache() {
450-
assert(_array != nullptr, "sanity check");
451449
// Deallocate oop maps that are allocated out-of-line
452450
flush();
453-
// Deallocate array
454-
FREE_C_HEAP_ARRAY(OopMapCacheEntry*, _array);
455451
}
456452

457453
OopMapCacheEntry* OopMapCache::entry_at(int i) const {
458-
return Atomic::load_acquire(&(_array[i % _size]));
454+
return Atomic::load_acquire(&(_array[i % size]));
459455
}
460456

461457
bool OopMapCache::put_at(int i, OopMapCacheEntry* entry, OopMapCacheEntry* old) {
462-
return Atomic::cmpxchg(&_array[i % _size], old, entry) == old;
458+
return Atomic::cmpxchg(&_array[i % size], old, entry) == old;
463459
}
464460

465461
void OopMapCache::flush() {
466-
for (int i = 0; i < _size; i++) {
462+
for (int i = 0; i < size; i++) {
467463
OopMapCacheEntry* entry = _array[i];
468464
if (entry != nullptr) {
469465
_array[i] = nullptr; // no barrier, only called in OopMapCache destructor
@@ -474,7 +470,7 @@ void OopMapCache::flush() {
474470

475471
void OopMapCache::flush_obsolete_entries() {
476472
assert(SafepointSynchronize::is_at_safepoint(), "called by RedefineClasses in a safepoint");
477-
for (int i = 0; i < _size; i++) {
473+
for (int i = 0; i < size; i++) {
478474
OopMapCacheEntry* entry = _array[i];
479475
if (entry != nullptr && !entry->is_empty() && entry->method()->is_old()) {
480476
// Cache entry is occupied by an old redefined method and we don't want
@@ -509,7 +505,7 @@ void OopMapCache::lookup(const methodHandle& method,
509505
// Need a critical section to avoid race against concurrent reclamation.
510506
{
511507
GlobalCounter::CriticalSection cs(Thread::current());
512-
for (int i = 0; i < _probe_depth; i++) {
508+
for (int i = 0; i < probe_depth; i++) {
513509
OopMapCacheEntry *entry = entry_at(probe + i);
514510
if (entry != nullptr && !entry->is_empty() && entry->match(method, bci)) {
515511
entry_for->resource_copy(entry);
@@ -538,7 +534,7 @@ void OopMapCache::lookup(const methodHandle& method,
538534
}
539535

540536
// First search for an empty slot
541-
for (int i = 0; i < _probe_depth; i++) {
537+
for (int i = 0; i < probe_depth; i++) {
542538
OopMapCacheEntry* entry = entry_at(probe + i);
543539
if (entry == nullptr) {
544540
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, 2022, 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
@@ -148,11 +148,10 @@ class InterpreterOopMap: ResourceObj {
148148
class OopMapCache : public CHeapObj<mtClass> {
149149
static OopMapCacheEntry* volatile _old_entries;
150150
private:
151-
enum { _size = 32, // Use fixed size for now
152-
_probe_depth = 3 // probe depth in case of collisions
153-
};
151+
static constexpr int size = 32; // Use fixed size for now
152+
static constexpr int probe_depth = 3; // probe depth in case of collisions
154153

155-
OopMapCacheEntry* volatile * _array;
154+
OopMapCacheEntry* volatile _array[size];
156155

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

0 commit comments

Comments
 (0)