Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/aarch64/codegen/ARM64RecompilationSnippet.cpp
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2019, 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
#include "codegen/ARM64RecompilationSnippet.hpp"
24
25
#include "codegen/ARM64Instruction.hpp"
26
#include "codegen/CodeGenerator.hpp"
27
28
uint8_t *TR::ARM64RecompilationSnippet::emitSnippetBody()
29
{
30
uint8_t *buffer = cg()->getBinaryBufferCursor();
31
TR::SymbolReference *countingRecompMethodSymRef = cg()->symRefTab()->findOrCreateRuntimeHelper(TR_ARM64countingRecompileMethod);
32
33
getSnippetLabel()->setCodeLocation(buffer);
34
35
// bl symref
36
*(int32_t *)buffer = cg()->encodeHelperBranchAndLink(countingRecompMethodSymRef, buffer, getNode());
37
buffer += ARM64_INSTRUCTION_LENGTH;
38
39
// bodyinfo
40
*(intptr_t *)buffer = (intptr_t)cg()->comp()->getRecompilationInfo()->getJittedBodyInfo();
41
buffer += sizeof(intptr_t);
42
43
// startPC
44
*(intptr_t *)buffer = (intptr_t)cg()->getCodeStart();
45
buffer += sizeof(intptr_t);
46
47
return buffer;
48
}
49
50
uint32_t TR::ARM64RecompilationSnippet::getLength(int32_t estimatedSnippetStart)
51
{
52
return ARM64_INSTRUCTION_LENGTH + sizeof(intptr_t) + sizeof(intptr_t);
53
}
54
55
void
56
TR_Debug::print(TR::FILE *pOutFile, TR::ARM64RecompilationSnippet *snippet)
57
{
58
uint8_t *cursor = snippet->getSnippetLabel()->getCodeLocation();
59
60
printSnippetLabel(pOutFile, snippet->getSnippetLabel(), cursor, getName(snippet));
61
62
int32_t distance;
63
distance = *((int32_t *)cursor) & 0x03ffffff; // imm26
64
distance = (distance << 6) >> 4; // sign extend and add two 0 bits
65
66
printPrefix(pOutFile, NULL, cursor, ARM64_INSTRUCTION_LENGTH);
67
trfprintf(pOutFile, "bl \t" POINTER_PRINTF_FORMAT "\t\t; %s",
68
(intptr_t)cursor + distance, getRuntimeHelperName(TR_ARM64countingRecompileMethod));
69
cursor += ARM64_INSTRUCTION_LENGTH;
70
71
printPrefix(pOutFile, NULL, cursor, sizeof(intptr_t));
72
trfprintf(pOutFile, ".dword \t" POINTER_PRINTF_FORMAT "\t\t; BodyInfo", *(intptr_t *)cursor);
73
cursor += sizeof(intptr_t);
74
75
printPrefix(pOutFile, NULL, cursor, sizeof(intptr_t));
76
trfprintf(pOutFile, ".dword \t" POINTER_PRINTF_FORMAT "\t\t; startPC", *(intptr_t *)cursor);
77
}
78
79