Skip to content

Commit 0be1d88

Browse files
[clr-interp] Setup fully interpreted functional test on iOS simulator (#118889)
* [clr-interp] Set up fully interpreted functional test on iOS simulator * Update src/coreclr/vm/interpexec.cpp Co-authored-by: Aaron Robinson <[email protected]> * Update src/coreclr/vm/interpexec.cpp Co-authored-by: Aaron Robinson <[email protected]> * Add StaticLinkedRuntime property * Update ReadyToRun configuration for iOS platforms * Remove StaticLinkedRuntime property * Add comment * Simplify CMakeLists.txt * Test checked build * Fix exchange instruction size * Update CLR feature flags for Apple mobile targets in CMake * Skip hardware intrinsics check * Fix clrfeatures condition * Add hw.optional.arm.AdvSIMD check * Add tracking issue * Add macros undef in interpexec --------- Co-authored-by: Aaron Robinson <[email protected]>
1 parent 0be0db2 commit 0be1d88

File tree

15 files changed

+94
-28
lines changed

15 files changed

+94
-28
lines changed

src/coreclr/clrfeatures.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
if (NOT CLR_CMAKE_TARGET_ARCH_WASM)
1+
if (NOT CLR_CMAKE_TARGET_ARCH_WASM AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_TARGET_MACCATALYST)
22
set(FEATURE_JIT 1)
33
endif()
44

5-
if (CLR_CMAKE_TARGET_ARCH_WASM OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
5+
if (CLR_CMAKE_TARGET_ARCH_WASM OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS OR CLR_CMAKE_TARGET_MACCATALYST)
66
set(FEATURE_STATICALLY_LINKED 1)
77
endif()
88

src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ target_compile_definitions(coreclr_static PUBLIC CORECLR_EMBEDDED)
214214

215215
if (CLR_CMAKE_HOST_ANDROID)
216216
target_link_libraries(coreclr PUBLIC log)
217+
endif()
218+
219+
if (CLR_CMAKE_HOST_ANDROID OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_MACCATALYST)
217220
target_link_libraries(coreclr_static
218221
PUBLIC
219222
coreclrminipal_objects

src/coreclr/interpreter/compiler.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,6 +2378,36 @@ bool InterpCompiler::EmitNamedIntrinsicCall(NamedIntrinsic ni, CORINFO_CLASS_HAN
23782378
return true;
23792379
}
23802380

2381+
case NI_System_Threading_Interlocked_Exchange:
2382+
{
2383+
CHECK_STACK(2);
2384+
InterpType retType = GetInterpType(sig.retType);
2385+
2386+
int32_t opcode;
2387+
switch (retType)
2388+
{
2389+
case InterpTypeI4:
2390+
opcode = INTOP_EXCHANGE_I4;
2391+
break;
2392+
case InterpTypeI8:
2393+
opcode = INTOP_EXCHANGE_I8;
2394+
break;
2395+
default:
2396+
return false;
2397+
}
2398+
2399+
AddIns(opcode);
2400+
m_pStackPointer -= 2;
2401+
2402+
int32_t addrVar = m_pStackPointer[0].var;
2403+
int32_t valueVar = m_pStackPointer[1].var;
2404+
2405+
PushInterpType(retType, nullptr);
2406+
m_pLastNewIns->SetSVars2(addrVar, valueVar);
2407+
m_pLastNewIns->SetDVar(m_pStackPointer[-1].var);
2408+
return true;
2409+
}
2410+
23812411
case NI_System_Runtime_CompilerServices_RuntimeHelpers_IsReferenceOrContainsReferences:
23822412
{
23832413
CORINFO_CLASS_HANDLE clsHnd = sig.sigInst.methInst[0];

src/coreclr/interpreter/intops.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ OPDEF(INTOP_LOAD_FRAMEVAR, "load.framevar", 2, 1, 0, InterpOpNoArgs)
415415
// Intrinsics
416416
OPDEF(INTOP_COMPARE_EXCHANGE_I4, "compare.exchange.i4", 5, 1, 3, InterpOpNoArgs)
417417
OPDEF(INTOP_COMPARE_EXCHANGE_I8, "compare.exchange.i8", 5, 1, 3, InterpOpNoArgs)
418+
OPDEF(INTOP_EXCHANGE_I4, "exchange.i4", 4, 1, 2, InterpOpNoArgs)
419+
OPDEF(INTOP_EXCHANGE_I8, "exchange.i8", 4, 1, 2, InterpOpNoArgs)
418420

419421
// All instructions after this point are IROPS, instructions that are not emitted/executed
420422
OPDEF(INTOP_NOP, "nop", 1, 0, 0, InterpOpNoArgs)

src/coreclr/interpreter/intrinsics.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ NamedIntrinsic GetNamedIntrinsic(COMP_HANDLE compHnd, CORINFO_METHOD_HANDLE comp
104104
{
105105
if (!strcmp(methodName, "CompareExchange"))
106106
return NI_System_Threading_Interlocked_CompareExchange;
107+
else if (!strcmp(methodName, "Exchange"))
108+
return NI_System_Threading_Interlocked_Exchange;
107109
else if (!strcmp(methodName, "MemoryBarrier"))
108110
return NI_System_Threading_Interlocked_MemoryBarrier;
109111
}

src/coreclr/vm/eeconfig.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ HRESULT EEConfig::sync()
639639
#if defined(FEATURE_INTERPRETER)
640640
if (fTieredCompilation)
641641
{
642-
// Disable tiered compilation for interpreter testing. Tiered compilation and interpreter
642+
// Disable tiered compilation for interpreter testing. Tiered compilation and interpreter
643643
// do not work well together currently.
644644
LPWSTR pwzInterpreterMaybe;
645645
IfFailThrow(CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_Interpreter, &pwzInterpreterMaybe));

src/coreclr/vm/interpexec.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
646646
// Normal moves between vars
647647
case INTOP_MOV_4: MOV(int32_t, int32_t); break;
648648
case INTOP_MOV_8: MOV(int64_t, int64_t); break;
649+
#undef MOV
649650

650651
case INTOP_MOV_VT:
651652
memmove(stack + ip[1], stack + ip[2], ip[3]);
@@ -1016,6 +1017,7 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
10161017
case INTOP_BRTRUE_I8:
10171018
BR_UNOP(int64_t, != 0);
10181019
break;
1020+
#undef BR_UNOP
10191021

10201022
#define BR_BINOP_COND(cond) \
10211023
if (cond) \
@@ -1226,6 +1228,8 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
12261228
BR_BINOP_COND(isunordered(d1, d2) || d1 < d2);
12271229
break;
12281230
}
1231+
#undef BR_BINOP_COND
1232+
#undef BR_BINOP
12291233

12301234
case INTOP_ADD_I4:
12311235
LOCAL_VAR(ip[1], int32_t) = LOCAL_VAR(ip[2], int32_t) + LOCAL_VAR(ip[3], int32_t);
@@ -1682,6 +1686,7 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
16821686
case INTOP_CLT_UN_R8:
16831687
CMP_BINOP_FP(double, <, 1);
16841688
break;
1689+
#undef CMP_BINOP_FP
16851690

16861691
#define LDIND(dtype, ftype) \
16871692
do { \
@@ -1715,6 +1720,7 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
17151720
case INTOP_LDIND_R8:
17161721
LDIND(double, double);
17171722
break;
1723+
#undef LDIND
17181724
case INTOP_LDIND_VT:
17191725
{
17201726
char *src = LOCAL_VAR(ip[2], char*);
@@ -1757,6 +1763,7 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
17571763
case INTOP_STIND_R8:
17581764
STIND(double, double);
17591765
break;
1766+
#undef STIND
17601767
case INTOP_STIND_O:
17611768
{
17621769
char *dst = LOCAL_VAR(ip[1], char*);
@@ -2361,6 +2368,7 @@ do { \
23612368
LDELEM(double, double);
23622369
break;
23632370
}
2371+
#undef LDELEM
23642372
case INTOP_LDELEM_REF:
23652373
{
23662374
BASEARRAYREF arrayRef = LOCAL_VAR(ip[2], BASEARRAYREF);
@@ -2457,6 +2465,7 @@ do { \
24572465
STELEM(double, double);
24582466
break;
24592467
}
2468+
#undef STELEM
24602469
case INTOP_STELEM_REF:
24612470
{
24622471
BASEARRAYREF arrayRef = LOCAL_VAR(ip[1], BASEARRAYREF);
@@ -2635,6 +2644,31 @@ do \
26352644
COMPARE_EXCHANGE(int64_t);
26362645
break;
26372646
}
2647+
#undef COMPARE_EXCHANGE
2648+
2649+
#define EXCHANGE(type) \
2650+
do \
2651+
{ \
2652+
type* dst = LOCAL_VAR(ip[2], type*); \
2653+
NULL_CHECK(dst); \
2654+
type newValue = LOCAL_VAR(ip[3], type); \
2655+
type old = InterlockedExchangeT(dst, newValue); \
2656+
LOCAL_VAR(ip[1], type) = old; \
2657+
ip += 4; \
2658+
} while (0)
2659+
2660+
case INTOP_EXCHANGE_I4:
2661+
{
2662+
EXCHANGE(int32_t);
2663+
break;
2664+
}
2665+
2666+
case INTOP_EXCHANGE_I8:
2667+
{
2668+
EXCHANGE(int64_t);
2669+
break;
2670+
}
2671+
#undef EXCHANGE
26382672

26392673
case INTOP_CALL_FINALLY:
26402674
{

src/coreclr/vm/prestub.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,13 +2371,14 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo
23712371
pCode = DoBackpatch(pMT, pDispatchingMT, FALSE);
23722372

23732373
Return:
2374-
#if defined(FEATURE_INTERPRETER) && defined(FEATURE_JIT)
2374+
// Interpreter-FIXME: Call stubs are not yet supported on WASM
2375+
#if defined(FEATURE_INTERPRETER) && !defined(TARGET_WASM)
23752376
InterpByteCodeStart *pInterpreterCode = GetInterpreterCode();
23762377
if (pInterpreterCode != NULL)
23772378
{
23782379
CreateNativeToInterpreterCallStub(pInterpreterCode->Method);
23792380
}
2380-
#endif // FEATURE_INTERPRETER && FEATURE_JIT
2381+
#endif // FEATURE_INTERPRETER && !TARGET_WASM
23812382

23822383
RETURN pCode;
23832384
}

src/mono/msbuild/apple/build/AppleBuild.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@
9999
</PropertyGroup>
100100

101101
<RemoveDir Directories="$(AppleBundleDir)" />
102+
103+
<!-- Copy static CoreCLR library for static linking scenarios. Tracking issue: https://github.com/dotnet/runtime/issues/116531 -->
104+
<Copy SourceFiles="$(CoreCLRArtifactsPath)libcoreclr_static.a"
105+
DestinationFiles="$(AppleBuildDir)libcoreclr_static.a"
106+
Condition="'$(RuntimeFlavor)' == 'CoreCLR' and Exists('$(CoreCLRArtifactsPath)libcoreclr_static.a')" />
102107
</Target>
103108

104109
<Target Name="_AppleResolveReferences">

src/native/libs/System.Globalization.Native/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI)
192192
endif()
193193

194194
install (TARGETS System.Globalization.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs)
195-
if(CLR_CMAKE_HOST_ANDROID)
195+
if(CLR_CMAKE_HOST_ANDROID OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_MACCATALYST)
196196
install (TARGETS System.Globalization.Native-Static DESTINATION sharedFramework COMPONENT runtime)
197197
endif()
198198

0 commit comments

Comments
 (0)