Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/x/codegen/AllocPrefetchSnippet.hpp
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2020 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
#ifndef IA32ALLOCPREFETCHSNIPPET_INCL
24
#define IA32ALLOCPREFETCHSNIPPET_INCL
25
26
#include "x/codegen/RestartSnippet.hpp"
27
28
namespace TR {
29
void createCCPreLoadedCode(uint8_t *CCPreLoadedCodeBase, uint8_t *CCPreLoadedCodeTop, void ** CCPreLoadedCodeTable, TR::CodeGenerator *cg);
30
uint32_t getCCPreLoadedCodeSize();
31
}
32
33
34
struct TR_X86AllocPrefetchGeometry
35
{
36
public:
37
38
TR_X86AllocPrefetchGeometry(int32_t prefetchLineSize, int32_t prefetchLineCount, int32_t prefetchStaggeredLineCount, int32_t prefetchBoundaryLineCount, int32_t prefetchTLHEndLineCount) :
39
_prefetchLineSize(prefetchLineSize),
40
_prefetchLineCount(prefetchLineCount),
41
_prefetchStaggeredLineCount(prefetchStaggeredLineCount),
42
_prefetchBoundaryLineCount(prefetchBoundaryLineCount),
43
_prefetchTLHEndLineCount(prefetchTLHEndLineCount)
44
{}
45
46
int32_t getPrefetchLineSize() const { return _prefetchLineSize; }
47
int32_t getPrefetchLineCount() const { return _prefetchLineCount; }
48
int32_t getPrefetchStaggeredLineCount() const { return _prefetchStaggeredLineCount; }
49
int32_t getPrefetchBoundaryLineCount() const { return _prefetchBoundaryLineCount; }
50
int32_t getPrefetchTLHEndLineCount() const { return _prefetchTLHEndLineCount; }
51
52
int32_t sizeOfTLHEndCount() const { return getPrefetchTLHEndLineCount() * getPrefetchLineSize(); }
53
bool needWideDisplacementForTLHEndCount() const { return (sizeOfTLHEndCount() > 127 || sizeOfTLHEndCount() < -128); }
54
55
private:
56
int32_t _prefetchLineSize;
57
int32_t _prefetchLineCount;
58
int32_t _prefetchStaggeredLineCount;
59
int32_t _prefetchBoundaryLineCount;
60
int32_t _prefetchTLHEndLineCount;
61
};
62
63
namespace TR {
64
65
struct HeapTypes
66
{
67
enum Type
68
{
69
ZeroedHeap,
70
NonZeroedHeap
71
};
72
static const char * const getPrefix(size_t index)
73
{ static const char * const prefixes[] =
74
{
75
"Zeroed",
76
"Non-Zeroed"
77
};
78
return prefixes[index];
79
}
80
};
81
82
class X86AllocPrefetchSnippet : public TR::X86RestartSnippet
83
{
84
public:
85
86
X86AllocPrefetchSnippet(TR::CodeGenerator *cg,
87
TR::Node *node,
88
int32_t prefetchSize,
89
TR::LabelSymbol *restartlab,
90
TR::LabelSymbol *snippetlab,
91
bool nonZeroTLH)
92
: TR::X86RestartSnippet(cg, node, restartlab, snippetlab, false)
93
{
94
_prefetchSize = prefetchSize;
95
_nonZeroTLH = nonZeroTLH;
96
}
97
98
virtual uint8_t *emitSnippetBody();
99
100
virtual uint32_t getLength(int32_t estimatedSnippetStart);
101
102
int32_t getPrefetchSize() { return _prefetchSize; }
103
104
bool isNonZeroTLH() { return _nonZeroTLH; }
105
106
private:
107
108
static TR_X86AllocPrefetchGeometry generatePrefetchGeometry();
109
template <TR::HeapTypes::Type HEAP_TYPE, bool is64Bit> static int32_t sizeOfSharedBody();
110
template <TR::HeapTypes::Type HEAP_TYPE, bool is64Bit> static uint8_t* emitSharedBody(uint8_t *, TR::Compilation*);
111
112
friend void TR::createCCPreLoadedCode(uint8_t *CCPreLoadedCodeBase, uint8_t *CCPreLoadedCodeTop, void ** CCPreLoadedCodeTable, TR::CodeGenerator *cg);
113
friend uint32_t TR::getCCPreLoadedCodeSize();
114
115
int32_t _prefetchSize;
116
bool _nonZeroTLH;
117
118
};
119
120
}
121
122
#endif
123
124