Skip to content

Commit

Permalink
8266795: Remove dead code LowMemoryDetectorDisabler
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes
  • Loading branch information
Hamlin Li committed May 14, 2021
1 parent 1e0ecd6 commit 301095c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/hotspot/share/services/lowMemoryDetector.cpp
Expand Up @@ -39,7 +39,6 @@
#include "services/management.hpp"

volatile bool LowMemoryDetector::_enabled_for_collected_pools = false;
volatile jint LowMemoryDetector::_disabled_count = 0;

bool LowMemoryDetector::has_pending_requests() {
assert(Notification_lock->owned_by_self(), "Must own Notification_lock");
Expand Down
29 changes: 2 additions & 27 deletions src/hotspot/share/services/lowMemoryDetector.hpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, 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 @@ -211,19 +211,13 @@ class SensorInfo : public CHeapObj<mtInternal> {
};

class LowMemoryDetector : public AllStatic {
friend class LowMemoryDetectorDisabler;
friend class ServiceThread;
friend class NotificationThread;
private:
// true if any collected heap has low memory detection enabled
static volatile bool _enabled_for_collected_pools;
// > 0 if temporary disabed
static volatile jint _disabled_count;

static bool has_pending_requests();
static bool temporary_disabled() { return _disabled_count > 0; }
static void disable() { Atomic::inc(&_disabled_count); }
static void enable() { Atomic::dec(&_disabled_count); }
static void process_sensor_changes(TRAPS);

public:
Expand All @@ -244,19 +238,13 @@ class LowMemoryDetector : public AllStatic {
}
}

// indicates if low memory detection is enabled for any collected
// memory pools
static inline bool is_enabled_for_collected_pools() {
return !temporary_disabled() && _enabled_for_collected_pools;
}

// recompute enabled flag
static void recompute_enabled_for_collected_pools();

// low memory detection for collected memory pools.
static inline void detect_low_memory_for_collected_pools() {
// no-op if low memory detection not enabled
if (!is_enabled_for_collected_pools()) {
if (!_enabled_for_collected_pools) {
return;
}
int num_memory_pools = MemoryService::num_memory_pools();
Expand All @@ -276,17 +264,4 @@ class LowMemoryDetector : public AllStatic {
}
};

class LowMemoryDetectorDisabler: public StackObj {
public:
LowMemoryDetectorDisabler()
{
LowMemoryDetector::disable();
}
~LowMemoryDetectorDisabler()
{
assert(LowMemoryDetector::temporary_disabled(), "should be disabled!");
LowMemoryDetector::enable();
}
};

#endif // SHARE_SERVICES_LOWMEMORYDETECTOR_HPP

1 comment on commit 301095c

@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.