Path: blob/master/runtime/gc_trace/TgcExtensions.hpp
5985 views
1/*******************************************************************************2* Copyright (c) 1991, 2019 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* distribution and is available at https://www.eclipse.org/legal/epl-2.0/7* or the Apache License, Version 2.0 which accompanies this distribution and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*20* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception21*******************************************************************************/2223/**24* @file25* @ingroup GC_Trace26*/2728#if !defined(TGCEXTENSIONS_HPP_)29#define TGCEXTENSIONS_HPP_3031#include "j9.h"32#include "j9cfg.h"3334#include "BaseNonVirtual.hpp"35#include "GCExtensions.hpp"36#include "TgcBacktrace.hpp"37#include "TgcDump.hpp"38#include "TgcExclusiveaccess.hpp"39#include "TgcExcessivegc.hpp"40#include "TgcFreelist.hpp"41#include "TgcHeap.hpp"42#include "TgcParallel.hpp"43#include "TgcAllocation.hpp"44#include "TgcTerse.hpp"45#include "TgcNuma.hpp"4647#if defined(J9VM_GC_MODRON_STANDARD)48#include "TgcConcurrent.hpp"49#include "TgcConcurrentcardcleaning.hpp"50#include "TgcScavenger.hpp"51#endif /* defined(J9VM_GC_MODRON_STANDARD) */5253#if defined(J9VM_GC_MODRON_STANDARD)54/**55* Structure holding information relating to tgc tracing for compaction.56*/57typedef struct TgcCompactionExtensions {58UDATA unused;59} TgcCompactionExtensions;60#endif /* defined(J9VM_GC_MODRON_STANDARD) */6162#if defined(J9VM_GC_VLHGC)63/**64* Structure holding information relating to tgc tracing for compaction.65*/66typedef struct TgcWriteOnceCompactionExtensions {67UDATA unused;68} TgcWriteOnceCompactionExtensions;6970/**71* Structure holding information relating to tgc tracing for inter-region remembered set demographics.72*/73typedef struct TgcInterRegionRememberedSetDemographicsExtension {74UDATA incrementCount; /**< A persistent counter of how many times the demographic data has been printed */75J9HashTable *classHashTable; /**< A shared hash table of class data, repopulated in each iteration */76UDATA errorCount; /**< A shared count of errors, reset in each increment */77UDATA totalRememberedObjects; /**< A shared count of total remembered objects, reset in each increment */78omrthread_monitor_t mutex; /**< A monitor used to protect the shared resources when parallel threads merge their results */79} TgcInterRegionRememberedSetDemographicsExtension;80#endif /* J9VM_GC_VLHGC */8182/**83* Class for handling trace information.84* This class stores state information and variables needed by the85* functions associated with the trace output.86*/87class MM_TgcExtensions : public MM_BaseNonVirtual88{89/*90* Data members91*/92private:93J9PortLibrary* _portLibrary; /**< The port library to use for TGC */94IDATA _outputFile; /**< The file handle TGC output should be written to */95protected:96public:97/* data used to save parsed requests whatever are compatible with GC policy or not */98bool _allocationRequested; /**< true if "allocation" option is parsed */99bool _largeAllocationRequested; /**< true if "largeAllocation" option is parsed */100bool _largeAllocationVerboseRequested; /**< true if "_largeAllocationVerboseRequested" option is parsed */101bool _backtraceRequested; /**< true if "backtrace" option is parsed */102bool _compactionRequested; /**< true if "compaction" option is parsed */103bool _concurrentRequested; /**< true if "concurrent" option is parsed */104bool _cardCleaningRequested; /**< true if "cardcleaning" option is parsed */105bool _dumpRequested; /**< true if "dump" option is parsed */106bool _exclusiveAccessRequested; /**< true if "exclusiveaccess" option is parsed */107bool _excessiveGCRequested; /**< true if "excessivegc" option is parsed */108bool _freeListSummaryRequested; /**< true if "freeListSummary" option is parsed */109bool _freeListRequested; /**< true if "freeList" option is parsed */110bool _heapRequested; /**< true if "heap" option is parsed */111bool _parallelRequested; /**< true if "parallel" option is parsed */112bool _rootScannerRequested; /**< true if "rootscantime" option is parsed */113bool _scavengerRequested; /**< true if "scavenger" option is parsed */114bool _scavengerSurvivalStatsRequested; /**< true if "scavengerSurvivalStats" option is parsed */115bool _scavengerMemoryStatsRequested; /**< true if "scavengerMemoryStats" option is parsed */116bool _terseRequested; /**< true if "terse" option is parsed */117bool _interRegionRememberedSetRequested; /**< true if "rememberedSetCardList" option is parsed */118bool _interRegionRememberedSetDemographicsRequested; /**< true if "rememberedSetDemographics" option is parsed */119bool _numaRequested; /**< true if "numa" option is parsed */120bool _allocationContextRequested; /**< true if "allocationContext" option is parsed */121bool _intelligentCompactRequested; /**< true if "intelligentCompact" option is parsed */122bool _dynamicCollectionSetRequested; /**< true if "dynamicCollectionSet" option is parsed */123bool _projectedStatsRequested; /**< true if "projectedStats" option is parsed */124bool _writeOnceCompactTimingRequested; /**< true if "writeOnceCompactTiming" option is parsed */125bool _copyForwardRequested; /**< true if "copyForward" option is parsed */126bool _interRegionReferencesRequested; /**< true if "interRegionReferences" option is parsed */127bool _sizeClassesRequested; /**< true if "sizeClasses" option is parsed */128129TgcBacktraceExtensions _backtrace;130TgcDumpExtensions _dump;131TgcExclusiveAccessExtensions _exclusiveAccess;132TgcExcessiveGCExtensions _excessiveGC;133TgcFreeListExtensions _freeList;134TgcParallelExtensions _parallel;135TgcTerseExtensions _terse;136137#if defined(J9VM_GC_MODRON_STANDARD)138TgcCompactionExtensions _compaction;139TgcConcurrentExtensions _concurrent;140TgcConcurrentCardCleaningExtensions _cardCleaning;141TgcScavengerExtensions _scavenger;142#endif /* defined(J9VM_GC_MODRON_STANDARD) */143144#if defined(J9VM_GC_VLHGC)145TgcNumaExtensions _numa;146TgcWriteOnceCompactionExtensions _writeOnceCompaction;147U_8 *_rsclDistinctFlagArray; /* hash table used for distinct card list detection */148void *_dynamicCollectionSetData; /**< Private data used by dynamic collection set TGC extensions */149TgcInterRegionRememberedSetDemographicsExtension _interRegionRememberedSetDemographics;150#endif /* J9VM_GC_VLHGC */151152/*153* Function members154*/155private:156protected:157/**158* Construct a new TGC extensions object159* @param extensions[in] the GC extensions160*/161MM_TgcExtensions(MM_GCExtensions *extensions);162163/**164* Tear down a TGC extensions object165* @param extensions[in] the GC extensions166*/167void tearDown(MM_GCExtensions *extensions);168169public:170/**171* Fetch the cached port library pointer172* @return the cached port library pointer173*/174J9PortLibrary* getPortLibrary() { return _portLibrary; }175176/**177* Print TGC output to stderr or the TGC output file178* @param format[in] a format string, see j9tty_printf179* @param args[in] arguments to be formatted180*/181void vprintf(const char *format, va_list args);182183/**184* Print TGC output to stderr or the TGC output file185* @param format[in] a format string, see j9tty_printf186* @param ...[in] arguments to be formatted187*/188void printf(const char *format, ...);189190/**191* Set the output file for TGC output.192* @param filename[in] the name of the file to open193* @return true on success, false on failure194*/195bool setOutputFile(const char* filename);196197/**198* Allocate and initialize a new TGC extensions object199* @param extensions[in] the GC extensions200* @return an initialized instance, or NULL on failure201*/202static MM_TgcExtensions * newInstance(MM_GCExtensions *extensions);203204/**205* Tear down and free the TGC extensions object206* @param extensions[in] the GC extensions207*/208void kill(MM_GCExtensions *extensions);209210/**211* Get the TGC extensions object from the GC Extensions object212* @param extensions[in] the GC extensions object213* @return the TGC extensions214*/215static MM_TgcExtensions* getExtensions(MM_GCExtensions* extensions) { return (MM_TgcExtensions*)extensions->tgcExtensions; }216217/**218* Get the TGC extensions object from the J9JavaVM struct219* @param javaVM[in] the J9JavaVM struct220* @return the TGC extensions221*/222static MM_TgcExtensions* getExtensions(J9JavaVM* javaVM) { return getExtensions(MM_GCExtensions::getExtensions(javaVM)); }223224/**225* Get the TGC extensions object from the J9JavaVM struct226* @param javaVM[in] the J9JavaVM struct227* @return the TGC extensions228*/229static MM_TgcExtensions* getExtensions(OMR_VMThread* omrVMThread) { return getExtensions(MM_GCExtensions::getExtensions(omrVMThread)); }230231/**232* Get the TGC extensions object from a J9VMThread struct233* @param vmThread[in] a J9VMThread struct234* @return the TGC extensions235*/236static MM_TgcExtensions* getExtensions(J9VMThread* vmThread) { return getExtensions(vmThread->javaVM); }237};238239#endif /* TGCEXTENSIONS_HPP_ */240241242243