src/hotspot/share/services/gcNotifier.hpp
author dcubed
Wed, 18 Sep 2019 20:49:13 -0400
changeset 58223 778fc2dcbdaa
parent 53244 9807daeb47c4
permissions -rw-r--r--
8231210: [BACKOUT] JDK-8207266 ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread Reviewed-by: phh, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     4
 *
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     7
 * published by the Free Software Foundation.
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     8
 *
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    13
 * accompanied this code).
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    14
 *
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    18
 *
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    21
 * questions.
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    22
 *
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    23
 */
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    25
#ifndef SHARE_SERVICES_GCNOTIFIER_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    26
#define SHARE_SERVICES_GCNOTIFIER_HPP
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    27
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    28
#include "memory/allocation.hpp"
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    29
#include "services/memoryPool.hpp"
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    30
#include "services/memoryService.hpp"
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    31
#include "services/memoryManager.hpp"
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    32
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 11766
diff changeset
    33
class GCNotificationRequest : public CHeapObj<mtInternal> {
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    34
  friend class GCNotifier;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    35
  GCNotificationRequest *next;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    36
  jlong timestamp;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    37
  GCMemoryManager *gcManager;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    38
  const char *gcAction;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    39
  const char *gcCause;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    40
  GCStatInfo *gcStatInfo;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    41
public:
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    42
  GCNotificationRequest(jlong ts, GCMemoryManager *manager, const char*action, const char *cause,GCStatInfo *info) {
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    43
    next = NULL;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    44
    timestamp = ts;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    45
    gcManager = manager;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    46
    gcAction = action;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    47
    gcCause = cause;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    48
    gcStatInfo = info;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    49
  }
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    50
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    51
  ~GCNotificationRequest() {
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    52
    delete gcStatInfo;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    53
  }
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    54
};
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    55
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    56
class GCNotifier : public AllStatic {
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    57
  friend class ServiceThread;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    58
private:
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    59
  static GCNotificationRequest *first_request;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    60
  static GCNotificationRequest *last_request;
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    61
  static void addRequest(GCNotificationRequest *request);
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    62
  static GCNotificationRequest *getRequest();
11766
b1ff60353280 7143760: Memory leak in GarbageCollectionNotifications
fparain
parents: 9623
diff changeset
    63
  static void sendNotificationInternal(TRAPS);
9623
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    64
public:
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    65
  static void pushNotification(GCMemoryManager *manager, const char *action, const char *cause);
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    66
  static bool has_event();
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    67
  static void sendNotification(TRAPS);
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    68
};
151c0b638488 7036199: Adding a notification to the implementation of GarbageCollectorMXBeans
fparain
parents:
diff changeset
    69
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    70
#endif // SHARE_SERVICES_GCNOTIFIER_HPP