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
441441OopMapCacheEntry* volatile OopMapCache::_old_entries = nullptr ;
442442
443443OopMapCache::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
449448OopMapCache::~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
457453OopMapCacheEntry* OopMapCache::entry_at (int i) const {
458- return Atomic::load_acquire (&(_array[i % _size ]));
454+ return Atomic::load_acquire (&(_array[i % size ]));
459455}
460456
461457bool 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
465461void 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
475471void 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 )) {
0 commit comments