Skip to content

Commit 59b9ffa

Browse files
committed
Provide PrivateLinkage implementations for method entry inquiries
* `entryPointFromCompiledMethod` will answer the question using the LinkageInfo word * `entryPointFromInterpretedMethod` will answer using the start of the code buffer Signed-off-by: Daryl Maier <maier@ca.ibm.com>
1 parent fcb6d3f commit 59b9ffa

File tree

6 files changed

+72
-3
lines changed

6 files changed

+72
-3
lines changed

runtime/compiler/build/files/common.mk

+1
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ JIT_PRODUCT_SOURCE_FILES+=\
266266
compiler/codegen/J9WatchedInstanceFieldSnippet.cpp \
267267
compiler/codegen/J9WatchedStaticFieldSnippet.cpp \
268268
compiler/codegen/MonitorState.cpp \
269+
compiler/codegen/PrivateLinkage.cpp \
269270
compiler/compile/J9AliasBuilder.cpp \
270271
compiler/compile/J9Compilation.cpp \
271272
compiler/compile/J9Method.cpp \

runtime/compiler/codegen/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
################################################################################
2-
# Copyright (c) 2017, 2019 IBM Corp. and others
2+
# Copyright (c) 2017, 2020 IBM Corp. and others
33
#
44
# This program and the accompanying materials are made available under
55
# the terms of the Eclipse Public License 2.0 which accompanies this
@@ -25,6 +25,7 @@ j9jit_files(
2525
codegen/CodeGenGPU.cpp
2626
codegen/CodeGenRA.cpp
2727
codegen/MonitorState.cpp
28+
codegen/PrivateLinkage.cpp
2829
codegen/J9AheadOfTimeCompile.cpp
2930
codegen/J9CodeGenerator.cpp
3031
codegen/J9CodeGenPhase.cpp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2020, 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/CodeGenerator.hpp"
24+
#include "codegen/Linkage_inlines.hpp"
25+
#include "codegen/PrivateLinkage.hpp"
26+
#include "env/jittypes.h"
27+
28+
intptr_t
29+
J9::PrivateLinkage::entryPointFromCompiledMethod()
30+
{
31+
uint8_t *methodEntry = cg()->getCodeStart();
32+
methodEntry += J9::PrivateLinkage::LinkageInfo::get(methodEntry)->getReservedWord();
33+
return reinterpret_cast<intptr_t>(methodEntry);
34+
}
35+
36+
intptr_t
37+
J9::PrivateLinkage::entryPointFromInterpretedMethod()
38+
{
39+
return reinterpret_cast<intptr_t>(cg()->getCodeStart());
40+
}

runtime/compiler/codegen/PrivateLinkage.hpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2019 IBM Corp. and others
2+
* Copyright (c) 2000, 2020 IBM Corp. and others
33
*
44
* This program and the accompanying materials are made available under
55
* the terms of the Eclipse Public License 2.0 which accompanies this
@@ -24,6 +24,7 @@
2424
#define J9_PRIVATELINKAGE_INCL
2525

2626
#include "codegen/Linkage.hpp"
27+
#include "env/jittypes.h"
2728
#include "infra/Assert.hpp"
2829

2930
namespace TR { class CodeGenerator; }
@@ -119,6 +120,16 @@ class PrivateLinkage : public TR::Linkage
119120
LinkageInfo() {};
120121
};
121122

123+
/**
124+
* @brief J9 private linkage override of OMR function
125+
*/
126+
virtual intptr_t entryPointFromCompiledMethod();
127+
128+
/**
129+
* @brief J9 private linkage override of OMR function
130+
*/
131+
virtual intptr_t entryPointFromInterpretedMethod();
132+
122133
};
123134

124135
}

runtime/compiler/x/i386/codegen/IA32PrivateLinkage.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -720,3 +720,8 @@ void J9::X86::I386::PrivateLinkage::buildVirtualOrComputedCall(
720720
}
721721
}
722722

723+
intptr_t
724+
J9::X86::I386::PrivateLinkage::entryPointFromCompiledMethod()
725+
{
726+
return reinterpret_cast<intptr_t>(cg()->getCodeStart());
727+
}

runtime/compiler/x/i386/codegen/IA32PrivateLinkage.hpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2019 IBM Corp. and others
2+
* Copyright (c) 2000, 2020 IBM Corp. and others
33
*
44
* This program and the accompanying materials are made available under
55
* the terms of the Eclipse Public License 2.0 which accompanies this
@@ -24,6 +24,7 @@
2424
#define IA32LINKAGE_INCL
2525

2626
#include "codegen/X86PrivateLinkage.hpp"
27+
#include "env/jittypes.h"
2728

2829
namespace TR { class UnresolvedDataSnippet; }
2930

@@ -47,6 +48,16 @@ class PrivateLinkage : public J9::X86::PrivateLinkage
4748

4849
TR::UnresolvedDataSnippet *generateX86UnresolvedDataSnippetWithCPIndex(TR::Node *child, TR::SymbolReference *symRef, int32_t cpIndex);
4950

51+
/**
52+
* @brief J9 private linkage override of OMR function
53+
*/
54+
virtual intptr_t entryPointFromCompiledMethod();
55+
56+
/**
57+
* @brief J9 private linkage override of OMR function
58+
*/
59+
virtual intptr_t entryPointFromInterpretedMethod();
60+
5061
protected:
5162

5263
virtual TR::Instruction *savePreservedRegisters(TR::Instruction *cursor);

0 commit comments

Comments
 (0)