Path: blob/master/runtime/compiler/optimizer/InterProceduralAnalyzer.hpp
6000 views
/*******************************************************************************1* Copyright (c) 2000, 2019 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 IPA_h23#define IPA_h2425#include <stdint.h>26#include "env/TRMemory.hpp"27#include "il/Node.hpp"28#include "infra/Link.hpp"29#include "infra/List.hpp"3031class TR_ClassExtendCheck;32class TR_ClassLoadCheck;33class TR_FrontEnd;34class TR_OpaqueClassBlock;35class TR_OpaqueMethodBlock;36class TR_ResolvedMethod;37namespace OMR { class RuntimeAssumption; }38namespace TR { class ResolvedMethodSymbol; }39namespace TR { class SymbolReference; }40namespace TR { class SymbolReferenceTable; }41namespace TR { class Compilation; }4243namespace TR {4445class GlobalSymbol : public TR_Link<TR::GlobalSymbol>46{47public:48GlobalSymbol(TR::SymbolReference *symRef) : _symRef(symRef) { }49TR::SymbolReference *_symRef;50};5152struct PriorPeekInfo53{54TR_ResolvedMethod *_method;55TR_LinkHead<TR_ClassLoadCheck> _classesThatShouldNotBeLoaded;56TR_LinkHead<TR_ClassExtendCheck> _classesThatShouldNotBeNewlyExtended;57TR_LinkHead<TR::GlobalSymbol> _globalsWritten;58};5960class InterProceduralAnalyzer61{62public:63TR_ALLOC(TR_Memory::InterProceduralAnalyzer)6465InterProceduralAnalyzer(TR::Compilation *, bool trace);6667int32_t perform();6869TR_FrontEnd * fe() { return _fe; }70TR::Compilation * comp() { return _compilation; }7172TR_Memory * trMemory() { return _trMemory; }73TR_StackMemory trStackMemory() { return _trMemory; }74TR_HeapMemory trHeapMemory() { return _trMemory; }7576List<OMR::RuntimeAssumption> *analyzeCall(TR::Node *);77List<OMR::RuntimeAssumption> *analyzeCallGraph(TR::Node *, bool *);78List<OMR::RuntimeAssumption> *analyzeMethod(TR::Node *, TR_ResolvedMethod *, bool *);7980bool isOnPeekingStack(TR_ResolvedMethod *method);81bool capableOfPeekingVirtualCalls();82bool trace() { return _trace; }8384bool addClassThatShouldNotBeLoaded(char *name, int32_t len);85bool addClassThatShouldNotBeNewlyExtended(TR_OpaqueClassBlock *clazz);86bool addSingleClassThatShouldNotBeNewlyExtended(TR_OpaqueClassBlock *clazz);87bool addMethodThatShouldNotBeNewlyOverridden(TR_OpaqueMethodBlock *method);88bool addWrittenGlobal(TR::SymbolReference *symRef);89uint32_t hash(void * h, uint32_t size);9091virtual bool alreadyPeekedMethod(TR_ResolvedMethod *method, bool *success, TR::PriorPeekInfo **);92virtual bool analyzeNode(TR::Node *node, vcount_t visitCount, bool *success) = 0;9394protected:95//96// data97//98int32_t _sniffDepth, _maxSniffDepth;99int32_t _totalPeekedBytecodeSize;100int32_t _maxPeekedBytecodeSize;101bool _maxSniffDepthExceeded;102bool _trace;103TR_OpaqueClassBlock *_classPointer;104TR::Compilation *_compilation;105TR_Memory * _trMemory;106TR::SymbolReferenceTable *_symRefTab;107TR::SymbolReferenceTable *_currentPeekingSymRefTab;108TR_FrontEnd *_fe;109TR::ResolvedMethodSymbol *_currentMethodSymbol;110List<TR::PriorPeekInfo> _successfullyPeekedMethods;111List<TR_ResolvedMethod> _unsuccessfullyPeekedMethods;112TR_ScratchList<TR_ClassLoadCheck> _classesThatShouldNotBeLoadedInCurrentPeek;113TR_ScratchList<TR_ClassExtendCheck> _classesThatShouldNotBeNewlyExtendedInCurrentPeek;114TR_ScratchList<TR_ClassExtendCheck> * _classesThatShouldNotBeNewlyExtendedInCurrentPeekHT;115TR_ScratchList<TR::GlobalSymbol> _globalsWrittenInCurrentPeek;116ListElement<TR_ClassLoadCheck> *_prevClc;117ListElement<TR_ClassExtendCheck> *_prevCec;118ListElement<TR::GlobalSymbol> *_prevSymRef;119120public:121TR_LinkHead<TR_ClassLoadCheck> _classesThatShouldNotBeLoaded;122TR_LinkHead<TR_ClassExtendCheck> _classesThatShouldNotBeNewlyExtended;123TR_LinkHead<TR_ClassExtendCheck> *_classesThatShouldNotBeNewlyExtendedHT;124TR_LinkHead<TR::GlobalSymbol> _globalsWritten;125};126127}128129#endif130131132