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
433433OopMapCacheEntry* volatile OopMapCache::_old_entries = nullptr ;
434434
435435OopMapCache::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
441440OopMapCache::~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
449445OopMapCacheEntry* OopMapCache::entry_at (int i) const {
450- return Atomic::load_acquire (&(_array[i % _size ]));
446+ return Atomic::load_acquire (&(_array[i % size ]));
451447}
452448
453449bool 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
457453void 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
467463void 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 )) {
0 commit comments