Path: blob/master/runtime/bcutil/SRPKeyProducer.hpp
5985 views
/*******************************************************************************1* Copyright (c) 2001, 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/*23* SRPKeyProducer.hpp24*/2526#ifndef SRPKEYPRODUCER_HPP_27#define SRPKEYPRODUCER_HPP_2829/* @ddr_namespace: default */30#include "j9comp.h"31#include "ut_j9bcu.h"32#include "ROMClassBuilder.hpp" /* included to obtain definition of InterfaceInjectionInfo */3334class ClassFileOracle;3536class SRPKeyProducer37{38public:39#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)40SRPKeyProducer(ClassFileOracle *classFileOracle, InterfaceInjectionInfo *interfaceInjectionInfo);41#else /* J9VM_OPT_VALHALLA_VALUE_TYPES */42SRPKeyProducer(ClassFileOracle *classFileOracle);43#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */4445/* generateKey can no-longer be called after getMaxKey has been called */46UDATA generateKey();47UDATA getMaxKey();4849UDATA mapCfrConstantPoolIndexToKey(U_16 index)50{51U_16 maxIndex = _cfrConstantPoolCount;5253#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)54maxIndex += _numOfInterfacesToInject;55#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */5657Trc_BCU_Assert_LessThan(index, maxIndex);58return index;59}6061U_16 mapKeyToCfrConstantPoolIndex(UDATA key)62{63U_16 maxIndex = _cfrConstantPoolCount;6465#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)66maxIndex += _numOfInterfacesToInject;67#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */6869Trc_BCU_Assert_LessThan(key, maxIndex);70return U_16(key);71}7273UDATA mapMethodIndexToStackMapKey(U_16 index)74{75Trc_BCU_Assert_LessThan(index, _methodCount);76return UDATA(index) + _startStackMapKeys;77}7879UDATA mapMethodIndexToMethodDebugInfoKey(U_16 index)80{81Trc_BCU_Assert_LessThan(index, _methodCount);82return UDATA(index) + _startMethodDebugInfoKeys;83}8485UDATA mapMethodIndexToVariableInfoKey(U_16 index)86{87Trc_BCU_Assert_LessThan(index, _methodCount);88return UDATA(index) + _startVariableInfoKeys;89}9091bool isKeyToCfrConstantPoolItem(UDATA key) { return key < _cfrConstantPoolCount;}9293private:94U_16 _cfrConstantPoolCount;95U_16 _methodCount;96UDATA _startStackMapKeys;97UDATA _startMethodDebugInfoKeys;98UDATA _startVariableInfoKeys;99UDATA _maxKey;100bool _getMaxKeyWasCalled;101#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)102U_16 _numOfInterfacesToInject;103#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */104};105106#endif /* SRPKEYPRODUCER_HPP_ */107108109