11/*
2- * Copyright (c) 1998, 2020 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1998, 2021 , 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
@@ -235,6 +235,8 @@ void ObjectSynchronizer::initialize() {
235235 for (int i = 0 ; i < NINFLATIONLOCKS; i++) {
236236 gInflationLocks [i] = new os::PlatformMutex ();
237237 }
238+ // Start the ceiling with the estimate for one thread.
239+ set_in_use_list_ceiling (AvgMonitorsPerThreadEstimate);
238240}
239241
240242static MonitorList _in_use_list;
@@ -249,10 +251,9 @@ static MonitorList _in_use_list;
249251// of the thread count derived ceiling because we have used more
250252// ObjectMonitors than the estimated average.
251253//
252- // Start the ceiling with the estimate for one thread.
253- // This is a 'jint' because the range of AvgMonitorsPerThreadEstimate
254- // is 0..max_jint:
255- static jint _in_use_list_ceiling = AvgMonitorsPerThreadEstimate;
254+ // Start the ceiling with the estimate for one thread in initialize()
255+ // which is called after cmd line options are processed.
256+ static size_t _in_use_list_ceiling = 0 ;
256257bool volatile ObjectSynchronizer::_is_async_deflation_requested = false ;
257258bool volatile ObjectSynchronizer::_is_final_audit = false ;
258259jlong ObjectSynchronizer::_last_async_deflation_time_ns = 0 ;
@@ -1159,22 +1160,19 @@ static bool monitors_used_above_threshold(MonitorList* list) {
11591160}
11601161
11611162size_t ObjectSynchronizer::in_use_list_ceiling () {
1162- // _in_use_list_ceiling is a jint so this cast could lose precision,
1163- // but in reality the ceiling should never get that high.
1164- return (size_t )_in_use_list_ceiling;
1163+ return _in_use_list_ceiling;
11651164}
11661165
11671166void ObjectSynchronizer::dec_in_use_list_ceiling () {
1168- Atomic::add (&_in_use_list_ceiling, (jint)-AvgMonitorsPerThreadEstimate);
1169- #ifdef ASSERT
1170- size_t l_in_use_list_ceiling = in_use_list_ceiling ();
1171- #endif
1172- assert (l_in_use_list_ceiling > 0 , " in_use_list_ceiling=" SIZE_FORMAT
1173- " : must be > 0" , l_in_use_list_ceiling);
1167+ Atomic::add (&_in_use_list_ceiling, -AvgMonitorsPerThreadEstimate);
11741168}
11751169
11761170void ObjectSynchronizer::inc_in_use_list_ceiling () {
1177- Atomic::add (&_in_use_list_ceiling, (jint)AvgMonitorsPerThreadEstimate);
1171+ Atomic::add (&_in_use_list_ceiling, AvgMonitorsPerThreadEstimate);
1172+ }
1173+
1174+ void ObjectSynchronizer::set_in_use_list_ceiling (size_t new_value) {
1175+ _in_use_list_ceiling = new_value;
11781176}
11791177
11801178bool ObjectSynchronizer::is_async_deflation_needed () {
0 commit comments