Path: blob/master/runtime/gc_glue_java/MixedObjectModel.hpp
5990 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#if !defined(MIXEDOBJECTMODEL_HPP_)23#define MIXEDOBJECTMODEL_HPP_2425#include "j9.h"26#include "j9cfg.h"27#include "modron.h"28#include "objectdescription.h"2930#include "Bits.hpp"3132class MM_GCExtensionsBase;3334/**35* Provides information for mixed objects.36* @ingroup GC_Base37*/38class GC_MixedObjectModel39{4041/*42* Data members43*/44private:45protected:46#if defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS)47bool _compressObjectReferences;48#endif /* defined(OMR_GC_COMPRESSED_POINTERS) && defined(OMR_GC_FULL_POINTERS) */49public:5051/*52* Function members53*/54private:55protected:56public:57/**58* Return back true if object references are compressed59* @return true, if object references are compressed60*/61MMINLINE bool62compressObjectReferences()63{64return OMR_COMPRESS_OBJECT_REFERENCES(_compressObjectReferences);65}6667/**68* Returns the size of a class, in bytes, excluding the header.69* @param clazzPtr Pointer to the class whose size is required70* @return Size of class in bytes excluding the header71*/72MMINLINE UDATA73getSizeInBytesWithoutHeader(J9Class *clazz)74{75return clazz->totalInstanceSize;76}7778/**79* Returns the size of a mixed object, in bytes, excluding the header.80* @param objectPtr Pointer to the object whose size is required81* @return Size of object in bytes excluding the header82*/83MMINLINE UDATA84getSizeInBytesWithoutHeader(J9Object *objectPtr)85{86return getSizeInBytesWithoutHeader(J9GC_J9OBJECT_CLAZZ(objectPtr, this));87}8889/**90* Returns the size of a mixed object, in bytes, including the header.91* @param objectPtr Pointer to the object whose size is required92* @return Size of object in bytes including the header93*/94MMINLINE UDATA95getSizeInBytesWithHeader(J9Object *objectPtr)96{97return getSizeInBytesWithoutHeader(objectPtr) + getHeaderSize(objectPtr);98}99100/**101* Returns an address of first data slot of the object102* @param objectPtr Pointer to the object103* @return Address of first data slot of the object104*/105MMINLINE fomrobject_t *106getHeadlessObject(J9Object *objectPtr)107{108return (fomrobject_t *)((uint8_t*)objectPtr + getHeaderSize(objectPtr));109}110111/**112* Returns the header size of a given object.113* @param arrayPtr Ptr to an array for which header size will be returned114* @return Size of header in bytes115*/116MMINLINE UDATA117getHeaderSize(J9Object *objectPtr)118{119return J9GC_OBJECT_HEADER_SIZE(this);120}121122/**123* Returns the offset of the hashcode slot, in bytes, from the beginning of the header.124* @param clazzPtr Pointer to the class of the object125* @return offset of the hashcode slot126*/127MMINLINE UDATA128getHashcodeOffset(J9Class *clazzPtr)129{130return clazzPtr->backfillOffset;131}132133/**134* Returns the offset of the hashcode slot, in bytes, from the beginning of the header.135* @param arrayPtr Pointer to the object136* @return offset of the hashcode slot137*/138MMINLINE UDATA139getHashcodeOffset(J9Object *objectPtr)140{141return getHashcodeOffset(J9GC_J9OBJECT_CLAZZ(objectPtr, this));142}143144/**145* Initialize the receiver, a new instance of GC_ObjectModel146*147* @return true on success, false on failure148*/149bool initialize(MM_GCExtensionsBase *extensions);150151/**152* Tear down the receiver153*/154void tearDown(MM_GCExtensionsBase *extensions);155};156157#endif /* MIXEDOBJECTMODEL_HPP_ */158159160