Path: blob/master/runtime/compiler/aarch64/codegen/CallSnippet.hpp
6004 views
/*******************************************************************************1* Copyright (c) 2019, 2021 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 ARM64CALLSNIPPET_INCL23#define ARM64CALLSNIPPET_INCL2425#include "codegen/Snippet.hpp"26#include "env/VMJ9.h"2728namespace TR { class CodeGenerator; }29class TR_J2IThunk;3031extern void arm64CodeSync(uint8_t *codePointer, uint32_t codeSize);3233namespace TR {3435class ARM64CallSnippet : public TR::Snippet36{37uint8_t *callRA;38int32_t sizeOfArguments;3940public:4142ARM64CallSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s)43: TR::Snippet(cg, c, lab, false), sizeOfArguments(s), callRA(0)44{45}4647virtual Kind getKind() { return IsCall; }4849virtual uint8_t *emitSnippetBody();5051virtual uint32_t getLength(int32_t estimatedSnippetStart);5253int32_t getSizeOfArguments() {return sizeOfArguments;}54int32_t setSizeOfArguments(int32_t s) {return (sizeOfArguments = s);}5556TR_RuntimeHelper getHelper();5758uint8_t *getCallRA() {return callRA;}59uint8_t *setCallRA(uint8_t *ra) {return (callRA=ra);}6061static uint8_t *generateVIThunk(TR::Node *callNode, int32_t argSize, TR::CodeGenerator *cg);62static TR_J2IThunk *generateInvokeExactJ2IThunk(TR::Node *callNode, int32_t argSize, TR::CodeGenerator *cg, char *signature);63};6465class ARM64UnresolvedCallSnippet : public TR::ARM64CallSnippet66{6768public:6970ARM64UnresolvedCallSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s)71: TR::ARM64CallSnippet(cg, c, lab, s)72{73}7475virtual Kind getKind() { return IsUnresolvedCall; }7677virtual uint8_t *emitSnippetBody();7879virtual uint32_t getLength(int32_t estimatedSnippetStart);80};8182class ARM64VirtualSnippet : public TR::Snippet83{84TR::LabelSymbol *returnLabel;85int32_t sizeOfArguments;8687public:8889ARM64VirtualSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, TR::LabelSymbol *retl)90: TR::Snippet(cg, c, lab, true), sizeOfArguments(s), returnLabel(retl)91{92}9394virtual Kind getKind() { return IsVirtual; }9596virtual uint8_t *emitSnippetBody();9798virtual uint32_t getLength(int32_t estimatedSnippetStart);99100int32_t getSizeOfArguments() {return sizeOfArguments;}101int32_t setSizeOfArguments(int32_t s) {return (sizeOfArguments = s);}102103TR::LabelSymbol *getReturnLabel() {return returnLabel;}104TR::LabelSymbol *setReturnLabel(TR::LabelSymbol *rl) {return (returnLabel=rl);}105};106107class ARM64VirtualUnresolvedSnippet : public TR::ARM64VirtualSnippet108{109uint8_t *thunkAddress;110public:111112ARM64VirtualUnresolvedSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, TR::LabelSymbol *retl)113: TR::ARM64VirtualSnippet(cg, c, lab, s, retl), thunkAddress(NULL)114{115}116117ARM64VirtualUnresolvedSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, TR::LabelSymbol *retl, uint8_t *thunkPtr)118: TR::ARM64VirtualSnippet(cg, c, lab, s, retl), thunkAddress(thunkPtr)119{120}121122virtual Kind getKind() { return IsVirtualUnresolved; }123124virtual uint8_t *emitSnippetBody();125126virtual uint32_t getLength(int32_t estimatedSnippetStart);127};128129class ARM64InterfaceCallSnippet : public TR::ARM64VirtualSnippet130{131uint8_t *thunkAddress;132TR::LabelSymbol *_firstClassCacheSlotLabel;133TR::LabelSymbol *_firstBranchAddressCacheSlotLabel;134TR::LabelSymbol *_secondClassCacheSlotLabel;135TR::LabelSymbol *_secondBranchAddressCacheSlotLabel;136public:137138ARM64InterfaceCallSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, TR::LabelSymbol *retl,139TR::LabelSymbol *firstClassCacheSlotLabel, TR::LabelSymbol *firstBranchAddressCacheSlotLabel,140TR::LabelSymbol *secondClassCacheSlotLabel, TR::LabelSymbol *secondBranchAddressCacheSlotLabel)141: TR::ARM64VirtualSnippet(cg, c, lab, s, retl), thunkAddress(NULL),142_firstClassCacheSlotLabel(firstClassCacheSlotLabel), _firstBranchAddressCacheSlotLabel(firstBranchAddressCacheSlotLabel),143_secondClassCacheSlotLabel(secondClassCacheSlotLabel), _secondBranchAddressCacheSlotLabel(secondBranchAddressCacheSlotLabel)144{145}146147ARM64InterfaceCallSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, TR::LabelSymbol *retl,148TR::LabelSymbol *firstClassCacheSlotLabel, TR::LabelSymbol *firstBranchAddressCacheSlotLabel,149TR::LabelSymbol *secondClassCacheSlotLabel, TR::LabelSymbol *secondBranchAddressCacheSlotLabel, uint8_t *thunkPtr)150: TR::ARM64VirtualSnippet(cg, c, lab, s, retl), thunkAddress(thunkPtr),151_firstClassCacheSlotLabel(firstClassCacheSlotLabel), _firstBranchAddressCacheSlotLabel(firstBranchAddressCacheSlotLabel),152_secondClassCacheSlotLabel(secondClassCacheSlotLabel), _secondBranchAddressCacheSlotLabel(secondBranchAddressCacheSlotLabel)153{154}155156TR::LabelSymbol *getFirstClassCacheSlotLabel() { return _firstClassCacheSlotLabel; }157TR::LabelSymbol *getFirstBranchAddressCacheSlotLabel() { return _firstBranchAddressCacheSlotLabel; }158TR::LabelSymbol *getSecondClassCacheSlotLabel() { return _secondClassCacheSlotLabel; }159TR::LabelSymbol *getSecondBranchAddressCacheSlotLabel() { return _secondBranchAddressCacheSlotLabel; }160virtual Kind getKind() { return IsInterfaceCall; }161162virtual uint8_t *emitSnippetBody();163164virtual uint32_t getLength(int32_t estimatedSnippetStart);165};166167}168169#endif170171172