diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/coreclr/hosts/coreconsole/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/coreclr/hosts/corerun/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/dlls/mscoree/coreclr/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/ilasm/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/ildasm/exe/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/ildasm/rcdll/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/jit/inline.cpp | 73 | ||||
-rw-r--r-- | src/jit/inline.def | 1 | ||||
-rw-r--r-- | src/jit/inline.h | 8 | ||||
-rw-r--r-- | src/jit/inlinepolicy.cpp | 31 | ||||
-rw-r--r-- | src/jit/standalone/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/pal/src/thread/process.cpp | 37 | ||||
-rw-r--r-- | src/tools/crossgen/CMakeLists.txt | 3 |
13 files changed, 156 insertions, 14 deletions
diff --git a/src/coreclr/hosts/coreconsole/CMakeLists.txt b/src/coreclr/hosts/coreconsole/CMakeLists.txt index 634fdb77d6..fdc0020126 100644 --- a/src/coreclr/hosts/coreconsole/CMakeLists.txt +++ b/src/coreclr/hosts/coreconsole/CMakeLists.txt @@ -23,7 +23,8 @@ else() ) target_link_libraries(CoreConsole - msvcrt.lib + ${STATIC_MT_CRT_LIB} + ${STATIC_MT_VCRT_LIB} ) # Can't compile on linux yet so only add for windows diff --git a/src/coreclr/hosts/corerun/CMakeLists.txt b/src/coreclr/hosts/corerun/CMakeLists.txt index 7b25c12d6b..93bb9c2bcc 100644 --- a/src/coreclr/hosts/corerun/CMakeLists.txt +++ b/src/coreclr/hosts/corerun/CMakeLists.txt @@ -28,7 +28,8 @@ else() oleaut32.lib uuid.lib user32.lib - msvcrt.lib + ${STATIC_MT_CRT_LIB} + ${STATIC_MT_VCRT_LIB} ) # Can't compile on linux yet so only add for windows diff --git a/src/dlls/mscoree/coreclr/CMakeLists.txt b/src/dlls/mscoree/coreclr/CMakeLists.txt index 227490de21..c864d43fff 100644 --- a/src/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/dlls/mscoree/coreclr/CMakeLists.txt @@ -99,9 +99,10 @@ set(CORECLR_LIBRARIES if(WIN32) list(APPEND CORECLR_LIBRARIES + ${STATIC_MT_CRT_LIB} + ${STATIC_MT_VCRT_LIB} mdwinmd_wks comnls_wks - msvcrt.lib kernel32.lib advapi32.lib ole32.lib diff --git a/src/ilasm/CMakeLists.txt b/src/ilasm/CMakeLists.txt index e6828e7a49..f155f48289 100644 --- a/src/ilasm/CMakeLists.txt +++ b/src/ilasm/CMakeLists.txt @@ -70,7 +70,6 @@ else() target_link_libraries(ilasm ${ILASM_LINK_LIBRARIES} coreclr - msvcrt ole32 oleaut32 shell32 diff --git a/src/ildasm/exe/CMakeLists.txt b/src/ildasm/exe/CMakeLists.txt index 8b468f07a4..8ce2bc3446 100644 --- a/src/ildasm/exe/CMakeLists.txt +++ b/src/ildasm/exe/CMakeLists.txt @@ -64,7 +64,6 @@ else() target_link_libraries(ildasm ${ILDASM_LINK_LIBRARIES} coreclr - msvcrt ole32 oleaut32 shell32 diff --git a/src/ildasm/rcdll/CMakeLists.txt b/src/ildasm/rcdll/CMakeLists.txt index 2a3a2c8291..20af311045 100644 --- a/src/ildasm/rcdll/CMakeLists.txt +++ b/src/ildasm/rcdll/CMakeLists.txt @@ -18,7 +18,8 @@ add_library_clr(ildasmrc ) target_link_libraries(ildasmrc - msvcrt + ${STATIC_MT_CRT_LIB} + ${STATIC_MT_VCRT_LIB} ) # We will generate PDB only for the debug configuration diff --git a/src/jit/inline.cpp b/src/jit/inline.cpp index 188d21caf7..4477fd2d14 100644 --- a/src/jit/inline.cpp +++ b/src/jit/inline.cpp @@ -663,6 +663,9 @@ InlineStrategy::InlineStrategy(Compiler* compiler) //------------------------------------------------------------------------ // GetRootContext: get the InlineContext for the root method // +// Return Value: +// Root context; describes the method being jitted. +// // Note: // Also initializes the jit time estimate and budget. @@ -698,26 +701,68 @@ void InlineStrategy::NoteCandidate() //------------------------------------------------------------------------ // EstimateTime: estimate impact of this inline on the method jit time +// +// Arguments: +// context - context describing this inline +// +// Return Value: +// Nominal estimate of jit time. int InlineStrategy::EstimateTime(InlineContext* context) { - unsigned ILSize = context->GetCodeSize(); - // Simple linear models based on observations + // show time is fairly well predicted by IL size. + unsigned ilSize = context->GetCodeSize(); + // Prediction varies for root and inlines. if (context == m_RootContext) { - // Root method - return 60 + 3 * ILSize; + return EstimateRootTime(ilSize); } else { - // Inline - return -14 + 2 * ILSize; + return EstimateInlineTime(ilSize); } } //------------------------------------------------------------------------ +// EstimteRootTime: estimate jit time for method of this size with +// no inlining. +// +// Arguments: +// ilSize - size of the method's IL +// +// Return Value: +// Nominal estimate of jit time. +// +// Notes: +// Based on observational data. Time is nominally microseconds. + +int InlineStrategy::EstimateRootTime(unsigned ilSize) +{ + return 60 + 3 * ilSize; +} + +//------------------------------------------------------------------------ +// EstimteInlineTime: estimate time impact on jitting for an inline +// of this size. +// +// Arguments: +// ilSize - size of the method's IL +// +// Return Value: +// Nominal increase in jit time. +// +// Notes: +// Based on observational data. Time is nominally microseconds. +// Small inlines will make the jit a bit faster. + +int InlineStrategy::EstimateInlineTime(unsigned ilSize) +{ + return -14 + 2 * ilSize; +} + +//------------------------------------------------------------------------ // NoteOutcome: do bookkeeping for an inline // // Arguments: @@ -789,6 +834,22 @@ void InlineStrategy::NoteOutcome(InlineContext* context) } //------------------------------------------------------------------------ +// BudgetCheck: return true if as inline of this size would exceed the +// jit time budget for this method +// +// Arguments: +// ilSize - size of the method's IL +// +// Return Value: +// true if the inline would go over budget + +bool InlineStrategy::BudgetCheck(unsigned ilSize) +{ + int timeDelta = EstimateInlineTime(ilSize); + return (timeDelta + m_CurrentTimeEstimate > m_CurrentTimeBudget); +} + +//------------------------------------------------------------------------ // NewRoot: construct an InlineContext for the root method // // Return Value: diff --git a/src/jit/inline.def b/src/jit/inline.def index 03979b116d..6684891726 100644 --- a/src/jit/inline.def +++ b/src/jit/inline.def @@ -138,6 +138,7 @@ INLINE_OBSERVATION(LDFLD_NEEDS_HELPER, bool, "ldfld needs helper", INLINE_OBSERVATION(LDVIRTFN_ON_NON_VIRTUAL, bool, "ldvirtfn on non-virtual", FATAL, CALLSITE) INLINE_OBSERVATION(NOT_CANDIDATE, bool, "not inline candidate", FATAL, CALLSITE) INLINE_OBSERVATION(NOT_PROFITABLE_INLINE, bool, "unprofitable inline", FATAL, CALLSITE) +INLINE_OBSERVATION(OVER_BUDGET, bool, "inline exceeds budget", FATAL, CALLSITE) INLINE_OBSERVATION(OVER_INLINE_LIMIT, bool, "limited by JitInlineLimit", FATAL, CALLSITE) INLINE_OBSERVATION(RANDOM_REJECT, bool, "random reject", FATAL, CALLSITE) INLINE_OBSERVATION(REQUIRES_SAME_THIS, bool, "requires same this", FATAL, CALLSITE) diff --git a/src/jit/inline.h b/src/jit/inline.h index 8dfed325b6..efc2db4586 100644 --- a/src/jit/inline.h +++ b/src/jit/inline.h @@ -660,6 +660,10 @@ public: // Inform strategy that there's a new inline candidate. void NoteCandidate(); + // See if an inline of this size would fit within the current jit + // time budget. + bool BudgetCheck(unsigned ilSize); + #if defined(DEBUG) || defined(INLINE_DATA) // Dump textual description of inlines done so far. @@ -687,6 +691,10 @@ private: // Estimate the jit time change because of this inline. int EstimateTime(InlineContext* context); + // EstimateTime helpers + int EstimateRootTime(unsigned ilSize); + int EstimateInlineTime(unsigned ilSize); + #if defined(DEBUG) || defined(INLINE_DATA) static bool s_DumpDataHeader; #endif // defined(DEBUG) || defined(INLINE_DATA) diff --git a/src/jit/inlinepolicy.cpp b/src/jit/inlinepolicy.cpp index bc1385512a..d27a21caaa 100644 --- a/src/jit/inlinepolicy.cpp +++ b/src/jit/inlinepolicy.cpp @@ -321,6 +321,37 @@ void LegacyPolicy::NoteBool(InlineObservation obs, bool value) m_MethodIsMostlyLoadStore = true; } + // Budget check. + // + // Conceptually this should happen when we + // observe the candidate's IL size. + // + // However, we do this here to avoid potential + // inconsistency between the state of the budget + // during candidate scan and the state when the IL is + // being scanned. + // + // Consider the case where we're just below the budget + // during candidate scan, and we have three possible + // inlines, any two of which put us over budget. We + // allow them all to become candidates. We then move + // on to inlining and the first two get inlined and + // put us over budget. Now the third can't be inlined + // anymore, but we have a policy that when we replay + // the candidate IL size during the inlining pass it + // "reestablishes" candidacy rather than alters + // candidacy ... so instead we bail out here. + + if (!m_IsPrejitRoot) + { + InlineStrategy* strategy = m_RootCompiler->m_inlineStrategy; + bool overBudget = strategy->BudgetCheck(m_CodeSize); + if (overBudget) + { + SetFailure(InlineObservation::CALLSITE_OVER_BUDGET); + } + } + break; } diff --git a/src/jit/standalone/CMakeLists.txt b/src/jit/standalone/CMakeLists.txt index 80e9a0e8e9..54a5e54916 100644 --- a/src/jit/standalone/CMakeLists.txt +++ b/src/jit/standalone/CMakeLists.txt @@ -27,7 +27,8 @@ if(CLR_CMAKE_PLATFORM_UNIX) ) else() list(APPEND RYUJIT_LINK_LIBRARIES - msvcrt.lib + ${STATIC_MT_CRT_LIB} + ${STATIC_MT_VCRT_LIB} kernel32.lib advapi32.lib ole32.lib diff --git a/src/pal/src/thread/process.cpp b/src/pal/src/thread/process.cpp index 0de235e59c..df9a28b380 100644 --- a/src/pal/src/thread/process.cpp +++ b/src/pal/src/thread/process.cpp @@ -54,6 +54,13 @@ Abstract: #include <sys/sysctl.h> #endif +#ifdef __NetBSD__ +#include <sys/cdefs.h> +#include <sys/param.h> +#include <sys/sysctl.h> +#include <kvm.h> +#endif + using namespace CorUnix; SET_DEFAULT_DEBUG_CHANNEL(PROCESS); @@ -1874,6 +1881,36 @@ GetProcessIdDisambiguationKey(DWORD processId, UINT64 *disambiguationKey) return FALSE; } +#elif defined(__NetBSD__) + + // On NetBSD, we return the process start time expressed in Unix time (the number of seconds + // since the start of the Unix epoch). + kvm_t *kd; + int cnt; + struct kinfo_proc2 *info; + + kd = kvm_open(nullptr, nullptr, nullptr, KVM_NO_FILES, "kvm_open"); + if (kd == nullptr) + { + _ASSERTE(!"Failed to get start time of a process."); + return FALSE; + } + + info = kvm_getproc2(kd, KERN_PROC_PID, processId, sizeof(struct kinfo_proc2), &cnt); + if (info == nullptr || cnt < 1) + { + kvm_close(kd); + _ASSERTE(!"Failed to get start time of a process."); + return FALSE; + } + + kvm_close(kd); + + long secondsSinceEpoch = info->p_ustart_sec; + *disambiguationKey = secondsSinceEpoch; + + return TRUE; + #elif defined(HAVE_PROCFS_CTL) // Here we read /proc/<pid>/stat file to get the start time for the process. diff --git a/src/tools/crossgen/CMakeLists.txt b/src/tools/crossgen/CMakeLists.txt index 4baac254c9..c0099f66a8 100644 --- a/src/tools/crossgen/CMakeLists.txt +++ b/src/tools/crossgen/CMakeLists.txt @@ -62,7 +62,8 @@ else() shlwapi bcrypt mdwinmd_crossgen - msvcrt + ${STATIC_MT_CRT_LIB} + ${STATIC_MT_VCRT_LIB} ) endif(CLR_CMAKE_PLATFORM_UNIX) |