Skip to content

Commit

Permalink
Merge pull request #6165 from knn-k/aarch64codegen10
Browse files Browse the repository at this point in the history
AArch64: Implement ARM64RecompilationSnippet
  • Loading branch information
0xdaryl committed Dec 2, 2019
2 parents feed4dd + ce8012d commit b25f8b0
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 0 deletions.
77 changes: 77 additions & 0 deletions runtime/compiler/aarch64/codegen/ARM64RecompilationSnippet.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*******************************************************************************
* Copyright (c) 2019, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* 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
*******************************************************************************/

#include "codegen/ARM64RecompilationSnippet.hpp"

#include "codegen/ARM64Instruction.hpp"
#include "codegen/CodeGenerator.hpp"

uint8_t *TR::ARM64RecompilationSnippet::emitSnippetBody()
{
uint8_t *buffer = cg()->getBinaryBufferCursor();
TR::SymbolReference *countingRecompMethodSymRef = cg()->symRefTab()->findOrCreateRuntimeHelper(TR_ARM64countingRecompileMethod, false, false, false);

getSnippetLabel()->setCodeLocation(buffer);

// bl symref
*(int32_t *)buffer = cg()->encodeHelperBranchAndLink(countingRecompMethodSymRef, buffer, getNode());
buffer += ARM64_INSTRUCTION_LENGTH;

// bodyinfo
*(intptr_t *)buffer = (intptr_t)cg()->comp()->getRecompilationInfo()->getJittedBodyInfo();
buffer += sizeof(intptr_t);

// startPC
*(intptr_t *)buffer = (intptr_t)cg()->getCodeStart();
buffer += sizeof(intptr_t);

return buffer;
}

uint32_t TR::ARM64RecompilationSnippet::getLength(int32_t estimatedSnippetStart)
{
return ARM64_INSTRUCTION_LENGTH + sizeof(intptr_t) + sizeof(intptr_t);
}

void
TR_Debug::print(TR::FILE *pOutFile, TR::ARM64RecompilationSnippet *snippet)
{
uint8_t *cursor = snippet->getSnippetLabel()->getCodeLocation();

printSnippetLabel(pOutFile, snippet->getSnippetLabel(), cursor, getName(snippet));

int32_t distance;
distance = *((int32_t *)cursor) & 0x03ffffff; // imm26
distance = (distance << 6) >> 4; // sign extend and add two 0 bits

printPrefix(pOutFile, NULL, cursor, ARM64_INSTRUCTION_LENGTH);
trfprintf(pOutFile, "bl \t" POINTER_PRINTF_FORMAT "\t\t; %s",
(intptr_t)cursor + distance, getRuntimeHelperName(TR_ARM64countingRecompileMethod));
cursor += ARM64_INSTRUCTION_LENGTH;

printPrefix(pOutFile, NULL, cursor, sizeof(intptr_t));
trfprintf(pOutFile, ".dword \t" POINTER_PRINTF_FORMAT "\t\t; BodyInfo", *(intptr_t *)cursor);
cursor += sizeof(intptr_t);

printPrefix(pOutFile, NULL, cursor, sizeof(intptr_t));
trfprintf(pOutFile, ".dword \t" POINTER_PRINTF_FORMAT "\t\t; startPC", *(intptr_t *)cursor);
}
59 changes: 59 additions & 0 deletions runtime/compiler/aarch64/codegen/ARM64RecompilationSnippet.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2019, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* 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
*******************************************************************************/

#ifndef ARM64RECOMPILATIONSNIPPET_INCL
#define ARM64RECOMPILATIONSNIPPET_INCL

#include "codegen/Snippet.hpp"

namespace TR { class CodeGenerator; }
namespace TR { class Instruction; }
namespace TR { class LabelSymbol; }

namespace TR {

class ARM64RecompilationSnippet : public TR::Snippet
{
TR::Instruction *branchToSnippet;

public:

ARM64RecompilationSnippet(
TR::LabelSymbol *snippetlab,
TR::Instruction *bts,
TR::CodeGenerator *cg)
: TR::Snippet(cg, 0, snippetlab, false), branchToSnippet(bts)
{
}

virtual Kind getKind() { return IsRecompilation; }

TR::Instruction *getBranchToSnippet() { return branchToSnippet; }

virtual uint8_t *emitSnippetBody();

virtual uint32_t getLength(int32_t estimatedSnippetStart);
};

} // TR

#endif
1 change: 1 addition & 0 deletions runtime/compiler/aarch64/codegen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ j9jit_files(
aarch64/codegen/ARM64JNILinkage.cpp
aarch64/codegen/ARM64PrivateLinkage.cpp
aarch64/codegen/ARM64Recompilation.cpp
aarch64/codegen/ARM64RecompilationSnippet.cpp
aarch64/codegen/CallSnippet.cpp
aarch64/codegen/ForceRecompilationSnippet.cpp
aarch64/codegen/J9ARM64Snippet.cpp
Expand Down
4 changes: 4 additions & 0 deletions runtime/compiler/aarch64/runtime/Recompilation.spp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@

.file "Recompilation.s"

.globl _countingRecompileMethod
.globl _initialInvokeExactThunkGlue
.globl _revertToInterpreterGlue

_countingRecompileMethod:
hlt #0 // Not implemented yet

_initialInvokeExactThunkGlue:
hlt #0 // Not implemented yet

Expand Down
1 change: 1 addition & 0 deletions runtime/compiler/build/files/target/aarch64.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ JIT_PRODUCT_SOURCE_FILES+= \
compiler/aarch64/codegen/ARM64JNILinkage.cpp \
compiler/aarch64/codegen/ARM64PrivateLinkage.cpp \
compiler/aarch64/codegen/ARM64Recompilation.cpp \
compiler/aarch64/codegen/ARM64RecompilationSnippet.cpp \
compiler/aarch64/codegen/CallSnippet.cpp \
compiler/aarch64/codegen/ForceRecompilationSnippet.cpp \
compiler/aarch64/codegen/J9ARM64Snippet.cpp \
Expand Down

0 comments on commit b25f8b0

Please sign in to comment.