Path: blob/master/runtime/compiler/env/J9ObjectModel.hpp
6000 views
/*******************************************************************************1* Copyright (c) 2000, 2022 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#ifndef J9_OBJECTMODEL_INCL23#define J9_OBJECTMODEL_INCL2425/*26* The following #define and typedef must appear before any #includes in this file27*/28#ifndef J9_OBJECTMODEL_CONNECTOR29#define J9_OBJECTMODEL_CONNECTOR30namespace J9 { class ObjectModel; }31namespace J9 { typedef J9::ObjectModel ObjectModelConnector; }32#endif3334#include "env/OMRObjectModel.hpp"3536#include <stdint.h>37#include "env/jittypes.h"3839namespace TR { class Node; }40namespace TR { class Compilation; }4142namespace J943{4445class ObjectModel : public OMR::ObjectModelConnector46{47public:4849ObjectModel() :50OMR::ObjectModelConnector(),51_compressObjectReferences(false),52_usesDiscontiguousArraylets(false),53_arrayLetLeafSize(0),54_arrayLetLeafLogSize(0),55_readBarrierType(gc_modron_readbar_none),56_writeBarrierType(gc_modron_wrtbar_none),57_objectAlignmentInBytes(0)58{}5960void initialize();6162bool mayRequireSpineChecks();6364bool areValueTypesEnabled();65/**66* @brief Whether the check is enabled on monitor object being value based class type67*/68bool areValueBasedMonitorChecksEnabled();6970int32_t sizeofReferenceField();71bool isHotReferenceFieldRequired();72uintptr_t elementSizeOfBooleanArray();73uint32_t getSizeOfArrayElement(TR::Node *node);74int64_t maxArraySizeInElementsForAllocation(TR::Node *newArray, TR::Compilation *comp);75int64_t maxArraySizeInElements(int32_t knownMinElementSize, TR::Compilation *comp);7677int32_t maxContiguousArraySizeInBytes();7879uintptr_t contiguousArrayHeaderSizeInBytes();8081uintptr_t discontiguousArrayHeaderSizeInBytes();8283// For array access84bool isDiscontiguousArray(int32_t sizeInBytes);85bool isDiscontiguousArray(int32_t sizeInElements, int32_t elementSize);86bool isDiscontiguousArray(TR::Compilation* comp, uintptr_t objectPointer);87intptr_t getArrayLengthInElements(TR::Compilation* comp, uintptr_t objectPointer);88uintptr_t getArrayLengthInBytes(TR::Compilation* comp, uintptr_t objectPointer);89uintptr_t getArrayElementWidthInBytes(TR::DataType type);90uintptr_t getArrayElementWidthInBytes(TR::Compilation* comp, uintptr_t objectPointer);91uintptr_t getAddressOfElement(TR::Compilation* comp, uintptr_t objectPointer, int64_t offset);92uintptr_t decompressReference(TR::Compilation* comp, uintptr_t compressedReference);9394bool generateCompressedObjectHeaders();9596bool usesDiscontiguousArraylets();97bool canGenerateArraylets() { return usesDiscontiguousArraylets(); }98bool useHybridArraylets() { return usesDiscontiguousArraylets(); }99int32_t arrayletLeafSize();100int32_t arrayletLeafLogSize();101102int32_t compressedReferenceShiftOffset();103int32_t compressedReferenceShift();104105bool nativeAddressesCanChangeSize();106107uintptr_t offsetOfObjectVftField();108109uintptr_t offsetOfHeaderFlags();110111uintptr_t maskOfObjectVftField();112113int32_t arraySpineShift(int32_t width);114int32_t arrayletMask(int32_t width);115int32_t arrayletLeafIndex(int32_t index, int32_t elementSize);116int32_t objectAlignmentInBytes();117uintptr_t offsetOfContiguousArraySizeField();118uintptr_t offsetOfDiscontiguousArraySizeField();119uintptr_t objectHeaderSizeInBytes();120uintptr_t offsetOfIndexableSizeField();121#if defined(TR_TARGET_64BIT)122uintptr_t offsetOfContiguousDataAddrField();123uintptr_t offsetOfDiscontiguousDataAddrField();124#endif /* TR_TARGET_64BIT */125126/**127* @brief Returns the read barrier type of VM's GC128*/129MM_GCReadBarrierType readBarrierType();130131/**132* @brief Returns the write barrier type of VM's GC133*/134MM_GCWriteBarrierType writeBarrierType();135136/**137* @brief Returns whether or not object references are compressed138*/139bool compressObjectReferences();140141int32_t getObjectAlignmentInBytes();142143private:144145bool _compressObjectReferences;146bool _usesDiscontiguousArraylets;147int32_t _arrayLetLeafSize;148int32_t _arrayLetLeafLogSize;149MM_GCReadBarrierType _readBarrierType;150MM_GCWriteBarrierType _writeBarrierType;151int32_t _objectAlignmentInBytes;152};153154}155156#endif157158159