Path: blob/master/runtime/gc_trace/TgcConcurrentcardcleaning.cpp
5985 views
/*******************************************************************************1* Copyright (c) 1991, 2018 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/2122/**23* @file24* @ingroup GC_Trace25*/262728#include "j9.h"29#include "j9cfg.h"30#include "mmhook.h"31#include "j9port.h"32#include "modronopt.h"3334#if defined(OMR_GC_MODRON_CONCURRENT_MARK)35#include "ConcurrentCardTableStats.hpp"36#include "ConcurrentGCStats.hpp"37#include "GCExtensions.hpp"38#include "EnvironmentBase.hpp"39#include "TgcExtensions.hpp"4041/**42* Final card cleaning has finished.43* Function called by a hook when the final card cleaning has completed.44*45* @param concurrentGCStats The address of the concurrent statistics structure46* @param cardTableStats The address of the card table statistics structure47*/48static void49tgcHookCardCleaningComplete(J9HookInterface** hook, UDATA eventNum, void* eventData, void* userData)50{51MM_ConcurrentCollectionCardCleaningEndEvent* event = (MM_ConcurrentCollectionCardCleaningEndEvent*)eventData;52MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(event->currentThread);53MM_TgcExtensions *tgcExtensions = MM_TgcExtensions::getExtensions(extensions);5455tgcExtensions->printf("Card cleaning for GC(%zu)\n",56#if defined(J9VM_GC_MODRON_SCAVENGER)57extensions->scavengerStats._gcCount +58#endif /* J9VM_GC_MODRON_SCAVENGER */59extensions->globalGCStats.gcCount +60161);6263/* All card clean thresholds initialized to HIGH_VALUES so cast to IDATA so they are printed as -164* if we never got as far asKO of a particular phase of card cleaning65*/66tgcExtensions->printf(" concurrent card cleaning KO: Threshold=\"%zu\" Phase1= \"%zi\" Phase2= \"%zi\" Phase3= \"%zi\" \n",67event->cardCleaningThreshold,68(IDATA)event->cardCleaningPhase1KickOff,69(IDATA)event->cardCleaningPhase2KickOff,70(IDATA)event->cardCleaningPhase3KickOff71);7273tgcExtensions->printf(" concurrent cards cleaned: Phase1= \"%zu\" Phase2= \"%zu\" Phase3= \"%zu\" Total= \"%zu\" \n",74event->concleanedCardsPhase1,75event->concleanedCardsPhase2,76event->concleanedCardsPhase3,77event->concleanedCards78);7980tgcExtensions->printf(" final cards cleaned: Phase1= \"%zu\" Phase2= \"%zu\" Total= \"%zu\" \n",81event->finalcleanedCardsPhase1,82event->finalcleanedCardsPhase2,83event->finalcleanedCards84);85}8687/**88* Initialize cardcleaning tgc tracing.89* Initializes the TgcConcurrentExtensions object associated with concurrent tgc tracing.90* Attaches hooks to the appropriate functions handling events used by card cleaning tgc tracing.91*/92bool93tgcConcurrentCardCleaningInitialize(J9JavaVM *javaVM)94{95MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(javaVM);96bool result = true;9798J9HookInterface** privateHooks = J9_HOOK_INTERFACE(extensions->privateHookInterface);99(*privateHooks)->J9HookRegisterWithCallSite(privateHooks, J9HOOK_MM_PRIVATE_CONCURRENT_COLLECTION_CARD_CLEANING_END, tgcHookCardCleaningComplete, OMR_GET_CALLSITE(), NULL);100101return result;102}103104#endif /* OMR_GC_MODRON_CONCURRENT_MARK */105106107