Path: blob/master/runtime/compiler/optimizer/DynamicLiteralPool.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 DYNAMICLITERALPOOL_INCL23#define DYNAMICLITERALPOOL_INCL2425#include <stddef.h>26#include <stdint.h>27#include "compile/Compilation.hpp"28#include "env/TRMemory.hpp"29#include "env/jittypes.h"30#include "il/Block.hpp"31#include "il/ILOpCodes.hpp"32#include "il/Node.hpp"33#include "infra/Assert.hpp"34#include "infra/List.hpp"35#include "optimizer/Optimization.hpp"36#include "optimizer/OptimizationManager.hpp"373839namespace TR { class SymbolReference; }40namespace TR { class TreeTop; }414243class TR_DynamicLiteralPool : public TR::Optimization44{45public:46TR_DynamicLiteralPool(TR::OptimizationManager *manager);47static TR::Optimization *create(TR::OptimizationManager *manager)48{49return new (manager->allocator()) TR_DynamicLiteralPool(manager);50}5152virtual int32_t perform();53virtual int32_t performOnBlock(TR::Block *);54virtual const char * optDetailString() const throw();5556int32_t process(TR::TreeTop *, TR::TreeTop *);5758TR::SymbolReference * getLitPoolAddressSym()59{60if (_litPoolAddressSym==NULL) initLiteralPoolBase();61return _litPoolAddressSym;62}63TR::Node * getAloadFromCurrentBlock(TR::Node *parent)64{65if (_aloadFromCurrentBlock==NULL)66{67setAloadFromCurrentBlock(TR::Node::createWithSymRef(parent, TR::aload, 0, getLitPoolAddressSym()));68dumpOptDetails(comp(), "New aload needed, it is: %p!\n", _aloadFromCurrentBlock);69}70else71{72dumpOptDetails(comp(), "Can re-use aload %p!\n",_aloadFromCurrentBlock);73}74return _aloadFromCurrentBlock;75}76void setAloadFromCurrentBlock(TR::Node *aloadNode) {_aloadFromCurrentBlock = aloadNode;}7778TR::Node *getVMThreadAloadFromCurrentBlock(TR::Node *parent);79void setVMThreadAloadFromCurrentBlock(TR::Node *aloadNode) {_vmThreadAloadFromCurrentBlock = aloadNode;}8081int32_t getNumChild() {return _numChild;}82void setNumChild(int32_t n) {_numChild=n;}8384private:8586TR::SymbolReference * _litPoolAddressSym;87TR::Block * _currentBlock;88TR::Node * _aloadFromCurrentBlock;89TR::Node * _vmThreadAloadFromCurrentBlock;90bool _changed;91int32_t _numChild;9293void initLiteralPoolBase();94bool processBlock(TR::Block *block, vcount_t visitCount);95bool visitTreeTop(TR::TreeTop *, TR::Node *grandParent, TR::Node *parent, TR::Node *node, vcount_t visitCount);96bool transformLitPoolConst(TR::Node *grandParent, TR::Node *parent, TR::Node *child);97bool transformConstToIndirectLoad(TR::Node *parent, TR::Node *child);98bool transformStaticSymRefToIndirectLoad(TR::TreeTop *, TR::Node *parent, TR::Node * & child);99bool transformNeeded(TR::Node *grandParent, TR::Node *parent, TR::Node *child);100bool addNewAloadChild(TR::Node *node);101bool handleNodeUsingSystemStack(TR::TreeTop *, TR::Node *parent, TR::Node *node, vcount_t visitCount);102bool handleNodeUsingVMThread(TR::TreeTop *, TR::Node *parent, TR::Node *node, vcount_t visitCount);103};104105#endif106107108109