From 4561dad3f38f8dd5a9637fc3a0be418abac1f088 Mon Sep 17 00:00:00 2001 From: noahfalk Date: Thu, 30 Mar 2017 00:07:59 -0700 Subject: [PATCH] Add Tier0/1 jit flags These flags provides a hook to change the JIT policy in the future and diverge tier0/tier1 compilation from min_opt/speed_opt respectively. --- src/inc/corinfo.h | 10 +++++----- src/inc/corjit.h | 2 ++ src/jit/compiler.cpp | 6 ++++-- src/jit/jitee.h | 4 ++++ src/vm/prestub.cpp | 4 ++-- src/vm/tieredcompilation.cpp | 2 +- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/inc/corinfo.h b/src/inc/corinfo.h index f7560b2..d421ac1 100644 --- a/src/inc/corinfo.h +++ b/src/inc/corinfo.h @@ -214,11 +214,11 @@ TODO: Talk about initializing strutures before use #endif // Update this one -SELECTANY const GUID JITEEVersionIdentifier = { /* 61783541-8fc0-44ce-80f7-7789b93a3309 */ - 0x61783541, - 0x8fc0, - 0x44ce, - { 0x80, 0xf7, 0x77, 0x89, 0xb9, 0x3a, 0x33, 0x09 } +SELECTANY const GUID JITEEVersionIdentifier = { /* f00b3f49-ddd2-49be-ba43-6e49ffa66959 */ + 0xf00b3f49, + 0xddd2, + 0x49be, + { 0xba, 0x43, 0x6e, 0x49, 0xff, 0xa6, 0x69, 0x59 } }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/inc/corjit.h b/src/inc/corjit.h index f434fee..e6d067c 100644 --- a/src/inc/corjit.h +++ b/src/inc/corjit.h @@ -146,6 +146,8 @@ public: CORJIT_FLAG_USE_PINVOKE_HELPERS = 36, // The JIT should use the PINVOKE_{BEGIN,END} helpers instead of emitting inline transitions CORJIT_FLAG_REVERSE_PINVOKE = 37, // The JIT should insert REVERSE_PINVOKE_{ENTER,EXIT} helpers into method prolog/epilog CORJIT_FLAG_DESKTOP_QUIRKS = 38, // The JIT should generate desktop-quirk-compatible code + CORJIT_FLAG_TIER0 = 39, // This is the initial tier for tiered compilation which should generate code as quickly as possible + CORJIT_FLAG_TIER1 = 40, // This is the final tier (for now) for tiered compilation which should generate high quality code }; CORJIT_FLAGS() diff --git a/src/jit/compiler.cpp b/src/jit/compiler.cpp index 3f75623..df54c8f 100644 --- a/src/jit/compiler.cpp +++ b/src/jit/compiler.cpp @@ -2470,7 +2470,8 @@ void Compiler::compInitOptions(JitFlags* jitFlags) opts.jitFlags = jitFlags; opts.compFlags = CLFLG_MAXOPT; // Default value is for full optimization - if (jitFlags->IsSet(JitFlags::JIT_FLAG_DEBUG_CODE) || jitFlags->IsSet(JitFlags::JIT_FLAG_MIN_OPT)) + if (jitFlags->IsSet(JitFlags::JIT_FLAG_DEBUG_CODE) || jitFlags->IsSet(JitFlags::JIT_FLAG_MIN_OPT) || + jitFlags->IsSet(JitFlags::JIT_FLAG_TIER0)) { opts.compFlags = CLFLG_MINOPT; } @@ -2495,7 +2496,8 @@ void Compiler::compInitOptions(JitFlags* jitFlags) // // If the EE sets SPEED_OPT we will optimize for speed at the expense of code size // - else if (jitFlags->IsSet(JitFlags::JIT_FLAG_SPEED_OPT)) + else if (jitFlags->IsSet(JitFlags::JIT_FLAG_SPEED_OPT) || + (jitFlags->IsSet(JitFlags::JIT_FLAG_TIER1) && !jitFlags->IsSet(JitFlags::JIT_FLAG_MIN_OPT))) { opts.compCodeOpt = FAST_CODE; assert(!jitFlags->IsSet(JitFlags::JIT_FLAG_SIZE_OPT)); diff --git a/src/jit/jitee.h b/src/jit/jitee.h index 810c93e..7b0e4a0 100644 --- a/src/jit/jitee.h +++ b/src/jit/jitee.h @@ -78,6 +78,8 @@ public: JIT_FLAG_USE_PINVOKE_HELPERS = 36, // The JIT should use the PINVOKE_{BEGIN,END} helpers instead of emitting inline transitions JIT_FLAG_REVERSE_PINVOKE = 37, // The JIT should insert REVERSE_PINVOKE_{ENTER,EXIT} helpers into method prolog/epilog JIT_FLAG_DESKTOP_QUIRKS = 38, // The JIT should generate desktop-quirk-compatible code + JIT_FLAG_TIER0 = 39, // This is the initial tier for tiered compilation which should generate code as quickly as possible + JIT_FLAG_TIER1 = 40, // This is the final tier (for now) for tiered compilation which should generate high quality code }; // clang-format on @@ -187,6 +189,8 @@ public: FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_USE_PINVOKE_HELPERS, JIT_FLAG_USE_PINVOKE_HELPERS); FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_REVERSE_PINVOKE, JIT_FLAG_REVERSE_PINVOKE); FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_DESKTOP_QUIRKS, JIT_FLAG_DESKTOP_QUIRKS); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_TIER0, JIT_FLAG_TIER0); + FLAGS_EQUAL(CORJIT_FLAGS::CORJIT_FLAG_TIER1, JIT_FLAG_TIER1); #undef FLAGS_EQUAL } diff --git a/src/vm/prestub.cpp b/src/vm/prestub.cpp index e646771..67639e9 100644 --- a/src/vm/prestub.cpp +++ b/src/vm/prestub.cpp @@ -285,7 +285,7 @@ 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 + // If this is the first stage of a tiered compilation progression, use tier0, otherwise // use default compilation options #ifdef FEATURE_TIERED_COMPILATION if (!IsEligibleForTieredCompilation()) @@ -295,7 +295,7 @@ PCODE MethodDesc::MakeJitWorker(COR_ILMETHOD_DECODER* ILHeader, CORJIT_FLAGS fla else { fStable = FALSE; - flags.Add(CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_MIN_OPT)); + flags.Add(CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_TIER0)); } #endif diff --git a/src/vm/tieredcompilation.cpp b/src/vm/tieredcompilation.cpp index 64378db..2032e66 100644 --- a/src/vm/tieredcompilation.cpp +++ b/src/vm/tieredcompilation.cpp @@ -300,7 +300,7 @@ PCODE TieredCompilationManager::CompileMethod(MethodDesc* pMethod) EX_TRY { CORJIT_FLAGS flags = CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_MCJIT_BACKGROUND); - flags.Add(CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_SPEED_OPT)); + flags.Add(CORJIT_FLAGS(CORJIT_FLAGS::CORJIT_FLAG_TIER1)); if (pMethod->IsDynamicMethod()) { -- 2.7.4