Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/control/MethodToBeCompiled.hpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2021 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* 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-exception
21
*******************************************************************************/
22
23
#ifndef METHODTOBECOMPILED_HPP
24
#define METHODTOBECOMPILED_HPP
25
26
#pragma once
27
28
#include "j9.h"
29
#if defined(J9VM_OPT_JITSERVER)
30
#include "compile/CompilationTypes.hpp"
31
#endif /* defined(J9VM_OPT_JITSERVER) */
32
#include "control/CompilationPriority.hpp"
33
#include "ilgen/IlGeneratorMethodDetails_inlines.hpp"
34
35
36
#define MAX_COMPILE_ATTEMPTS 3
37
38
#define ENTRY_INITIALIZED 0x1
39
#define ENTRY_QUEUED 0x2
40
#define ENTRY_IN_POOL_NOT_FREE 0x4 // comp thread finished and put the entry back in the pool
41
#define ENTRY_IN_POOL_FREE 0x8
42
#define ENTRY_DEALLOCATED 0x10
43
44
namespace TR { class CompilationInfoPerThreadBase; }
45
class TR_OptimizationPlan;
46
#if defined(J9VM_OPT_JITSERVER)
47
namespace JITServer { class ServerStream; }
48
#endif /* defined(J9VM_OPT_JITSERVER) */
49
namespace TR { class Monitor; }
50
struct J9JITConfig;
51
struct J9VMThread;
52
53
struct TR_MethodToBeCompiled
54
{
55
enum LPQ_REASON
56
{
57
REASON_NONE = 0,
58
REASON_IPROFILER_CALLS,
59
REASON_LOW_COUNT_EXPIRED,
60
REASON_UPGRADE,
61
#if defined(J9VM_OPT_JITSERVER)
62
REASON_SERVER_UNAVAILABLE
63
#endif
64
};
65
66
static int16_t _globalIndex;
67
static TR_MethodToBeCompiled *allocate(J9JITConfig *jitConfig);
68
void shutdown();
69
70
void initialize(TR::IlGeneratorMethodDetails & details, void *oldStartPC, CompilationPriority p, TR_OptimizationPlan *optimizationPlan);
71
72
TR::Monitor *getMonitor() { return _monitor; }
73
TR::IlGeneratorMethodDetails & getMethodDetails() const { return *_methodDetails; }
74
bool isDLTCompile() { return getMethodDetails().isMethodInProgress(); }
75
bool isCompiled() const;
76
bool isJNINative() const;
77
void acquireSlotMonitor(J9VMThread *vmThread);
78
void releaseSlotMonitor(J9VMThread *vmThread);
79
void setAotCodeToBeRelocated(const void *m);
80
bool isAotLoad() const { return _doAotLoad; }
81
#if defined(J9VM_OPT_JITSERVER)
82
bool isRemoteCompReq() const { return _remoteCompReq; } // at the client
83
void setRemoteCompReq() { _remoteCompReq = true; }
84
void unsetRemoteCompReq() { _remoteCompReq = false; }
85
bool isOutOfProcessCompReq() const { return _stream != NULL; } // at the server
86
uint64_t getClientUID() const;
87
bool hasChangedToLocalSyncComp() const { return (_origOptLevel != unknownHotness); }
88
void setShouldUpgradeOutOfProcessCompilation() { _shouldUpgradeOutOfProcessCompilation = true; }
89
bool shouldUpgradeOutOfProcessCompilation() { return _shouldUpgradeOutOfProcessCompilation; }
90
#else
91
bool isRemoteCompReq() const { return false; } // at the client
92
bool isOutOfProcessCompReq() const { return false; } // at the server
93
#endif /* defined(J9VM_OPT_JITSERVER) */
94
95
TR_MethodToBeCompiled *_next;
96
TR::IlGeneratorMethodDetails _methodDetailsStorage;
97
TR::IlGeneratorMethodDetails *_methodDetails;
98
void *_oldStartPC;
99
void *_newStartPC;
100
TR::Monitor *_monitor;
101
char _monitorName[30]; // to be able to deallocate the string
102
TR_OptimizationPlan *_optimizationPlan;
103
uint64_t _entryTime; // time it was added to the queue (ms)
104
TR::CompilationInfoPerThreadBase *_compInfoPT; // pointer to the thread that is handling this request
105
const void * _aotCodeToBeRelocated;
106
107
uint16_t /*CompilationPriority*/_priority;
108
int16_t _numThreadsWaiting;
109
int8_t _compilationAttemptsLeft;
110
int8_t _compErrCode;
111
int8_t _methodIsInSharedCache;/*TR_YesNoMaybe*/
112
uint8_t _reqFromSecondaryQueue; // This is actually of LPQ_REASON type
113
114
// list of flags
115
bool _reqFromJProfilingQueue;
116
bool _unloadedMethod; // flag set by the GC thread during unloading
117
// need to have vmaccess for accessing this flag
118
bool _doAotLoad;// used for AOT shared cache
119
bool _useAotCompilation;// used for AOT shared cache
120
bool _doNotUseAotCodeFromSharedCache;
121
bool _tryCompilingAgain;
122
123
bool _async; // flag for async compilation; used to print in vlog
124
bool _changedFromAsyncToSync; // to prevent DLT compiling again and again we flag
125
// the normal requests for which a DLT request also
126
// exists, so that any further normal compilation
127
// requests for the same method will be performed
128
// synchronously
129
bool _entryShouldBeDeallocated; // when set, the thread requesting the compilation
130
// should deallocate the entry
131
// It is set only when stopping compilation thread
132
bool _entryIsCountedAsInvRequest; // when adding a request to the queue, if this is
133
// an invalidation request, flag the entry and
134
// increment a counter. Note that this flag is solely
135
// used for proper counting. An entry could have been
136
// queued as a normal request and later on be
137
// transformed into a INV request. The flag is only set
138
// if the request started as an INV request
139
bool _GCRrequest; // Needed to be able to decrement the number of GCR requests in the queue
140
// The flag in methodInfo is not enough because it may indicate true when
141
// the entry is queued, but change afterwards if method receives samples
142
// to be upgraded to hot or scorching
143
int16_t _index;
144
uint8_t _freeTag; // temporary to catch a nasty bug
145
uint8_t _weight; // Up to 256 levels of weight
146
bool _hasIncrementedNumCompThreadsCompilingHotterMethods;
147
uint8_t _jitStateWhenQueued;
148
149
#if defined(J9VM_OPT_JITSERVER)
150
// Comp request should be sent remotely to JITServer
151
bool _remoteCompReq;
152
// A non-NULL field denotes an out-of-process compilation request
153
JITServer::ServerStream *_stream;
154
// Cache original optLevel when transforming a remote sync compilation to a local cheap one
155
TR_Hotness _origOptLevel;
156
// Flag used to determine whether a cold local compilation should be upgraded by LPQ
157
bool _shouldUpgradeOutOfProcessCompilation;
158
// Set at the client after a failed AOT deserialization or load to bypass AOT cache on the next compilation attempt
159
bool _doNotLoadFromJITServerAOTCache;
160
#endif /* defined(J9VM_OPT_JITSERVER) */
161
}; // TR_MethodToBeCompiled
162
163
#endif // METHODTOBECOMPILED_HPP
164
165