Path: blob/master/runtime/gc_stats/ScanClassesMode.hpp
5986 views
1/*******************************************************************************2* Copyright (c) 1991, 2017 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*******************************************************************************/222324#if !defined(SCANCLASSESMODE_HPP_)25#define SCANCLASSESMODE_HPP_2627#include "j9cfg.h"28#include "j9comp.h"29#include "omrgcconsts.h"30#include "AtomicOperations.hpp"3132#if defined(J9VM_GC_DYNAMIC_CLASS_UNLOADING)3334/**35* Concurrent status symbols extending ConcurrentKickoffReason enumeration.36* Explain why kickoff triggered by Java.37*/38enum {39FORCED_UNLOADING_CLASSES = (uintptr_t)((uintptr_t)NO_LANGUAGE_KICKOFF_REASON + 1)40};4142/**43* @todo Provide class documentation44* @ingroup GC_Base_Core45*/46class MM_ScanClassesMode : public MM_Base47{48private:49volatile uintptr_t _scanClassesMode;5051public:52typedef enum {53SCAN_CLASSES_NEED_TO_BE_EXECUTED = 1,54SCAN_CLASSES_CURRENTLY_ACTIVE,55SCAN_CLASSES_COMPLETE,56SCAN_CLASSES_DISABLED57} ScanClassesMode;5859public:60MMINLINE ScanClassesMode getScanClassesMode() { return (ScanClassesMode)_scanClassesMode; }6162MMINLINE bool63switchScanClassesMode(ScanClassesMode oldMode, ScanClassesMode newMode)64{65uintptr_t result = MM_AtomicOperations::lockCompareExchange(&_scanClassesMode, (uintptr_t)oldMode, (uintptr_t)newMode);66return result == (uintptr_t)oldMode;67}6869MMINLINE void70setScanClassesMode(ScanClassesMode mode)71{72MM_AtomicOperations::set((uintptr_t *)&_scanClassesMode, (uintptr_t)mode);73}7475MMINLINE bool76isPendingOrActiveMode()77{78uintptr_t mode = _scanClassesMode;79return (mode == SCAN_CLASSES_NEED_TO_BE_EXECUTED) || (mode == SCAN_CLASSES_CURRENTLY_ACTIVE);80}8182MMINLINE const char *83getScanClassesModeAsString()84{85switch (getScanClassesMode()) {86case SCAN_CLASSES_NEED_TO_BE_EXECUTED:87return "pending";8889case SCAN_CLASSES_CURRENTLY_ACTIVE:90return "active";9192case SCAN_CLASSES_COMPLETE:93return "complete";9495case SCAN_CLASSES_DISABLED:96return "disabled";9798default:99return "unknown";100}101}102103/**104* Create a ScanClassesMode object.105*/106MM_ScanClassesMode() :107MM_Base(),108_scanClassesMode((uintptr_t)SCAN_CLASSES_DISABLED)109{}110111};112113#endif /* J9VM_GC_DYNAMIC_CLASS_UNLOADING */114115#endif /* SCANCLASSESMODE_HPP_ */116117118