Path: blob/master/runtime/gc_glue_java/MixedObjectScanner.hpp
5985 views
/*******************************************************************************1* Copyright (c) 2016, 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* @ingroup GC_Structs25*/2627#if !defined(MIXEDOBJECTSCANNER_HPP_)28#define MIXEDOBJECTSCANNER_HPP_2930#include "j9.h"31#include "j9cfg.h"32#include "modron.h"33#include "objectdescription.h"34#include "GCExtensions.hpp"35#include "HeadlessMixedObjectScanner.hpp"3637/**38* This class is used to iterate over the slots of a Java object.39*/40class GC_MixedObjectScanner : public GC_HeadlessMixedObjectScanner41{4243/* Data Members */44private:4546protected:4748public:4950/* Member Functions */51private:52protected:53/**54* @param env The scanning thread environment55* @param objectPtr the object to be processed56* @param flags Scanning context flags57*/58MMINLINE GC_MixedObjectScanner(MM_EnvironmentBase *env, omrobjectptr_t objectPtr, uintptr_t flags)59: GC_HeadlessMixedObjectScanner(env, env->getExtensions()->mixedObjectModel.getHeadlessObject(objectPtr), env->getExtensions()->mixedObjectModel.getSizeInBytesWithoutHeader(J9GC_J9OBJECT_CLAZZ(objectPtr, env)), flags)60{61_typeId = __FUNCTION__;62}6364/**65* Subclasses must call this method to set up the instance description bits and description pointer.66* @param[in] env The scanning thread environment67*/68MMINLINE void69initialize(MM_EnvironmentBase *env, J9Class *clazzPtr)70{71#if defined(J9VM_GC_LEAF_BITS)72GC_HeadlessMixedObjectScanner::initialize(env, clazzPtr->instanceDescription, clazzPtr->instanceLeafDescription);73#else /* J9VM_GC_LEAF_BITS */74GC_HeadlessMixedObjectScanner::initialize(env, clazzPtr->instanceDescription);75#endif /* J9VM_GC_LEAF_BITS */76}7778public:79/**80* In-place instantiation and initialization for mixed object scanner.81* @param[in] env The scanning thread environment82* @param[in] objectPtr The object to scan83* @param[in] allocSpace Pointer to space for in-place instantiation (at least sizeof(GC_MixedObjectScanner) bytes)84* @param[in] flags Scanning context flags85* @return Pointer to GC_MixedObjectScanner instance in allocSpace86*/87MMINLINE static GC_MixedObjectScanner *88newInstance(MM_EnvironmentBase *env, omrobjectptr_t objectPtr, void *allocSpace, uintptr_t flags)89{90GC_MixedObjectScanner *objectScanner = (GC_MixedObjectScanner *)allocSpace;91J9Class *classPtr = J9GC_J9OBJECT_CLAZZ(objectPtr, env);9293new(objectScanner) GC_MixedObjectScanner(env, objectPtr, flags);94objectScanner->initialize(env, classPtr);95return objectScanner;96}97};98#endif /* MIXEDOBJECTSCANNER_HPP_ */99100101