Path: blob/master/runtime/gc_verbose_old_events/VerboseEventGCInitialized.cpp
5985 views
/*******************************************************************************1* Copyright (c) 1991, 2019 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#include "VerboseEventGCInitialized.hpp"23#include "GCExtensions.hpp"24#include "VerboseEventStream.hpp"25#include "VerboseManagerOld.hpp"2627#include "j9modron.h"28#include "omrutil.h"2930/**31* Create an new instance of a MM_VerboseEventGCInitialized event.32* @param event Pointer to a structure containing the data passed over the hookInterface33*/34MM_VerboseEvent *35MM_VerboseEventGCInitialized::newInstance(MM_InitializedEvent *event, J9HookInterface** hookInterface)36{37MM_VerboseEventGCInitialized *eventObject;3839eventObject = (MM_VerboseEventGCInitialized *)MM_VerboseEvent::create(event->currentThread, sizeof(MM_VerboseEventGCInitialized));40if(NULL != eventObject) {41new(eventObject) MM_VerboseEventGCInitialized(event, hookInterface);42}43return eventObject;44}4546/**47* Populate events data fields.48* The event calls the event stream requesting the address of events it is interested in.49* When an address is returned it populates itself with the data.50*/51void52MM_VerboseEventGCInitialized::consumeEvents(void)53{54}5556/**57* Passes a format string and data to the output routine defined in the passed output agent.58* @param agent Pointer to an output agent.59*/60void61MM_VerboseEventGCInitialized::formattedOutput(MM_VerboseOutputAgent *agent)62{63OMRPORT_ACCESS_FROM_OMRVMTHREAD(_omrThread);64UDATA indentLevel = _manager->getIndentLevel();65char timestamp[32];66jint i;67JavaVMInitArgs* vmArgs = static_cast<J9VMThread*>(_omrThread->_language_vmthread)->javaVM->vmArgsArray->actualVMArgs;68MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(_omrThread->_vm);6970omrstr_ftime(timestamp, sizeof(timestamp), VERBOSEGC_DATE_FORMAT, omrtime_current_time_millis());71agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<initialized timestamp=\"%s\" >", timestamp);72agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"gcPolicy\" value=\"%s\" />", _event.gcPolicy);73agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"maxHeapSize\" value=\"0x%zx\" />", _event.maxHeapSize);74agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"initialHeapSize\" value=\"0x%zx\" />", _event.initialHeapSize);75#if defined(OMR_GC_COMPRESSED_POINTERS)76if (OMRVMTHREAD_COMPRESS_OBJECT_REFERENCES(_omrThread)) {77agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"compressedRefs\" value=\"true\" />");78agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"compressedRefsDisplacement\" value=\"0x%zx\" />", 0);79agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"compressedRefsShift\" value=\"0x%zx\" />", _event.compressedPointersShift);80} else81#endif /* defined(OMR_GC_COMPRESSED_POINTERS) */82{83agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"compressedRefs\" value=\"false\" />");84}85agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"pageSize\" value=\"0x%zx\" />", _event.heapPageSize);86agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"pageType\" value=\"%s\" />", _event.heapPageType);87agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"requestedPageSize\" value=\"0x%zx\" />", _event.heapRequestedPageSize);88agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"requestedPageType\" value=\"%s\" />", _event.heapRequestedPageType);89agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"gcthreads\" value=\"%zu\" />", _event.gcThreads);9091agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<system>");92agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 2, "<attribute name=\"physicalMemory\" value=\"%llu\" />", _event.physicalMemory);93agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 2, "<attribute name=\"numCPUs\" value=\"%zu\" />", _event.numCPUs);94agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 2, "<attribute name=\"architecture\" value=\"%s\" />", _event.architecture);95agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 2, "<attribute name=\"os\" value=\"%s\" />", _event.os);96agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 2, "<attribute name=\"osVersion\" value=\"%s\" />", _event.osVersion);97agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "</system>");9899agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<vmargs>");100for (i = 0; i < vmArgs->nOptions; ++i) {101char escapedXMLString[128];102UDATA optLen = strlen(vmArgs->options[i].optionString);103UDATA escapeConsumed = escapeXMLString(OMRPORTLIB, escapedXMLString, sizeof(escapedXMLString), vmArgs->options[i].optionString, optLen);104const char* dots = (escapeConsumed < optLen) ? "..." : "";105agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 2, "<vmarg name=\"%s%s\" value=\"0x%p\" />", escapedXMLString, dots, vmArgs->options[i].extraInfo);106}107agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "</vmargs>");108109if (extensions->isMetronomeGC()) {110#if defined(J9VM_GC_REALTIME)111agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<metronome>");112agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 2, "<attribute name=\"beatsPerMeasure\" value=\"%zu\" />", _event.beat);113agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 2, "<attribute name=\"timeInterval\" value=\"%zu\" />", _event.timeWindow);114agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 2, "<attribute name=\"targetUtilization\" value=\"%zu\" />", _event.targetUtilization);115agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 2, "<attribute name=\"trigger\" value=\"0x%zx\" />", _event.gcTrigger);116agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 2, "<attribute name=\"headRoom\" value=\"0x%zx\" />", _event.headRoom);117agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "</metronome>");118#endif /* J9VM_GC_REALTIME */119}120121agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel + 1, "<attribute name=\"numaNodes\" value=\"%zu\" />", _event.numaNodes);122123agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "</initialized>");124_manager->setInitializedTime(getTimeStamp());125agent->endOfCycle(static_cast<J9VMThread*>(_omrThread->_language_vmthread));126}127128129