Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/arm/codegen/ARMHelperCallSnippet.cpp
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
#include "codegen/ARMHelperCallSnippet.hpp"
24
25
#include <stdint.h>
26
#include "codegen/CodeGenerator.hpp"
27
#include "codegen/Relocation.hpp"
28
#include "codegen/SnippetGCMap.hpp"
29
#include "env/jittypes.h"
30
#include "il/LabelSymbol.hpp"
31
#include "il/MethodSymbol.hpp"
32
#include "il/RegisterMappedSymbol.hpp"
33
#include "il/ResolvedMethodSymbol.hpp"
34
#include "il/StaticSymbol.hpp"
35
#include "il/Symbol.hpp"
36
#include "il/SymbolReference.hpp"
37
#include "runtime/CodeCacheManager.hpp"
38
39
uint8_t *TR::ARMHelperCallSnippet::emitSnippetBody()
40
{
41
uint8_t *buffer = cg()->getBinaryBufferCursor();
42
intptr_t distance = (intptr_t)getDestination()->getSymbol()->castToMethodSymbol()->getMethodAddress() - (intptr_t)buffer - 8;
43
44
getSnippetLabel()->setCodeLocation(buffer);
45
46
if (!(distance>=BRANCH_BACKWARD_LIMIT && distance<=BRANCH_FORWARD_LIMIT))
47
{
48
distance = TR::CodeCacheManager::instance()->findHelperTrampoline(getDestination()->getReferenceNumber(), (void *)buffer) - (intptr_t)buffer - 8;
49
TR_ASSERT(distance>=BRANCH_BACKWARD_LIMIT && distance<=BRANCH_FORWARD_LIMIT,
50
"CodeCache is more than 32MB.\n");
51
}
52
53
// b|bl distance
54
*(int32_t *)buffer = 0xea000000 | ((distance >> 2)& 0x00ffffff);
55
if (_restartLabel != NULL)
56
*(int32_t *)buffer |= 0x01000000;
57
cg()->addExternalRelocation(new (cg()->trHeapMemory()) TR::ExternalRelocation(
58
buffer,
59
(uint8_t *)getDestination(),
60
TR_HelperAddress, cg()), __FILE__, __LINE__, getNode());
61
buffer += 4;
62
63
gcMap().registerStackMap(buffer, cg());
64
65
if (_restartLabel != NULL)
66
{
67
int32_t returnDistance = _restartLabel->getCodeLocation() - buffer - 8 ;
68
*(int32_t *)buffer = 0xea000000 | ((returnDistance >> 2) & 0x00ffffff);
69
buffer += 4;
70
}
71
72
return buffer;
73
}
74
75
uint32_t TR::ARMHelperCallSnippet::getLength(int32_t estimatedSnippetStart)
76
{
77
return ((_restartLabel==NULL)?4:8);
78
}
79
80