Path: blob/master/runtime/gc_verbose_old_events/VerboseEventClassUnloadingEnd.cpp
5985 views
1/*******************************************************************************2* Copyright (c) 1991, 2014 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#include "VerboseEventClassUnloadingEnd.hpp"24#include "GCExtensions.hpp"25#include "VerboseEventStream.hpp"26#include "VerboseManagerOld.hpp"27#include "VerboseEventClassUnloadingStart.hpp"2829/**30* Create an new instance of a MM_VerboseEventClassUnloadingEnd event.31* @param event Pointer to a structure containing the data passed over the hookInterface32*/33MM_VerboseEvent *34MM_VerboseEventClassUnloadingEnd::newInstance(MM_ClassUnloadingEndEvent *event, J9HookInterface** hookInterface)35{36MM_VerboseEventClassUnloadingEnd *eventObject;3738eventObject = (MM_VerboseEventClassUnloadingEnd *)MM_VerboseEvent::create((OMR_VMThread*)event->currentThread->omrVMThread, sizeof(MM_VerboseEventClassUnloadingEnd));39if(NULL != eventObject) {40new(eventObject) MM_VerboseEventClassUnloadingEnd(event, hookInterface);41}42return eventObject;43}4445/**46* Populate events data fields.47* The event calls the event stream requesting the address of events it is interested in.48* When an address is returned it populates itself with the data.49*/50void51MM_VerboseEventClassUnloadingEnd::consumeEvents(void)52{53MM_VerboseEventStream *eventStream = _manager->getEventStream();54MM_VerboseEventClassUnloadingStart *event = NULL;5556if (NULL != (event = (MM_VerboseEventClassUnloadingStart *)eventStream->returnEvent(J9HOOK_MM_PRIVATE_CLASS_UNLOADING_START, _manager->getPrivateHookInterface(), (MM_VerboseEvent *)this))){57_classUnloadingStartTime = event->getTimeStamp();58} else {59//Stream is corrupted, what now?60}61}6263/**64* Passes a format string and data to the output routine defined in the passed output agent.65* @param agent Pointer to an output agent.66*/67void68MM_VerboseEventClassUnloadingEnd::formattedOutput(MM_VerboseOutputAgent *agent)69{70UDATA indentLevel = _manager->getIndentLevel();71U_64 timeInMicroSeconds;7273if (!getTimeDeltaInMicroSeconds(&timeInMicroSeconds, _classUnloadingStartTime, _time)) {74agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<warning details=\"clock error detected in classloadersunloaded timetakenms\" />");75}7677if (_extensions->verboseExtensions) {78U_64 setupTime, scanTime, postTime;7980getTimeDeltaInMicroSeconds(&setupTime, 0, _cleanUpClassLoadersStartTime);81getTimeDeltaInMicroSeconds(&scanTime, 0, _cleanUpClassLoadersTime);82getTimeDeltaInMicroSeconds(&postTime, 0, _cleanUpClassLoadersEndTime);8384agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<classunloading classloaders=\"%zu\" classes=\"%zu\" timevmquiescems=\"%llu.%03.3llu\" setup=\"%llu.%03.3llu\" scan=\"%llu.%03.3llu\" post=\"%llu.%03.3llu\" totalms=\"%llu.%03.3llu\" />",85_classLoadersUnloadedCount,86_classesUnloadedCount,87_classUnloadMutexQuiesceTime / 1000,88_classUnloadMutexQuiesceTime % 1000,89setupTime / 1000,90setupTime % 1000,91scanTime / 1000,92scanTime % 1000,93postTime / 1000,94postTime % 1000,95timeInMicroSeconds / 1000,96timeInMicroSeconds % 100097);98} else {99agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<classunloading classloaders=\"%zu\" classes=\"%zu\" timevmquiescems=\"%llu.%03.3llu\" timetakenms=\"%llu.%03.3llu\" />",100_classLoadersUnloadedCount,101_classesUnloadedCount,102_classUnloadMutexQuiesceTime / 1000,103_classUnloadMutexQuiesceTime % 1000,104timeInMicroSeconds / 1000,105timeInMicroSeconds % 1000106);107}108}109110111