Path: blob/master/runtime/compiler/aarch64/codegen/ARM64RecompilationSnippet.cpp
6004 views
/*******************************************************************************1* Copyright (c) 2019, 2020 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/2122#include "codegen/ARM64RecompilationSnippet.hpp"2324#include "codegen/ARM64Instruction.hpp"25#include "codegen/CodeGenerator.hpp"2627uint8_t *TR::ARM64RecompilationSnippet::emitSnippetBody()28{29uint8_t *buffer = cg()->getBinaryBufferCursor();30TR::SymbolReference *countingRecompMethodSymRef = cg()->symRefTab()->findOrCreateRuntimeHelper(TR_ARM64countingRecompileMethod);3132getSnippetLabel()->setCodeLocation(buffer);3334// bl symref35*(int32_t *)buffer = cg()->encodeHelperBranchAndLink(countingRecompMethodSymRef, buffer, getNode());36buffer += ARM64_INSTRUCTION_LENGTH;3738// bodyinfo39*(intptr_t *)buffer = (intptr_t)cg()->comp()->getRecompilationInfo()->getJittedBodyInfo();40buffer += sizeof(intptr_t);4142// startPC43*(intptr_t *)buffer = (intptr_t)cg()->getCodeStart();44buffer += sizeof(intptr_t);4546return buffer;47}4849uint32_t TR::ARM64RecompilationSnippet::getLength(int32_t estimatedSnippetStart)50{51return ARM64_INSTRUCTION_LENGTH + sizeof(intptr_t) + sizeof(intptr_t);52}5354void55TR_Debug::print(TR::FILE *pOutFile, TR::ARM64RecompilationSnippet *snippet)56{57uint8_t *cursor = snippet->getSnippetLabel()->getCodeLocation();5859printSnippetLabel(pOutFile, snippet->getSnippetLabel(), cursor, getName(snippet));6061int32_t distance;62distance = *((int32_t *)cursor) & 0x03ffffff; // imm2663distance = (distance << 6) >> 4; // sign extend and add two 0 bits6465printPrefix(pOutFile, NULL, cursor, ARM64_INSTRUCTION_LENGTH);66trfprintf(pOutFile, "bl \t" POINTER_PRINTF_FORMAT "\t\t; %s",67(intptr_t)cursor + distance, getRuntimeHelperName(TR_ARM64countingRecompileMethod));68cursor += ARM64_INSTRUCTION_LENGTH;6970printPrefix(pOutFile, NULL, cursor, sizeof(intptr_t));71trfprintf(pOutFile, ".dword \t" POINTER_PRINTF_FORMAT "\t\t; BodyInfo", *(intptr_t *)cursor);72cursor += sizeof(intptr_t);7374printPrefix(pOutFile, NULL, cursor, sizeof(intptr_t));75trfprintf(pOutFile, ".dword \t" POINTER_PRINTF_FORMAT "\t\t; startPC", *(intptr_t *)cursor);76}777879