Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/bcutil/SRPKeyProducer.hpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 2001, 2021 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* 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 and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
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-exception
21
*******************************************************************************/
22
23
/*
24
* SRPKeyProducer.hpp
25
*/
26
27
#ifndef SRPKEYPRODUCER_HPP_
28
#define SRPKEYPRODUCER_HPP_
29
30
/* @ddr_namespace: default */
31
#include "j9comp.h"
32
#include "ut_j9bcu.h"
33
#include "ROMClassBuilder.hpp" /* included to obtain definition of InterfaceInjectionInfo */
34
35
class ClassFileOracle;
36
37
class SRPKeyProducer
38
{
39
public:
40
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
41
SRPKeyProducer(ClassFileOracle *classFileOracle, InterfaceInjectionInfo *interfaceInjectionInfo);
42
#else /* J9VM_OPT_VALHALLA_VALUE_TYPES */
43
SRPKeyProducer(ClassFileOracle *classFileOracle);
44
#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */
45
46
/* generateKey can no-longer be called after getMaxKey has been called */
47
UDATA generateKey();
48
UDATA getMaxKey();
49
50
UDATA mapCfrConstantPoolIndexToKey(U_16 index)
51
{
52
U_16 maxIndex = _cfrConstantPoolCount;
53
54
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
55
maxIndex += _numOfInterfacesToInject;
56
#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */
57
58
Trc_BCU_Assert_LessThan(index, maxIndex);
59
return index;
60
}
61
62
U_16 mapKeyToCfrConstantPoolIndex(UDATA key)
63
{
64
U_16 maxIndex = _cfrConstantPoolCount;
65
66
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
67
maxIndex += _numOfInterfacesToInject;
68
#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */
69
70
Trc_BCU_Assert_LessThan(key, maxIndex);
71
return U_16(key);
72
}
73
74
UDATA mapMethodIndexToStackMapKey(U_16 index)
75
{
76
Trc_BCU_Assert_LessThan(index, _methodCount);
77
return UDATA(index) + _startStackMapKeys;
78
}
79
80
UDATA mapMethodIndexToMethodDebugInfoKey(U_16 index)
81
{
82
Trc_BCU_Assert_LessThan(index, _methodCount);
83
return UDATA(index) + _startMethodDebugInfoKeys;
84
}
85
86
UDATA mapMethodIndexToVariableInfoKey(U_16 index)
87
{
88
Trc_BCU_Assert_LessThan(index, _methodCount);
89
return UDATA(index) + _startVariableInfoKeys;
90
}
91
92
bool isKeyToCfrConstantPoolItem(UDATA key) { return key < _cfrConstantPoolCount;}
93
94
private:
95
U_16 _cfrConstantPoolCount;
96
U_16 _methodCount;
97
UDATA _startStackMapKeys;
98
UDATA _startMethodDebugInfoKeys;
99
UDATA _startVariableInfoKeys;
100
UDATA _maxKey;
101
bool _getMaxKeyWasCalled;
102
#if defined(J9VM_OPT_VALHALLA_VALUE_TYPES)
103
U_16 _numOfInterfacesToInject;
104
#endif /* J9VM_OPT_VALHALLA_VALUE_TYPES */
105
};
106
107
#endif /* SRPKEYPRODUCER_HPP_ */
108
109