summaryrefslogtreecommitdiff
path: root/src/vm/prestub.cpp
diff options
context:
space:
mode:
authorNoah Falk <noahfalk@users.noreply.github.com>2017-03-29 23:24:57 -0700
committerGitHub <noreply@github.com>2017-03-29 23:24:57 -0700
commitbf6a03a994fce9c4b1bb3ba904b67c09d7f40b68 (patch)
tree67aa335918995c27469cedce7b2c25048f339b6c /src/vm/prestub.cpp
parent61f3162a2d2729cc146c1864e0a742a48bd0ed7d (diff)
parent850164ee70077e0970d7ab4e4bf2ca51809b92e8 (diff)
downloadcoreclr-bf6a03a994fce9c4b1bb3ba904b67c09d7f40b68.tar.gz
coreclr-bf6a03a994fce9c4b1bb3ba904b67c09d7f40b68.tar.bz2
coreclr-bf6a03a994fce9c4b1bb3ba904b67c09d7f40b68.zip
Merge pull request #10478 from noahfalk/fitjit
Tiered Compilation step 1
Diffstat (limited to 'src/vm/prestub.cpp')
-rw-r--r--src/vm/prestub.cpp60
1 files changed, 56 insertions, 4 deletions
diff --git a/src/vm/prestub.cpp b/src/vm/prestub.cpp
index 87b36fa275..e6467710dd 100644
--- a/src/vm/prestub.cpp
+++ b/src/vm/prestub.cpp
@@ -48,6 +48,10 @@
#include "perfmap.h"
#endif
+#ifdef FEATURE_TIERED_COMPILATION
+#include "callcounter.h"
+#endif
+
#ifndef DACCESS_COMPILE
EXTERN_C void STDCALL ThePreStub();
@@ -267,10 +271,12 @@ PCODE MethodDesc::MakeJitWorker(COR_ILMETHOD_DECODER* ILHeader, CORJIT_FLAGS fla
PCODE pCode = NULL;
ULONG sizeOfCode = 0;
+#if defined(FEATURE_INTERPRETER) || defined(FEATURE_TIERED_COMPILATION)
+ BOOL fStable = TRUE; // True iff the new code address (to be stored in pCode), is a stable entry point.
+#endif
#ifdef FEATURE_INTERPRETER
PCODE pPreviousInterpStub = NULL;
BOOL fInterpreted = FALSE;
- BOOL fStable = TRUE; // True iff the new code address (to be stored in pCode), is a stable entry point.
#endif
#ifdef FEATURE_MULTICOREJIT
@@ -279,6 +285,20 @@ PCODE MethodDesc::MakeJitWorker(COR_ILMETHOD_DECODER* ILHeader, CORJIT_FLAGS fla
bool fBackgroundThread = flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_MCJIT_BACKGROUND);
#endif
+ // If this is the first stage of a tiered compilation progression, use min-opt, otherwise
+ // use default compilation options
+#ifdef FEATURE_TIERED_COMPILATION
+ if (!IsEligibleForTieredCompilation())
+ {
+ fStable = TRUE;
+ }
+ else
+ {
+ fStable = FALSE;
+ flags.Add(CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_MIN_OPT));
+ }
+#endif
+
{
// Enter the global lock which protects the list of all functions being JITd
ListLockHolder pJitLock (GetDomain()->GetJitLock());
@@ -1283,6 +1303,22 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT)
if (!IsPointingToPrestub())
#endif
{
+ // If we are counting calls for tiered compilation, leave the prestub
+ // in place so that we can continue intercepting method invocations.
+ // When the TieredCompilationManager has received enough call notifications
+ // for this method only then do we back-patch it.
+#ifdef FEATURE_TIERED_COMPILATION
+ PCODE pNativeCode = GetNativeCode();
+ if (pNativeCode && IsEligibleForTieredCompilation())
+ {
+ CallCounter * pCallCounter = GetAppDomain()->GetCallCounter();
+ BOOL doBackPatch = pCallCounter->OnMethodCalled(this);
+ if (!doBackPatch)
+ {
+ return pNativeCode;
+ }
+ }
+#endif
LOG((LF_CLASSLOADER, LL_INFO10000,
" In PreStubWorker, method already jitted, backpatching call point\n"));
@@ -1308,8 +1344,8 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT)
else if (IsIL() || IsNoMetadata())
{
// remember if we need to backpatch the MethodTable slot
- BOOL fBackpatch = !fRemotingIntercepted
- && !IsEnCMethod();
+ BOOL fBackpatch = !fRemotingIntercepted
+ && IsNativeCodeStableAfterInit();
#ifdef FEATURE_PREJIT
//
@@ -1583,6 +1619,22 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT)
MemoryBarrier();
#endif
+ // If we are counting calls for tiered compilation, leave the prestub
+ // in place so that we can continue intercepting method invocations.
+ // When the TieredCompilationManager has received enough call notifications
+ // for this method only then do we back-patch it.
+#ifdef FEATURE_TIERED_COMPILATION
+ if (pCode && IsEligibleForTieredCompilation())
+ {
+ CallCounter * pCallCounter = GetAppDomain()->GetCallCounter();
+ BOOL doBackPatch = pCallCounter->OnMethodCalled(this);
+ if (!doBackPatch)
+ {
+ return pCode;
+ }
+ }
+#endif
+
if (pCode != NULL)
{
if (HasPrecode())
@@ -1712,7 +1764,7 @@ static PCODE PatchNonVirtualExternalMethod(MethodDesc * pMD, PCODE pCode, PTR_CO
//
#ifdef HAS_FIXUP_PRECODE
if (pMD->HasPrecode() && pMD->GetPrecode()->GetType() == PRECODE_FIXUP
- && !pMD->IsEnCMethod()
+ && pMD->IsNativeCodeStableAfterInit()
#ifndef HAS_REMOTING_PRECODE
&& !pMD->IsRemotingInterceptedViaPrestub()
#endif