Path: blob/master/runtime/gc_realtime/RealtimeMarkTask.cpp
5985 views
/*******************************************************************************1* Copyright (c) 1991, 2020 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*/2526#include "ut_j9mm.h"2728#include "EnvironmentRealtime.hpp"29#include "GCExtensionsBase.hpp"30#include "GlobalGCStats.hpp"31#include "RealtimeGC.hpp"32#include "RealtimeMarkingScheme.hpp"33#include "RealtimeMarkTask.hpp"3435void36MM_RealtimeMarkTask::run(MM_EnvironmentBase *env)37{38_markingScheme->markLiveObjectsInit(env, false);39_markingScheme->markLiveObjectsRoots(env);40_markingScheme->markLiveObjectsScan(env);41_markingScheme->markLiveObjectsComplete(env);42}4344void45MM_RealtimeMarkTask::setup(MM_EnvironmentBase *envBase)46{47MM_EnvironmentRealtime *env = MM_EnvironmentRealtime::getEnvironment(envBase);48MM_GCExtensionsBase *extensions = env->getExtensions();4950extensions->realtimeGC->getRealtimeDelegate()->clearGCStatsEnvironment(env);5152/* record that this thread is participating in this cycle */53env->_markStats._gcCount = extensions->globalGCStats.gcCount;54env->_workPacketStats._gcCount = extensions->globalGCStats.gcCount;5556if(env->isMainThread()) {57Assert_MM_true(_cycleState == env->_cycleState);58} else {59Assert_MM_true(NULL == env->_cycleState);60env->_cycleState = _cycleState;61}62}6364void65MM_RealtimeMarkTask::cleanup(MM_EnvironmentBase *envBase)66{67MM_EnvironmentRealtime *env = MM_EnvironmentRealtime::getEnvironment(envBase);68MM_GCExtensionsBase *extensions = env->getExtensions();69MM_MetronomeDelegate *delegate = extensions->realtimeGC->getRealtimeDelegate();70OMRPORT_ACCESS_FROM_ENVIRONMENT(env);7172delegate->mergeGCStats(env);7374if (env->isMainThread()) {75Assert_MM_true(_cycleState == env->_cycleState);76} else {77env->_cycleState = NULL;78}7980/* record the thread-specific parallelism stats in the trace buffer. This partially duplicates info in -Xtgc:parallel */81Trc_MM_RealtimeMarkTask_parallelStats(82env->getLanguageVMThread(),83(U_32)env->getWorkerID(),84(U_32)omrtime_hires_delta(0, env->_workPacketStats._workStallTime, OMRPORT_TIME_DELTA_IN_MILLISECONDS),85(U_32)omrtime_hires_delta(0, env->_workPacketStats._completeStallTime, OMRPORT_TIME_DELTA_IN_MILLISECONDS),86(U_32)omrtime_hires_delta(0, env->_markStats._syncStallTime, OMRPORT_TIME_DELTA_IN_MILLISECONDS),87(U_32)env->_workPacketStats._workStallCount,88(U_32)env->_workPacketStats._completeStallCount,89(U_32)env->_markStats._syncStallCount,90env->_workPacketStats.workPacketsAcquired,91env->_workPacketStats.workPacketsReleased,92env->_workPacketStats.workPacketsExchanged,93delegate->getSplitArraysProcessed(env));94}959697