Path: blob/master/runtime/compiler/codegen/J9CodeGenPhase.cpp
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#if defined(J9ZOS390)23//On zOS XLC linker can't handle files with same name at link time24//This workaround with pragma is needed. What this does is essentially25//give a different name to the codesection (csect) for this file. So it26//doesn't conflict with another file with same name.2728#pragma csect(CODE,"TRJ9CGPhase#C")29#pragma csect(STATIC,"TRJ9CGPhase#S")30#pragma csect(TEST,"TRJ9CGPhase#T")31#endif3233#include "codegen/CodeGenPhase.hpp"34#include "codegen/CodeGenerator.hpp"35#include "compile/Compilation.hpp"36#include "compile/Method.hpp"37#include "il/Block.hpp"38#include "optimizer/SequentialStoreSimplifier.hpp"39#include "env/VMJ9.h"4041#ifdef TR_TARGET_S39042#include "codegen/InMemoryLoadStoreMarking.hpp"43#endif4445// to decide if asyncchecks should be inserted at method exits46#define BYTECODESIZE_THRESHOLD_FOR_ASYNCCHECKS 3004748void49J9::CodeGenPhase::reportPhase(PhaseValue phase)50{51TR_J9VMBase *fej9 = (TR_J9VMBase *)(_cg->comp()->fe());52fej9->reportCodeGeneratorPhase(phase);53_currentPhase = phase;54}5556int57J9::CodeGenPhase::getNumPhases()58{59return static_cast<int>(TR::CodeGenPhase::LastJ9Phase);60}6162void63J9::CodeGenPhase::performFixUpProfiledInterfaceGuardTestPhase(TR::CodeGenerator *cg, TR::CodeGenPhase *phase)64{65cg->fixUpProfiledInterfaceGuardTest();66}6768void69J9::CodeGenPhase::performAllocateLinkageRegistersPhase(TR::CodeGenerator * cg, TR::CodeGenPhase * phase)70{71TR::Compilation * comp = cg->comp();72if (!comp->getOption(TR_DisableLinkageRegisterAllocation))73cg->allocateLinkageRegisters();74}757677void78J9::CodeGenPhase::performPopulateOSRBufferPhase(TR::CodeGenerator * cg, TR::CodeGenPhase * phase)79{80phase->reportPhase(PopulateOSRBufferPhase);81cg->populateOSRBuffer();82}838485void86J9::CodeGenPhase::performMoveUpArrayLengthStoresPhase(TR::CodeGenerator * cg, TR::CodeGenPhase * phase)87{88phase->reportPhase(MoveUpArrayLengthStoresPhase);89cg->moveUpArrayLengthStores(cg->comp()->getStartBlock()->getEntry());90}9192void93J9::CodeGenPhase::performInsertEpilogueYieldPointsPhase(TR::CodeGenerator * cg, TR::CodeGenPhase * phase)94{95TR::Compilation * comp = cg->comp();96phase->reportPhase(InsertEpilogueYieldPointsPhase);9798// insert asyncchecks for non-loopy large methods that contain no calls99// (important for sunflow where the second hottest method is one such)100//101// FIXME: the value for methodContainsCalls is not computed until102// after the main tree traversal (below). However, we can't move103// this code after the loop because the inserted yield points need104// to be lowered by the same loop.105//106if ((comp->getCurrentMethod()->maxBytecodeIndex() >= BYTECODESIZE_THRESHOLD_FOR_ASYNCCHECKS) &&107!comp->mayHaveLoops() &&108comp->getCurrentMethod()->convertToMethod()->methodType() == TR::Method::J9 && // FIXME: enable for ruby and python109comp->getOSRMode() != TR::involuntaryOSR)110{111cg->insertEpilogueYieldPoints();112}113}114115void116J9::CodeGenPhase::performCompressedReferenceRematerializationPhase(TR::CodeGenerator * cg, TR::CodeGenPhase *)117{118cg->compressedReferenceRematerialization();119}120121const char *122J9::CodeGenPhase::getName()123{124return TR::CodeGenPhase::getName(_currentPhase);125}126127const char *128J9::CodeGenPhase::getName(TR::CodeGenPhase::PhaseValue phase)129{130switch (phase)131{132case AllocateLinkageRegisters:133return "AllocateLinkageRegisters";134case PopulateOSRBufferPhase:135return "PopulateOSRBuffer";136case MoveUpArrayLengthStoresPhase:137return "MoveUpArrayLengthStores";138case InsertEpilogueYieldPointsPhase:139return "InsertEpilogueYieldPoints";140case CompressedReferenceRematerializationPhase:141return "CompressedReferenceRematerialization";142case IdentifyUnneededByteConvsPhase:143return "IdentifyUnneededByteConvsPhase";144case FixUpProfiledInterfaceGuardTest:145return "FixUpProfiledInterfaceGuardTest";146default:147return OMR::CodeGenPhaseConnector::getName(phase);148}149}150151void152J9::CodeGenPhase::performIdentifyUnneededByteConvsPhase(TR::CodeGenerator * cg, TR::CodeGenPhase * phase)153{154cg->identifyUnneededByteConvNodes();155}156157158159160