Skip to content

Commit

Permalink
8323685: PrintSystemDictionaryAtExit has mutex rank assert
Browse files Browse the repository at this point in the history
Backport-of: 2865afe759fd5362abd0947fd4c1f5c8d3519ca3
  • Loading branch information
GoeLin committed Apr 19, 2024
1 parent e63addb commit f341621
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 20 deletions.
7 changes: 5 additions & 2 deletions src/hotspot/share/gc/g1/g1CardSet.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -286,7 +286,10 @@ class G1CardSetHashTable : public CHeapObj<mtGCCardSet> {
size_t initial_log_table_size = InitialLogTableSize) :
_inserted_card(false),
_mm(mm),
_table(mm, initial_log_table_size, false),
_table(Mutex::service-1,
mm,
initial_log_table_size,
false /* enable_statistics */),
_table_scanner(&_table, BucketClaimSize) {
}

Expand Down
8 changes: 5 additions & 3 deletions src/hotspot/share/gc/g1/g1CodeRootSet.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -84,8 +84,10 @@ class G1CodeRootSetHashTable : public CHeapObj<mtGC> {

public:
G1CodeRootSetHashTable() :
_table(Log2DefaultNumBuckets,
HashTable::DEFAULT_MAX_SIZE_LOG2),
_table(Mutex::service-1,
nullptr,
Log2DefaultNumBuckets,
false /* enable_statistics */),
_table_scanner(&_table, BucketClaimSize), _num_entries(0) {
clear();
}
Expand Down
8 changes: 5 additions & 3 deletions src/hotspot/share/utilities/concurrentHashTable.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,6 +26,7 @@
#define SHARE_UTILITIES_CONCURRENTHASHTABLE_HPP

#include "memory/allocation.hpp"
#include "runtime/mutex.hpp"
#include "utilities/globalCounter.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/growableArray.hpp"
Expand Down Expand Up @@ -406,10 +407,11 @@ class ConcurrentHashTable : public CHeapObj<F> {
size_t log2size_limit = DEFAULT_MAX_SIZE_LOG2,
size_t grow_hint = DEFAULT_GROW_HINT,
bool enable_statistics = DEFAULT_ENABLE_STATISTICS,
Mutex::Rank rank = Mutex::nosafepoint-2,
void* context = nullptr);

explicit ConcurrentHashTable(void* context, size_t log2size = DEFAULT_START_SIZE_LOG2, bool enable_statistics = DEFAULT_ENABLE_STATISTICS) :
ConcurrentHashTable(log2size, DEFAULT_MAX_SIZE_LOG2, DEFAULT_GROW_HINT, enable_statistics, context) {}
explicit ConcurrentHashTable(Mutex::Rank rank, void* context, size_t log2size = DEFAULT_START_SIZE_LOG2, bool enable_statistics = DEFAULT_ENABLE_STATISTICS) :
ConcurrentHashTable(log2size, DEFAULT_MAX_SIZE_LOG2, DEFAULT_GROW_HINT, enable_statistics, rank, context) {}

~ConcurrentHashTable();

Expand Down
7 changes: 3 additions & 4 deletions src/hotspot/share/utilities/concurrentHashTable.inline.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1012,7 +1012,7 @@ inline size_t ConcurrentHashTable<CONFIG, F>::
// Constructor
template <typename CONFIG, MEMFLAGS F>
inline ConcurrentHashTable<CONFIG, F>::
ConcurrentHashTable(size_t log2size, size_t log2size_limit, size_t grow_hint, bool enable_statistics, void* context)
ConcurrentHashTable(size_t log2size, size_t log2size_limit, size_t grow_hint, bool enable_statistics, Mutex::Rank rank, void* context)
: _context(context), _new_table(nullptr), _log2_size_limit(log2size_limit),
_log2_start_size(log2size), _grow_hint(grow_hint),
_size_limit_reached(false), _resize_lock_owner(nullptr),
Expand All @@ -1023,8 +1023,7 @@ ConcurrentHashTable(size_t log2size, size_t log2size_limit, size_t grow_hint, bo
} else {
_stats_rate = nullptr;
}
_resize_lock =
new Mutex(Mutex::service-1, "ConcurrentHashTableResize_lock");
_resize_lock = new Mutex(rank, "ConcurrentHashTableResize_lock");
_table = new InternalTable(log2size);
assert(log2size_limit >= log2size, "bad ergo");
_size_limit_reached = _table->_log2_size == _log2_size_limit;
Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/gtest/utilities/test_concurrentHashtable.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -322,7 +322,7 @@ static void cht_reset_shrink(Thread* thr) {

Allocator mem_allocator;
const uint initial_log_table_size = 4;
CustomTestTable* cht = new CustomTestTable(&mem_allocator);
CustomTestTable* cht = new CustomTestTable(Mutex::nosafepoint-2, &mem_allocator);

cht_insert_and_find(thr, cht, val1);
cht_insert_and_find(thr, cht, val2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -23,22 +23,47 @@

import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Platform;

/*
* @test PrintStringTableStatsTest
* @bug 8211821
* @test
* @summary Test various printing functions in classfile directory
* @bug 8211821 8323685
* @requires vm.flagless
* @library /test/lib
* @run driver PrintStringTableStatsTest
* @run driver ClassfilePrintingTests
*/

public class PrintStringTableStatsTest {
public static void main(String... args) throws Exception {
class SampleClass {
public static void main(java.lang.String[] unused) {
System.out.println("Hello from the sample class");
}
}

public class ClassfilePrintingTests {
private static void printStringTableStatsTest() throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
"-XX:+PrintStringTableStatistics",
"--version");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain("Number of buckets");
output.shouldHaveExitValue(0);
}

private static void printSystemDictionaryAtExitTest() throws Exception {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
"-XX:+PrintSystemDictionaryAtExit",
"SampleClass");
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldContain(SampleClass.class.getName());
output.shouldContain("jdk/internal/loader/ClassLoaders$AppClassLoader");
output.shouldHaveExitValue(0);
}

public static void main(String... args) throws Exception {
printStringTableStatsTest();
if (Platform.isDebugBuild()) {
printSystemDictionaryAtExitTest();
}
}
}

1 comment on commit f341621

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.