Path: blob/master/runtime/compiler/codegen/PrivateLinkage.hpp
6000 views
/*******************************************************************************1* Copyright (c) 2000, 2020 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_PRIVATELINKAGE_INCL23#define J9_PRIVATELINKAGE_INCL2425#include "codegen/Linkage.hpp"26#include "env/jittypes.h"27#include "compile/CompilationTypes.hpp"28#include "infra/Assert.hpp"2930namespace TR { class CodeGenerator; }3132namespace J933{3435class PrivateLinkage : public TR::Linkage36{37public:3839PrivateLinkage(TR::CodeGenerator *cg) :40TR::Linkage(cg)41{42}4344/**45* @class LinkageInfo46*47* @brief Helper class for encoding and decoding the linkage info word that is48* embedded in the code cache prior to the interpreter entry point in each49* compiled method body.50*51* @details52* Implementation restrictions:53* * this is a non-instantiable abstract class54* * this class cannot have any virtual methods55*/56class LinkageInfo57{58public:59static LinkageInfo *get(void *startPC) { return reinterpret_cast<LinkageInfo *>(((uint32_t*)startPC)-1); }6061void setCountingMethodBody() { _word |= CountingPrologue; }62void setSamplingMethodBody() { _word |= SamplingPrologue; }63void setHasBeenRecompiled()64{65TR_ASSERT((_word & HasFailedRecompilation)==0, "Cannot setHasBeenRecompiled because method has failed recompilation");66_word |= HasBeenRecompiled;67}6869void setHasFailedRecompilation()70{71TR_ASSERT((_word & HasBeenRecompiled) == 0, "Cannot setHasFailedRecompilation because method has been recompiled");72_word |= HasFailedRecompilation;73}7475void setIsBeingRecompiled() { _word |= IsBeingRecompiled; }76void resetIsBeingRecompiled() { _word &= ~IsBeingRecompiled; }7778bool isCountingMethodBody() { return (_word & CountingPrologue) != 0; }79bool isSamplingMethodBody() { return (_word & SamplingPrologue) != 0; }80bool isRecompMethodBody() { return (_word & (SamplingPrologue | CountingPrologue)) != 0; }81bool hasBeenRecompiled() { return (_word & HasBeenRecompiled) != 0; }82bool hasFailedRecompilation() { return (_word & HasFailedRecompilation) != 0; }83bool recompilationAttempted() { return hasBeenRecompiled() || hasFailedRecompilation(); }84bool isBeingCompiled() { return (_word & IsBeingRecompiled) != 0; }8586inline uint16_t getReservedWord() { return (_word & ReservedMask) >> 16; }87inline void setReservedWord(uint16_t w) { _word |= ((w << 16) & ReservedMask); }8889inline TR_ReturnInfo getReturnInfo() { return (TR_ReturnInfo)(_word & ReturnInfoMask); }90inline void setReturnInfo(TR_ReturnInfo w) { _word |= (w & ReturnInfoMask); }9192inline uint32_t getWord() { return _word; }9394int32_t getJitEntryOffset()95{96#if defined(TR_TARGET_X86) && defined(TR_TARGET_32BIT)97return 0;98#else99return getReservedWord();100#endif101}102103enum104{105ReturnInfoMask = 0x0000000F, // bottom 4 bits106// The VM depends on these four bits - word to the wise: don't mess107108SamplingPrologue = 0x00000010,109CountingPrologue = 0x00000020,110// NOTE: flags have to be set under the compilation monitor or during compilation process111HasBeenRecompiled = 0x00000040,112HasFailedRecompilation = 0x00000100,113IsBeingRecompiled = 0x00000200,114115// RESERVED:116// non-ia32: 0xffff0000 <---- jitEntryOffset117// ia32: 0xffff0000 <---- Recomp/FSD save area118119ReservedMask = 0xFFFF0000120};121122uint32_t _word;123124private:125LinkageInfo() {};126};127128/**129* @brief J9 private linkage override of OMR function130*/131virtual intptr_t entryPointFromCompiledMethod();132133/**134* @brief J9 private linkage override of OMR function135*/136virtual intptr_t entryPointFromInterpretedMethod();137138virtual void mapIncomingParms(TR::ResolvedMethodSymbol *method);139};140141}142143#endif144145146