Path: blob/master/runtime/compiler/x/amd64/codegen/AMD64JNILinkage.hpp
6004 views
/*******************************************************************************1* Copyright (c) 2000, 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#ifndef AMD64_JNILINKAGE_INCL23#define AMD64_JNILINKAGE_INCL2425#ifdef TR_TARGET_64BIT2627#include "x/amd64/codegen/AMD64SystemLinkage.hpp"2829#include "codegen/AMD64PrivateLinkage.hpp"30#include "env/jittypes.h"3132namespace TR { class CodeGenerator; }33namespace TR { class Instruction; }34namespace TR { class LabelSymbol; }35namespace TR { class Node; }36namespace TR { class RegisterDependencyConditions; }3738#define IMCOMPLETELINKAGE "This class is only used to generate call-out sequence but no call-in sequence, so it is not used as a complete linkage."3940namespace J941{4243namespace X8644{4546namespace AMD6447{4849class JNILinkage : public PrivateLinkage50{51public:5253JNILinkage(TR::AMD64SystemLinkage *systemLinkage, TR::CodeGenerator *cg) :54PrivateLinkage(cg),55_systemLinkage(systemLinkage) {}5657int32_t computeMemoryArgSize(TR::Node *callNode, int32_t first, int32_t last, bool passThread = true);58int32_t buildArgs(TR::Node *callNode, TR::RegisterDependencyConditions *deps, bool passThread = true, bool passReceiver = true);59TR::Register *buildVolatileAndReturnDependencies(TR::Node *callNode, TR::RegisterDependencyConditions *deps, bool omitDedicatedFrameRegister);60void cleanupReturnValue(TR::Node *callNode, TR::Register *linkageReturnReg, TR::Register *targetReg);6162TR::Register *buildDirectDispatch(TR::Node *callNode, bool spillFPRegs);6364void buildJNICallOutFrame(TR::Node *callNode, TR::LabelSymbol *returnAddrLabel);65void buildJNIMergeLabelDependencies(TR::Node *callNode, bool killNonVolatileGPRs = true);66void buildOutgoingJNIArgsAndDependencies(TR::Node *callNode, bool passThread = true, bool passReceiver = true, bool killNonVolatileGPRs = true);67TR::Register *processJNIReferenceArg(TR::Node *child);68TR::Instruction *generateMethodDispatch(TR::Node *callNode, bool isJNIGCPoint = true, uintptr_t targetAddress = 0);69void releaseVMAccess(TR::Node *callNode);70void acquireVMAccess(TR::Node *callNode);71#ifdef J9VM_INTERP_ATOMIC_FREE_JNI72void releaseVMAccessAtomicFree(TR::Node *callNode);73void acquireVMAccessAtomicFree(TR::Node *callNode);74#endif /* J9VM_INTERP_ATOMIC_FREE_JNI */75void checkForJNIExceptions(TR::Node *callNode);76void cleanupJNIRefPool(TR::Node *callNode);77void populateJNIDispatchInfo();7879private:8081TR::Register *buildDirectJNIDispatch(TR::Node *callNode);82TR::AMD64SystemLinkage *_systemLinkage;8384class TR_JNIDispatchInfo85{86public:8788int32_t numJNIFrameSlotsPushed;89int32_t argSize;90bool requiresFPstackPop;9192TR::Register *JNIReturnRegister;93TR::Register *linkageReturnRegister;94TR::Register *dispatchTrampolineRegister;95TR::RealRegister::RegNum dedicatedFrameRegisterIndex;9697TR::RegisterDependencyConditions *callPreDeps;98TR::RegisterDependencyConditions *callPostDeps;99TR::RegisterDependencyConditions *mergeLabelPostDeps;100} _JNIDispatchInfo;101102};103104}105106}107108}109110#endif111112#endif113114115