-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6165 from knn-k/aarch64codegen10
AArch64: Implement ARM64RecompilationSnippet
- Loading branch information
Showing
5 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
runtime/compiler/aarch64/codegen/ARM64RecompilationSnippet.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
59
runtime/compiler/aarch64/codegen/ARM64RecompilationSnippet.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters