Path: blob/master/runtime/compiler/control/MethodToBeCompiled.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 METHODTOBECOMPILED_HPP23#define METHODTOBECOMPILED_HPP2425#pragma once2627#include "j9.h"28#if defined(J9VM_OPT_JITSERVER)29#include "compile/CompilationTypes.hpp"30#endif /* defined(J9VM_OPT_JITSERVER) */31#include "control/CompilationPriority.hpp"32#include "ilgen/IlGeneratorMethodDetails_inlines.hpp"333435#define MAX_COMPILE_ATTEMPTS 33637#define ENTRY_INITIALIZED 0x138#define ENTRY_QUEUED 0x239#define ENTRY_IN_POOL_NOT_FREE 0x4 // comp thread finished and put the entry back in the pool40#define ENTRY_IN_POOL_FREE 0x841#define ENTRY_DEALLOCATED 0x104243namespace TR { class CompilationInfoPerThreadBase; }44class TR_OptimizationPlan;45#if defined(J9VM_OPT_JITSERVER)46namespace JITServer { class ServerStream; }47#endif /* defined(J9VM_OPT_JITSERVER) */48namespace TR { class Monitor; }49struct J9JITConfig;50struct J9VMThread;5152struct TR_MethodToBeCompiled53{54enum LPQ_REASON55{56REASON_NONE = 0,57REASON_IPROFILER_CALLS,58REASON_LOW_COUNT_EXPIRED,59REASON_UPGRADE,60#if defined(J9VM_OPT_JITSERVER)61REASON_SERVER_UNAVAILABLE62#endif63};6465static int16_t _globalIndex;66static TR_MethodToBeCompiled *allocate(J9JITConfig *jitConfig);67void shutdown();6869void initialize(TR::IlGeneratorMethodDetails & details, void *oldStartPC, CompilationPriority p, TR_OptimizationPlan *optimizationPlan);7071TR::Monitor *getMonitor() { return _monitor; }72TR::IlGeneratorMethodDetails & getMethodDetails() const { return *_methodDetails; }73bool isDLTCompile() { return getMethodDetails().isMethodInProgress(); }74bool isCompiled() const;75bool isJNINative() const;76void acquireSlotMonitor(J9VMThread *vmThread);77void releaseSlotMonitor(J9VMThread *vmThread);78void setAotCodeToBeRelocated(const void *m);79bool isAotLoad() const { return _doAotLoad; }80#if defined(J9VM_OPT_JITSERVER)81bool isRemoteCompReq() const { return _remoteCompReq; } // at the client82void setRemoteCompReq() { _remoteCompReq = true; }83void unsetRemoteCompReq() { _remoteCompReq = false; }84bool isOutOfProcessCompReq() const { return _stream != NULL; } // at the server85uint64_t getClientUID() const;86bool hasChangedToLocalSyncComp() const { return (_origOptLevel != unknownHotness); }87void setShouldUpgradeOutOfProcessCompilation() { _shouldUpgradeOutOfProcessCompilation = true; }88bool shouldUpgradeOutOfProcessCompilation() { return _shouldUpgradeOutOfProcessCompilation; }89#else90bool isRemoteCompReq() const { return false; } // at the client91bool isOutOfProcessCompReq() const { return false; } // at the server92#endif /* defined(J9VM_OPT_JITSERVER) */9394TR_MethodToBeCompiled *_next;95TR::IlGeneratorMethodDetails _methodDetailsStorage;96TR::IlGeneratorMethodDetails *_methodDetails;97void *_oldStartPC;98void *_newStartPC;99TR::Monitor *_monitor;100char _monitorName[30]; // to be able to deallocate the string101TR_OptimizationPlan *_optimizationPlan;102uint64_t _entryTime; // time it was added to the queue (ms)103TR::CompilationInfoPerThreadBase *_compInfoPT; // pointer to the thread that is handling this request104const void * _aotCodeToBeRelocated;105106uint16_t /*CompilationPriority*/_priority;107int16_t _numThreadsWaiting;108int8_t _compilationAttemptsLeft;109int8_t _compErrCode;110int8_t _methodIsInSharedCache;/*TR_YesNoMaybe*/111uint8_t _reqFromSecondaryQueue; // This is actually of LPQ_REASON type112113// list of flags114bool _reqFromJProfilingQueue;115bool _unloadedMethod; // flag set by the GC thread during unloading116// need to have vmaccess for accessing this flag117bool _doAotLoad;// used for AOT shared cache118bool _useAotCompilation;// used for AOT shared cache119bool _doNotUseAotCodeFromSharedCache;120bool _tryCompilingAgain;121122bool _async; // flag for async compilation; used to print in vlog123bool _changedFromAsyncToSync; // to prevent DLT compiling again and again we flag124// the normal requests for which a DLT request also125// exists, so that any further normal compilation126// requests for the same method will be performed127// synchronously128bool _entryShouldBeDeallocated; // when set, the thread requesting the compilation129// should deallocate the entry130// It is set only when stopping compilation thread131bool _entryIsCountedAsInvRequest; // when adding a request to the queue, if this is132// an invalidation request, flag the entry and133// increment a counter. Note that this flag is solely134// used for proper counting. An entry could have been135// queued as a normal request and later on be136// transformed into a INV request. The flag is only set137// if the request started as an INV request138bool _GCRrequest; // Needed to be able to decrement the number of GCR requests in the queue139// The flag in methodInfo is not enough because it may indicate true when140// the entry is queued, but change afterwards if method receives samples141// to be upgraded to hot or scorching142int16_t _index;143uint8_t _freeTag; // temporary to catch a nasty bug144uint8_t _weight; // Up to 256 levels of weight145bool _hasIncrementedNumCompThreadsCompilingHotterMethods;146uint8_t _jitStateWhenQueued;147148#if defined(J9VM_OPT_JITSERVER)149// Comp request should be sent remotely to JITServer150bool _remoteCompReq;151// A non-NULL field denotes an out-of-process compilation request152JITServer::ServerStream *_stream;153// Cache original optLevel when transforming a remote sync compilation to a local cheap one154TR_Hotness _origOptLevel;155// Flag used to determine whether a cold local compilation should be upgraded by LPQ156bool _shouldUpgradeOutOfProcessCompilation;157// Set at the client after a failed AOT deserialization or load to bypass AOT cache on the next compilation attempt158bool _doNotLoadFromJITServerAOTCache;159#endif /* defined(J9VM_OPT_JITSERVER) */160}; // TR_MethodToBeCompiled161162#endif // METHODTOBECOMPILED_HPP163164165