Skip to content

Commit 1e860a4

Browse files
authored
Move RuntimeAsync ifdef to env variable (#118011)
1 parent 9da102b commit 1e860a4

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed

src/coreclr/clrdefinitions.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ if(FEATURE_OBJCMARSHAL)
152152
add_compile_definitions(FEATURE_OBJCMARSHAL)
153153
endif()
154154

155-
# add_compile_definitions(FEATURE_RUNTIME_ASYNC)
156-
157155
add_compile_definitions($<${FEATURE_JAVAMARSHAL}:FEATURE_JAVAMARSHAL>)
158156

159157
add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:DAC_COMPONENT>>>:FEATURE_PROFAPI_ATTACH_DETACH>)

src/coreclr/inc/clrconfigvalues.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,9 @@ RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableRiscV64Zba, W("EnableRiscV64
708708
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableRiscV64Zbb, W("EnableRiscV64Zbb"), 1, "Allows RiscV64 Zbb hardware intrinsics to be disabled")
709709
#endif
710710

711+
// Runtime-async
712+
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_RuntimeAsync, W("RuntimeAsync"), 0, "Enables runtime async method support")
713+
711714
///
712715
/// Uncategorized
713716
///

src/coreclr/vm/eeconfig.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ HRESULT EEConfig::Init()
237237
fGDBJitEmitDebugFrame = false;
238238
#endif
239239

240+
runtimeAsync = false;
241+
240242
return S_OK;
241243
}
242244

@@ -763,6 +765,8 @@ HRESULT EEConfig::sync()
763765
fUseCachedInterfaceDispatch = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_UseCachedInterfaceDispatch) != 0;
764766
#endif // defined(FEATURE_CACHED_INTERFACE_DISPATCH) && defined(FEATURE_VIRTUAL_STUB_DISPATCH)
765767

768+
runtimeAsync = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_RuntimeAsync) != 0;
769+
766770
return hr;
767771
}
768772

src/coreclr/vm/eeconfig.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ class EEConfig
439439

440440
#endif
441441

442+
bool RuntimeAsync() const { LIMITED_METHOD_CONTRACT; return runtimeAsync; }
443+
442444
private: //----------------------------------------------------------------
443445

444446
bool fInited; // have we synced to the registry at least once?
@@ -634,6 +636,8 @@ class EEConfig
634636
bool fUseCachedInterfaceDispatch;
635637
#endif // defined(FEATURE_CACHED_INTERFACE_DISPATCH) && defined(FEATURE_VIRTUAL_STUB_DISPATCH)
636638

639+
bool runtimeAsync; // True if the runtime supports async methods
640+
637641
public:
638642

639643
enum BitForMask {

src/coreclr/vm/method.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,9 +2299,13 @@ bool IsTypeDefOrRefImplementedInSystemModule(Module* pModule, mdToken tk)
22992299

23002300
MethodReturnKind ClassifyMethodReturnKind(SigPointer sig, Module* pModule, ULONG* offsetOfAsyncDetails, bool *isValueTask)
23012301
{
2302-
// Without FEATURE_RUNTIME_ASYNC every declared method is classified as a NormalMethod.
2302+
// Without runtime async, every declared method is classified as a NormalMethod.
23032303
// Thus code that handles runtime async scenarios becomes unreachable.
2304-
#ifdef FEATURE_RUNTIME_ASYNC
2304+
if (!g_pConfig->RuntimeAsync())
2305+
{
2306+
return MethodReturnKind::NormalMethod;
2307+
}
2308+
23052309
PCCOR_SIGNATURE initialSig = sig.GetPtr();
23062310
uint32_t data;
23072311
IfFailThrow(sig.GetCallingConvInfo(&data));
@@ -2359,7 +2363,6 @@ MethodReturnKind ClassifyMethodReturnKind(SigPointer sig, Module* pModule, ULONG
23592363
return MethodReturnKind::NonGenericTaskReturningMethod;
23602364
}
23612365
}
2362-
#endif // FEATURE_RUNTIME_ASYNC
23632366

23642367
return MethodReturnKind::NormalMethod;
23652368
}

src/coreclr/vm/methodtablebuilder.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,10 +2688,13 @@ MethodTableBuilder::EnumerateClassMethods()
26882688
BuildMethodTableThrowException(IDS_CLASSLOAD_TOO_MANY_METHODS);
26892689

26902690
bmtMethod->m_cMaxDeclaredMethods = (SLOT_INDEX)cMethAndGaps;
2691-
#ifdef FEATURE_RUNTIME_ASYNC
2692-
// TODO: (async) the index is uint16 and can potentially overflow. This needs to be more robust.
2693-
bmtMethod->m_cMaxDeclaredMethods *= 2;
2694-
#endif
2691+
2692+
if (g_pConfig->RuntimeAsync())
2693+
{
2694+
// TODO: (async) the index is uint16 and can potentially overflow. This needs to be more robust.
2695+
bmtMethod->m_cMaxDeclaredMethods *= 2;
2696+
}
2697+
26952698
bmtMethod->m_cDeclaredMethods = 0;
26962699
bmtMethod->m_rgDeclaredMethods = new (GetStackingAllocator())
26972700
bmtMDMethod *[bmtMethod->m_cMaxDeclaredMethods];

0 commit comments

Comments
 (0)