Path: blob/master/runtime/compiler/z/codegen/S390J9CallSnippet.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 TR_S390J9CALLSNIPPET_INCL23#define TR_S390J9CALLSNIPPET_INCL2425#include "z/codegen/CallSnippet.hpp"26#include "z/codegen/ConstantDataSnippet.hpp"27#include "z/codegen/S390Instruction.hpp"2829class TR_J2IThunk;30namespace TR { class CodeGenerator; }31namespace TR { class LabelSymbol; }32namespace TR { class Node; }3334namespace TR {3536class S390J9CallSnippet : public TR::S390CallSnippet37{38public:3940S390J9CallSnippet(41TR::CodeGenerator *cg,42TR::Node *n,43TR::LabelSymbol *lab,44int32_t s) :45TR::S390CallSnippet(cg, n, lab, s)46{}4748S390J9CallSnippet(49TR::CodeGenerator *cg,50TR::Node *n,51TR::LabelSymbol *lab,52TR::SymbolReference *symRef,53int32_t s) :54TR::S390CallSnippet(cg, n, lab, symRef, s) {}555657static uint8_t *generateVIThunk(TR::Node *callNode, int32_t argSize, TR::CodeGenerator *cg);58static TR_J2IThunk *generateInvokeExactJ2IThunk(TR::Node *callNode, int32_t argSize, char* signature, TR::CodeGenerator *cg);5960TR_RuntimeHelper getInterpretedDispatchHelper(TR::SymbolReference *methodSymRef, TR::DataType type);6162uint8_t *generatePICBinary(uint8_t *cursor, TR::SymbolReference *glueRef);63uint32_t getPICBinaryLength();64virtual uint32_t getLength(int32_t estimatedSnippetStart);6566virtual void print(TR::FILE *pOutFile, TR_Debug *debug);6768virtual uint8_t *emitSnippetBody();69};707172class S390UnresolvedCallSnippet : public TR::S390J9CallSnippet73{7475public:7677S390UnresolvedCallSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s)78: TR::S390J9CallSnippet(cg, c, lab, s)79{80}8182virtual Kind getKind() { return IsUnresolvedCall; }8384virtual uint8_t *emitSnippetBody();8586virtual uint32_t getLength(int32_t estimatedSnippetStart);87};888990class S390VirtualSnippet : public TR::S390J9CallSnippet91{92public:9394S390VirtualSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s)95: TR::S390J9CallSnippet(cg, c, lab, s)96{97}9899virtual Kind getKind() { return IsVirtual; }100101virtual uint8_t *emitSnippetBody();102103virtual uint32_t getLength(int32_t estimatedSnippetStart);104};105106107class S390VirtualUnresolvedSnippet : public TR::S390VirtualSnippet108{109void *thunkAddress;110111public:112113S390VirtualUnresolvedSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s)114: TR::S390VirtualSnippet(cg, c, lab, s), thunkAddress(NULL)115{116}117118S390VirtualUnresolvedSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, void *thunkPtr)119: TR::S390VirtualSnippet(cg, c, lab, s), thunkAddress(thunkPtr)120{121}122123virtual Kind getKind() { return IsVirtualUnresolved; }124125virtual uint8_t *emitSnippetBody();126127virtual uint32_t getLength(int32_t estimatedSnippetStart);128void* getJ2IThunkAddress() { return thunkAddress; }129130TR::Instruction *patchVftInstruction;131TR::Instruction *indirectCallInstruction; // the BASR in the virtual dispatch sequence132133TR::Instruction *setPatchVftInstruction(TR::Instruction *i) {return patchVftInstruction=i;}134TR::Instruction *getPatchVftInstruction() {return patchVftInstruction;}135136TR::Instruction *setIndirectCallInstruction(TR::Instruction *i) {return indirectCallInstruction = i;}137TR::Instruction *getIndirectCallInstruction() {return indirectCallInstruction;}138};139140class J9S390InterfaceCallDataSnippet : public TR::S390ConstantDataSnippet141{142TR::Instruction * _firstCLFI;143uint8_t _numInterfaceCallCacheSlots;144uint8_t* _codeRA;145void *_thunkAddress;146bool _useCLFIandBRCL;147148public:149J9S390InterfaceCallDataSnippet(TR::CodeGenerator *,150TR::Node *,151uint8_t,152void *,153bool useCLFIandBRCL = false);154155virtual Kind getKind() { return IsInterfaceCallData; }156virtual uint8_t *emitSnippetBody();157virtual uint32_t getLength(int32_t estimatedSnippetStart);158159int8_t getNumInterfaceCallCacheSlots() {return _numInterfaceCallCacheSlots;}160161void setUseCLFIandBRCL(bool useCLFIandBRCL) {_useCLFIandBRCL = useCLFIandBRCL;}162bool isUseCLFIandBRCL() {return _useCLFIandBRCL;}163164void setFirstCLFI(TR::Instruction* firstCLFI) { _firstCLFI = firstCLFI; }165TR::Instruction* getFirstCLFI() { return _firstCLFI;}166167uint8_t* getCodeRA() { return _codeRA;}168uint8_t* setCodeRA(uint8_t *codeRA)169{170return _codeRA = codeRA;171}172173virtual uint32_t getCallReturnAddressOffset();174virtual uint32_t getSingleDynamicSlotOffset();175virtual uint32_t getLastCachedSlotFieldOffset();176virtual uint32_t getFirstSlotFieldOffset();177virtual uint32_t getLastSlotFieldOffset();178virtual uint32_t getFirstSlotOffset();179virtual uint32_t getLastSlotOffset();180};181182class S390JNICallDataSnippet : public TR::S390ConstantDataSnippet183{184/** Base register for this snippet */185TR::Register * _baseRegister;186187//for JNI Callout frame188uintptr_t _ramMethod;189uintptr_t _JNICallOutFrameFlags;190TR::LabelSymbol * _returnFromJNICallLabel; //for savedCP slot191uintptr_t _savedPC; // This is unused, and hence zero192uintptr_t _tagBits;193194// VMThread setup195uintptr_t _pc;196uintptr_t _literals;197uintptr_t _jitStackFrameFlags;198199//for releaseVMaccess200uintptr_t _constReleaseVMAccessMask;201uintptr_t _constReleaseVMAccessOutOfLineMask;202203/** For CallNativeFunction */204uintptr_t _targetAddress;205206207public:208209S390JNICallDataSnippet(TR::CodeGenerator *,210TR::Node *);211212virtual Kind getKind() { return IsJNICallData; }213virtual uint8_t *emitSnippetBody();214virtual void print(TR::FILE *, TR_Debug*);215void setBaseRegister(TR::Register * aValue){ _baseRegister = aValue; }216TR::Register * getBaseRegister() { return _baseRegister; }217218void setRAMMethod(uintptr_t aValue){ _ramMethod = aValue; }219void setJNICallOutFrameFlags(uintptr_t aValue){ _JNICallOutFrameFlags = aValue; }220void setReturnFromJNICall( TR::LabelSymbol * aValue){ _returnFromJNICallLabel = aValue; }221void setSavedPC(uintptr_t aValue){ _savedPC = aValue; }222void setTagBits(uintptr_t aValue){ _tagBits = aValue; }223224void setPC(uintptr_t aValue){ _pc = aValue; }225void setLiterals(uintptr_t aValue){ _literals = aValue; }226void setJitStackFrameFlags(uintptr_t aValue){ _jitStackFrameFlags = aValue; }227228void setConstReleaseVMAccessMask(uintptr_t aValue){ _constReleaseVMAccessMask = aValue; }229void setConstReleaseVMAccessOutOfLineMask(uintptr_t aValue){ _constReleaseVMAccessOutOfLineMask = aValue; }230void setTargetAddress(uintptr_t aValue){ _targetAddress = aValue; }231232uint32_t getJNICallOutFrameDataOffset(){ return 0; }233uint32_t getRAMMethodOffset(){ return 0; }234uint32_t getJNICallOutFrameFlagsOffset();235uint32_t getReturnFromJNICallOffset();236uint32_t getSavedPCOffset();237uint32_t getTagBitsOffset();238239uint32_t getPCOffset();240uint32_t getLiteralsOffset();241uint32_t getJitStackFrameFlagsOffset();242243uint32_t getConstReleaseVMAccessMaskOffset();244uint32_t getConstReleaseVMAccessOutOfLineMaskOffset();245246uint32_t getTargetAddressOffset();247248uint32_t getLength(int32_t estimatedSnippetStart);249};250251252class S390InterfaceCallSnippet : public TR::S390VirtualSnippet253{254TR::J9S390InterfaceCallDataSnippet * _dataSnippet;255int8_t _numInterfaceCallCacheSlots;256bool _useCLFIandBRCL;257258public:259260S390InterfaceCallSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, int8_t n, void *thunkPtr, bool useCLFIandBRCL = false);261262virtual Kind getKind() { return IsInterfaceCall; }263int8_t getNumInterfaceCallCacheSlots() {return _numInterfaceCallCacheSlots;}264void setUseCLFIandBRCL(bool useCLFIandBRCL) {265_useCLFIandBRCL = useCLFIandBRCL;266if (getDataConstantSnippet() != NULL)267{268getDataConstantSnippet()->setUseCLFIandBRCL(useCLFIandBRCL);269}270}271bool isUseCLFIandBRCL() {return _useCLFIandBRCL;}272273TR::J9S390InterfaceCallDataSnippet *getDataConstantSnippet() { return _dataSnippet; }274TR::J9S390InterfaceCallDataSnippet *setDataConstantSnippet(TR::J9S390InterfaceCallDataSnippet *snippet)275{276return _dataSnippet = snippet;277}278279virtual uint32_t getLength(int32_t estimatedSnippetStart);280virtual uint8_t *emitSnippetBody();281282};283}284285#endif286287288