Path: blob/master/runtime/compiler/aarch64/codegen/ARM64Recompilation.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/ARM64Recompilation.hpp"23#include "codegen/ARM64RecompilationSnippet.hpp"24#include "codegen/CodeGenerator.hpp"25#include "codegen/GenerateInstructions.hpp"2627TR_ARM64Recompilation::TR_ARM64Recompilation(TR::Compilation * comp)28: TR::Recompilation(comp)29{30_countingSupported = true;3132setupMethodInfo();33}3435TR::Recompilation *TR_ARM64Recompilation::allocate(TR::Compilation *comp)36{37if (comp->isRecompilationEnabled())38{39return new (comp->trHeapMemory()) TR_ARM64Recompilation(comp);40}4142return NULL;43}4445TR_PersistentMethodInfo *TR_ARM64Recompilation::getExistingMethodInfo(TR_ResolvedMethod *method)46{47int8_t *startPC = (int8_t *)method->startAddressForInterpreterOfJittedMethod();48TR_PersistentMethodInfo *info = getJittedBodyInfoFromPC(startPC)->getMethodInfo();49return info;50}5152TR::Instruction *TR_ARM64Recompilation::generatePrePrologue()53{54TR_J9VMBase *fej9 = (TR_J9VMBase *)(comp()->fe());5556// If in Full Speed Debug, allow to go through57if (!couldBeCompiledAgain() && !_compilation->getOption(TR_FullSpeedDebug))58return NULL;5960// x9 may contain the vtable offset, and must be preserved here61// See PicBuilder.spp and Recompilation.spp62TR::Instruction *cursor = NULL;63TR::Machine *machine = cg()->machine();64TR::Register *x8 = machine->getRealRegister(TR::RealRegister::x8);65TR::Register *lr = machine->getRealRegister(TR::RealRegister::lr); // Link Register66TR::Register *xzr = machine->getRealRegister(TR::RealRegister::xzr); // zero register67TR::Node *firstNode = comp()->getStartTree()->getNode();68TR::SymbolReference *recompileMethodSymRef = cg()->symRefTab()->findOrCreateRuntimeHelper(TR_ARM64samplingRecompileMethod);69TR_PersistentJittedBodyInfo *info = getJittedBodyInfo();7071// Force creation of switch to interpreter preprologue if in Full Speed Debug72if (cg()->mustGenerateSwitchToInterpreterPrePrologue())73{74cursor = cg()->generateSwitchToInterpreterPrePrologue(cursor, firstNode);75}7677if (useSampling() && couldBeCompiledAgain())78{79// x8 must contain the saved LR; see Recompilation.spp80// cannot use generateMovInstruction() here81cursor = new (cg()->trHeapMemory()) TR::ARM64Trg1Src2Instruction(TR::InstOpCode::orrx, firstNode, x8, xzr, lr, cursor, cg());82cursor = generateImmSymInstruction(cg(), TR::InstOpCode::bl, firstNode,83(uintptr_t)recompileMethodSymRef->getMethodAddress(),84new (cg()->trHeapMemory()) TR::RegisterDependencyConditions(0, 0, cg()->trMemory()),85recompileMethodSymRef, NULL, cursor);86cursor = generateRelocatableImmInstruction(cg(), TR::InstOpCode::dd, firstNode, (uintptr_t)info, TR_BodyInfoAddress, cursor);8788// space for preserving original jitEntry instruction89cursor = generateImmInstruction(cg(), TR::InstOpCode::dd, firstNode, 0, cursor);90}9192return cursor;93}9495TR::Instruction *TR_ARM64Recompilation::generatePrologue(TR::Instruction *cursor)96{97TR::Recompilation *recomp = comp()->getRecompilationInfo();98if (!recomp->useSampling())99{100// counting recompilation101TR_UNIMPLEMENTED();102}103return cursor;104}105106107