Path: blob/master/runtime/gc_verbose_old_events/VerboseEventAFStart.cpp
5985 views
/*******************************************************************************1* Copyright (c) 1991, 2021 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 "VerboseEventAFStart.hpp"23#include "GCExtensions.hpp"24#include "VerboseEventStream.hpp"25#include "VerboseManagerOld.hpp"2627/**28* Create an new instance of a MM_VerboseEventAFStart event.29* @param event Pointer to a structure containing the data passed over the hookInterface30*/31MM_VerboseEvent *32MM_VerboseEventAFStart::newInstance(MM_AllocationFailureStartEvent *event, J9HookInterface** hookInterface)33{34MM_VerboseEventAFStart *eventObject;3536eventObject = (MM_VerboseEventAFStart *)MM_VerboseEvent::create(event->currentThread, sizeof(MM_VerboseEventAFStart));37if(NULL != eventObject) {38new(eventObject) MM_VerboseEventAFStart(event, hookInterface);39eventObject->initialize();40}41return eventObject;42}4344/**45* Populate events data fields.46* The event calls the event stream requesting the address of events it is interested in.47* When an address is returned it populates itself with the data.48*/49void50MM_VerboseEventAFStart::consumeEvents(void)51{52/* Increment collection count */53(MEMORY_TYPE_NEW == _subSpaceType) ? (_manager->incrementNurseryAFCount()) : (_manager->incrementTenureAFCount());5455/* Consume global data */56_lastAFTime = (MEMORY_TYPE_NEW == _subSpaceType) ? (_manager->getLastNurseryAFTime()) : (_manager->getLastTenureAFTime());57_AFCount = (MEMORY_TYPE_NEW == _subSpaceType) ? (_manager->getNurseryAFCount()) : (_manager->getTenureAFCount());58}5960/**61* Passes a format string and data to the output routine defined in the passed output agent.62* @param agent Pointer to an output agent.63*/64void65MM_VerboseEventAFStart::formattedOutput(MM_VerboseOutputAgent *agent)66{67PORT_ACCESS_FROM_JAVAVM(((J9VMThread*)_omrThread->_language_vmthread)->javaVM);68OMRPORT_ACCESS_FROM_J9PORT(PORTLIB);69char timestamp[32];70UDATA indentLevel = _manager->getIndentLevel();71U_64 timeInMicroSeconds = 0;72U_64 prevTime = 0;7374omrstr_ftime_ex(timestamp, sizeof(timestamp), VERBOSEGC_DATE_FORMAT, _timeInMilliSeconds, OMRSTR_FTIME_FLAG_LOCAL);75switch(_subSpaceType) {76case 0:77agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<af type=\"UNKNOWN!!\" />");78return;79break;8081case MEMORY_TYPE_NEW:8283if (1 == _manager->getNurseryAFCount()) {84prevTime = _manager->getInitializedTime();85} else {86prevTime = _lastAFTime;87}88timeInMicroSeconds = j9time_hires_delta(prevTime, _time, J9PORT_TIME_DELTA_IN_MICROSECONDS);89agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<af type=\"nursery\" id=\"%zu\" timestamp=\"%s\" intervalms=\"%llu.%03.3llu\">",90_manager->getNurseryAFCount(),91timestamp,92timeInMicroSeconds / 1000,93timeInMicroSeconds % 100094);95break;9697case MEMORY_TYPE_OLD:9899if (1 == _manager->getTenureAFCount()) {100prevTime = _manager->getInitializedTime();101} else {102prevTime = _lastAFTime;103}104timeInMicroSeconds = j9time_hires_delta(prevTime, _time, J9PORT_TIME_DELTA_IN_MICROSECONDS);105agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<af type=\"tenured\" id=\"%zu\" timestamp=\"%s\" intervalms=\"%llu.%03.3llu\">",106_manager->getTenureAFCount(),107timestamp,108timeInMicroSeconds / 1000,109timeInMicroSeconds % 1000110);111break;112default:113break;114}115116_manager->incrementIndent();117indentLevel = _manager->getIndentLevel();118119agent->formatAndOutput(static_cast<J9VMThread*>(_omrThread->_language_vmthread), indentLevel, "<minimum requested_bytes=\"%zu\" />", _requestedBytes);120121/* output the common GC start info */122gcStartFormattedOutput(agent);123124}125126127