Path: blob/master/runtime/compiler/ilgen/J9IlGeneratorMethodDetails.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 J9_ILGENERATOR_METHOD_DETAILS_INCL23#define J9_ILGENERATOR_METHOD_DETAILS_INCL2425/*26* The following #define and typedef must appear before any #includes in this file27*/28#ifndef J9_ILGENERATOR_METHOD_DETAILS_CONNECTOR29#define J9_ILGENERATOR_METHOD_DETAILS_CONNECTOR30namespace J9 { class IlGeneratorMethodDetails; }31namespace J9 { typedef J9::IlGeneratorMethodDetails IlGeneratorMethodDetailsConnector; }32#endif3334#include "ilgen/OMRIlGeneratorMethodDetails.hpp"3536#include <stdint.h>37#include "control/Options.hpp"38#include "env/IO.hpp"39#include "env/jittypes.h"40#include "infra/Annotations.hpp"4142class J9Class;43class J9Method;44class J9ROMClass;45class J9ROMMethod;46class TR_FrontEnd;47class TR_IlGenerator;48class TR_InlineBlocks;49class TR_J9VMBase;50class TR_ResolvedMethod;51namespace TR { class Compilation; }52namespace TR { class IlGeneratorMethodDetails; }53namespace TR { class ResolvedMethodSymbol; }54namespace TR { class SymbolReferenceTable;}5556namespace J957{58#if defined(J9VM_OPT_JITSERVER)59enum IlGeneratorMethodDetailsType60{61EMPTY = 0,62ORDINARY_METHOD = 1<<0,63DUMP_METHOD = 1<<1,64NEW_INSTANCE_THUNK = 1<<2,65METHOD_IN_PROGRESS = 1<<3,66ARCHETYPE_SPECIMEN = 1<<4,67METHOD_HANDLE_THUNK = 1<<5,68SHAREABLE_THUNK = 1<<6,69CUSTOM_THUNK = 1<<7,70};71#endif /* defined(J9VM_OPT_JITSERVER) */7273class OMR_EXTENSIBLE IlGeneratorMethodDetails : public OMR::IlGeneratorMethodDetailsConnector74{75friend class IlGeneratorMethodDetailsOverrideForReplay;7677public:78IlGeneratorMethodDetails() :79OMR::IlGeneratorMethodDetailsConnector()80{81_method = NULL;82}8384IlGeneratorMethodDetails(J9Method* method) :85OMR::IlGeneratorMethodDetailsConnector(),86_method(method)87{ }8889IlGeneratorMethodDetails(TR_ResolvedMethod *method);9091IlGeneratorMethodDetails(const TR::IlGeneratorMethodDetails & other);9293static TR::IlGeneratorMethodDetails & create(TR::IlGeneratorMethodDetails & target, TR_ResolvedMethod *method);9495static TR::IlGeneratorMethodDetails * clone(TR::IlGeneratorMethodDetails & storage, const TR::IlGeneratorMethodDetails & other);9697#if defined(J9VM_OPT_JITSERVER)98// Constructs a new IlGeneratorMethodDetails object of given type based on an existing TR::IlGeneratorMethodDetails object (other).99// The existing TR::IlGeneratorMethodDetails object (other) is obtained through de-serialization. It is missing the vtable pointer.100// Therefore the new object instance type cannot be determined through the virtual function calls such as other.isOrdinaryMethod(), etc.101static TR::IlGeneratorMethodDetails * clone(TR::IlGeneratorMethodDetails & storage, const TR::IlGeneratorMethodDetails & other, const IlGeneratorMethodDetailsType type);102#endif /* defined(J9VM_OPT_JITSERVER) */103104virtual const char * name() const { return "OrdinaryMethod"; }105106virtual bool isOrdinaryMethod() const { return true; }107virtual bool isJitDumpMethod() const { return false; }108virtual bool isJitDumpAOTMethod() const { return false; }109virtual bool isNewInstanceThunk() const { return false; }110virtual bool isMethodInProgress() const { return false; }111virtual bool isArchetypeSpecimen() const { return false; }112virtual bool isMethodHandleThunk() const { return false; }113virtual bool supportsInvalidation() const { return true; }114115J9Method *getMethod() const { return _method; }116virtual J9Class *getClass() const;117#if defined(J9VM_OPT_JITSERVER)118IlGeneratorMethodDetailsType getType() const;119#endif /* defined(J9VM_OPT_JITSERVER) */120virtual const J9ROMClass *getRomClass() const;121virtual const J9ROMMethod *getRomMethod(TR_J9VMBase *fe);122123124virtual TR_IlGenerator *getIlGenerator(TR::ResolvedMethodSymbol *methodSymbol,125TR_FrontEnd * fe,126TR::Compilation *comp,127TR::SymbolReferenceTable *symRefTab,128bool forceClassLookahead,129TR_InlineBlocks *blocksToInline);130131virtual bool sameAs(TR::IlGeneratorMethodDetails & other, TR_FrontEnd *fe);132133bool sameMethod(TR::IlGeneratorMethodDetails & other);134135void print(TR_FrontEnd *fe, TR::FILE *file);136137virtual void printDetails(TR_FrontEnd *fe, TR::FILE *file);138139protected:140141// All data across subclasses of IlGeneratorMethodDetails MUST be stored in the base class142// (using a union to save space across the hierarchy where possible)143// Primary reason is that an embedded instance of this class is stored in MethodToBeCompiled so that instance144// must be able to transmute itself into any kind of IlGeneratorMethodDetails in place (i.e. via placement new)145146J9Method *_method;147union148{149J9Class *_class;150int32_t _byteCodeIndex;151struct152{153uintptr_t *_handleRef;154uintptr_t *_argRef;155} _methodHandleData;156bool _aotCompile;157} _data;158159/// A cached options object from the original (crashed) compilation thread160TR::Options *_optionsFromOriginalCompile;161};162163// Replay compilation support that must not be used by anyone else because it breaks encapsulation164//165class IlGeneratorMethodDetailsOverrideForReplay166{167public:168169// When replay compilation initializes it needs to redirect the existing170// details object to compile the requested replay method.171//172static void changeMethod(TR::IlGeneratorMethodDetails & details, J9Method *newMethod);173};174175176177178}179180#endif181182183