Path: blob/master/runtime/compiler/ilgen/IlGeneratorMethodDetails.hpp
6000 views
/*******************************************************************************1* Copyright (c) 2000, 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 TR_ILGENERATOR_METHOD_DETAILS_INCL23#define TR_ILGENERATOR_METHOD_DETAILS_INCL2425#include "ilgen/J9IlGeneratorMethodDetails.hpp"2627#include <stdint.h>28#include "env/IO.hpp"29#include "env/jittypes.h"30#include "infra/Annotations.hpp"3132class TR_InlineBlocks;3334namespace TR35{3637class OMR_EXTENSIBLE IlGeneratorMethodDetails : public J9::IlGeneratorMethodDetailsConnector38{3940public:4142IlGeneratorMethodDetails() :43J9::IlGeneratorMethodDetailsConnector() {}4445IlGeneratorMethodDetails(J9Method* method) :46J9::IlGeneratorMethodDetailsConnector(method) {}4748IlGeneratorMethodDetails(TR_ResolvedMethod *method) :49J9::IlGeneratorMethodDetailsConnector(method) {}5051IlGeneratorMethodDetails(const TR::IlGeneratorMethodDetails & other) :52J9::IlGeneratorMethodDetailsConnector(other) {}5354};5556}575859namespace J960{6162class JitDumpMethodDetails : public TR::IlGeneratorMethodDetails63{64// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails6566public:67JitDumpMethodDetails(J9Method* method, TR::Options* optionsFromOriginalCompile, bool aotCompile)68: TR::IlGeneratorMethodDetails(method)69{70_optionsFromOriginalCompile = optionsFromOriginalCompile;71_data._aotCompile = aotCompile;72}7374JitDumpMethodDetails(const JitDumpMethodDetails& other)75: TR::IlGeneratorMethodDetails(other.getMethod())76{77_optionsFromOriginalCompile = other._optionsFromOriginalCompile;78_data._aotCompile = other._data._aotCompile;79}8081virtual const char * name() const { return "JitDumpMethod"; }8283virtual bool isOrdinaryMethod() const { return false; }84virtual bool isJitDumpMethod() const { return true; }85virtual bool isJitDumpAOTMethod() const { return _data._aotCompile; }868788virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)89{90return other.isJitDumpMethod() && sameMethod(other);91}9293virtual bool supportsInvalidation() { return false; }9495/**96* \brief97* Gets the options used in the original compilation which we are trying to reproduce.98*99* \returns100* The options from the original compile if it exists; \c NULL otherwise.101*/102TR::Options* getOptionsFromOriginalCompile() const103{104return _optionsFromOriginalCompile;105}106};107108109class MethodInProgressDetails : public TR::IlGeneratorMethodDetails110{111// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails112113public:114MethodInProgressDetails(J9Method* method, int32_t byteCodeIndex) :115TR::IlGeneratorMethodDetails(method)116{117_data._byteCodeIndex = byteCodeIndex;118}119MethodInProgressDetails(TR_ResolvedMethod *method, int32_t byteCodeIndex) :120TR::IlGeneratorMethodDetails(method)121{122_data._byteCodeIndex = byteCodeIndex;123}124MethodInProgressDetails(const MethodInProgressDetails & other) :125TR::IlGeneratorMethodDetails(other.getMethod())126{127_data._byteCodeIndex = other.getByteCodeIndex();128}129130virtual const char * name() const { return "MethodInProgress"; }131132virtual bool isOrdinaryMethod() const { return false; }133virtual bool isMethodInProgress() const { return true; }134virtual bool supportsInvalidation() const { return false; }135136int32_t getByteCodeIndex() const { return _data._byteCodeIndex; }137138virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)139{140return other.isMethodInProgress() &&141isSimilarEnough(static_cast<MethodInProgressDetails &>(other), fe);142}143144virtual void printDetails(TR_FrontEnd *fe, TR::FILE *file);145146private:147bool isSimilarEnough(MethodInProgressDetails & other, TR_FrontEnd *fe)148{149return sameMethod(other);150}151152bool sameAsMethodInProgress(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)153{154return TR::IlGeneratorMethodDetails::sameAs(other, fe) &&155static_cast<MethodInProgressDetails &>(other).getByteCodeIndex() == getByteCodeIndex();156}157158};159160161class NewInstanceThunkDetails : public TR::IlGeneratorMethodDetails162{163// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails164165public:166NewInstanceThunkDetails(J9Method* method, J9Class *clazz) :167TR::IlGeneratorMethodDetails(method)168{169_data._class = clazz;170}171NewInstanceThunkDetails(TR_ResolvedMethod *method, J9Class *clazz) :172TR::IlGeneratorMethodDetails(method)173{174_data._class = clazz;175}176NewInstanceThunkDetails(const NewInstanceThunkDetails & other) :177TR::IlGeneratorMethodDetails(other.getMethod())178{179_data._class = other.classNeedingThunk();180}181182virtual const char * name() const { return "NewInstanceThunk"; }183184virtual bool isOrdinaryMethod() const { return false; }185virtual bool isNewInstanceThunk() const { return true; }186virtual bool supportsInvalidation() const { return false; }187188J9Class *classNeedingThunk() const { return _data._class; }189190virtual J9Class *getClass() const { return classNeedingThunk(); }191192bool isThunkFor(J9Class *clazz) const { return clazz == classNeedingThunk(); }193194virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)195{196return other.isNewInstanceThunk() &&197sameMethod(other) &&198static_cast<NewInstanceThunkDetails &>(other).classNeedingThunk() == classNeedingThunk();199}200201virtual void printDetails(TR_FrontEnd *fe, TR::FILE *file);202};203204205// This class is currently not instantiated directly206class ArchetypeSpecimenDetails : public TR::IlGeneratorMethodDetails207{208// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails209210public:211ArchetypeSpecimenDetails(J9Method* method) : TR::IlGeneratorMethodDetails(method) { }212ArchetypeSpecimenDetails(TR_ResolvedMethod *method) : TR::IlGeneratorMethodDetails(method) { }213ArchetypeSpecimenDetails(const ArchetypeSpecimenDetails &other) : TR::IlGeneratorMethodDetails(other) { }214215virtual const char * name() const { return "ArchetypeSpecimen"; }216217virtual bool isOrdinaryMethod() const { return false; }218virtual bool isArchetypeSpecimen() const { return true; }219220virtual TR_IlGenerator *getIlGenerator(TR::ResolvedMethodSymbol *methodSymbol,221TR_FrontEnd * fe,222TR::Compilation *comp,223TR::SymbolReferenceTable *symRefTab,224bool forceClassLookahead,225TR_InlineBlocks *blocksToInline);226227virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)228{229return other.isArchetypeSpecimen() && sameMethod(other);230}231};232233234// This class is currently not instantiated directly235class MethodHandleThunkDetails : public ArchetypeSpecimenDetails236{237// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails238239public:240MethodHandleThunkDetails(J9Method* method, uintptr_t *handleRef, uintptr_t *argRef) :241ArchetypeSpecimenDetails(method)242{243_data._methodHandleData._handleRef = handleRef;244_data._methodHandleData._argRef = argRef;245}246MethodHandleThunkDetails(TR_ResolvedMethod *method, uintptr_t *handleRef, uintptr_t *argRef) :247ArchetypeSpecimenDetails(method)248{249_data._methodHandleData._handleRef = handleRef;250_data._methodHandleData._argRef = argRef;251}252MethodHandleThunkDetails(const MethodHandleThunkDetails &other) :253ArchetypeSpecimenDetails(other)254{255_data._methodHandleData._handleRef = other.getHandleRef();256_data._methodHandleData._argRef = other.getArgRef();257}258259virtual const char * name() const { return "MethodHandleThunk"; }260261virtual bool isMethodHandleThunk() const { return true; }262263uintptr_t *getHandleRef() const { return _data._methodHandleData._handleRef; }264uintptr_t *getArgRef() const { return _data._methodHandleData._argRef; }265266virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe)267{268return other.isMethodHandleThunk() &&269sameMethod(other) &&270isSameThunk(static_cast<MethodHandleThunkDetails &>(other),271(TR_J9VMBase *)(fe));272}273274virtual bool supportsInvalidation() const { return false; }275276virtual bool isShareable() const { return false; }277278virtual bool isCustom() const { return false; }279280virtual void printDetails(TR_FrontEnd *fe, TR::FILE *file);281282private:283virtual bool isSameThunk(MethodHandleThunkDetails & otherThunk, TR_J9VMBase *fe);284};285286287class ShareableInvokeExactThunkDetails : public MethodHandleThunkDetails288{289// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails290291public:292ShareableInvokeExactThunkDetails(J9Method* method, uintptr_t *handleRef, uintptr_t *argRef) :293MethodHandleThunkDetails(method, handleRef, argRef) { }294ShareableInvokeExactThunkDetails(TR_ResolvedMethod *method, uintptr_t *handleRef, uintptr_t *argRef) :295MethodHandleThunkDetails(method, handleRef, argRef) { }296ShareableInvokeExactThunkDetails(const ShareableInvokeExactThunkDetails & other) :297MethodHandleThunkDetails(other.getMethod(), other.getHandleRef(), other.getArgRef()) { }298299virtual const char * name() const { return "SharableInvokeExactThunk"; }300301virtual bool isShareable() const { return true; }302303private:304virtual bool isSameThunk(MethodHandleThunkDetails & otherThunk, TR_J9VMBase *fe);305};306307308class CustomInvokeExactThunkDetails : public MethodHandleThunkDetails309{310// Objects cannot hold data of its own: must store in the _data union in TR::IlGeneratorMethodDetails311312public:313CustomInvokeExactThunkDetails(J9Method* method, uintptr_t *handleRef, uintptr_t *argRef) :314MethodHandleThunkDetails(method, handleRef, argRef) { }315CustomInvokeExactThunkDetails(TR_ResolvedMethod *method, uintptr_t *handleRef, uintptr_t *argRef) :316MethodHandleThunkDetails(method, handleRef, argRef) { }317CustomInvokeExactThunkDetails(const CustomInvokeExactThunkDetails & other) :318MethodHandleThunkDetails(other.getMethod(), other.getHandleRef(), other.getArgRef()) { }319320virtual const char * name() const { return "CustomInvokeExactThunk"; }321322virtual bool isCustom() const { return true; }323324private:325virtual bool isSameThunk(MethodHandleThunkDetails & otherThunk, TR_J9VMBase *fe);326};327328329}330331#endif332333334