Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/coreclr/clrfeatures.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
if (NOT CLR_CMAKE_TARGET_ARCH_WASM)
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)
set(FEATURE_JIT 1)
endif()

if (CLR_CMAKE_TARGET_ARCH_WASM OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
if (CLR_CMAKE_TARGET_ARCH_WASM OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS OR CLR_CMAKE_TARGET_MACCATALYST)
set(FEATURE_STATICALLY_LINKED 1)
endif()

Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ target_compile_definitions(coreclr_static PUBLIC CORECLR_EMBEDDED)

if (CLR_CMAKE_HOST_ANDROID)
target_link_libraries(coreclr PUBLIC log)
endif()

if (CLR_CMAKE_HOST_ANDROID OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_MACCATALYST)
target_link_libraries(coreclr_static
PUBLIC
coreclrminipal_objects
Expand Down
30 changes: 30 additions & 0 deletions src/coreclr/interpreter/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,36 @@ bool InterpCompiler::EmitNamedIntrinsicCall(NamedIntrinsic ni, CORINFO_CLASS_HAN
return true;
}

case NI_System_Threading_Interlocked_Exchange:
{
CHECK_STACK(2);
InterpType retType = GetInterpType(sig.retType);

int32_t opcode;
switch (retType)
{
case InterpTypeI4:
opcode = INTOP_EXCHANGE_I4;
break;
case InterpTypeI8:
opcode = INTOP_EXCHANGE_I8;
break;
default:
return false;
}

AddIns(opcode);
m_pStackPointer -= 2;

int32_t addrVar = m_pStackPointer[0].var;
int32_t valueVar = m_pStackPointer[1].var;

PushInterpType(retType, nullptr);
m_pLastNewIns->SetSVars2(addrVar, valueVar);
m_pLastNewIns->SetDVar(m_pStackPointer[-1].var);
return true;
}

case NI_System_Runtime_CompilerServices_RuntimeHelpers_IsReferenceOrContainsReferences:
{
CORINFO_CLASS_HANDLE clsHnd = sig.sigInst.methInst[0];
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/interpreter/intops.def
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ OPDEF(INTOP_LOAD_FRAMEVAR, "load.framevar", 2, 1, 0, InterpOpNoArgs)
// Intrinsics
OPDEF(INTOP_COMPARE_EXCHANGE_I4, "compare.exchange.i4", 5, 1, 3, InterpOpNoArgs)
OPDEF(INTOP_COMPARE_EXCHANGE_I8, "compare.exchange.i8", 5, 1, 3, InterpOpNoArgs)
OPDEF(INTOP_EXCHANGE_I4, "exchange.i4", 4, 1, 2, InterpOpNoArgs)
OPDEF(INTOP_EXCHANGE_I8, "exchange.i8", 4, 1, 2, InterpOpNoArgs)

// All instructions after this point are IROPS, instructions that are not emitted/executed
OPDEF(INTOP_NOP, "nop", 1, 0, 0, InterpOpNoArgs)
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/interpreter/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ NamedIntrinsic GetNamedIntrinsic(COMP_HANDLE compHnd, CORINFO_METHOD_HANDLE comp
{
if (!strcmp(methodName, "CompareExchange"))
return NI_System_Threading_Interlocked_CompareExchange;
else if (!strcmp(methodName, "Exchange"))
return NI_System_Threading_Interlocked_Exchange;
else if (!strcmp(methodName, "MemoryBarrier"))
return NI_System_Threading_Interlocked_MemoryBarrier;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/eeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ HRESULT EEConfig::sync()
#if defined(FEATURE_INTERPRETER)
if (fTieredCompilation)
{
// Disable tiered compilation for interpreter testing. Tiered compilation and interpreter
// Disable tiered compilation for interpreter testing. Tiered compilation and interpreter
// do not work well together currently.
LPWSTR pwzInterpreterMaybe;
IfFailThrow(CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_Interpreter, &pwzInterpreterMaybe));
Expand Down
34 changes: 34 additions & 0 deletions src/coreclr/vm/interpexec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
// Normal moves between vars
case INTOP_MOV_4: MOV(int32_t, int32_t); break;
case INTOP_MOV_8: MOV(int64_t, int64_t); break;
#undef MOV

case INTOP_MOV_VT:
memmove(stack + ip[1], stack + ip[2], ip[3]);
Expand Down Expand Up @@ -1016,6 +1017,7 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
case INTOP_BRTRUE_I8:
BR_UNOP(int64_t, != 0);
break;
#undef BR_UNOP

#define BR_BINOP_COND(cond) \
if (cond) \
Expand Down Expand Up @@ -1226,6 +1228,8 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
BR_BINOP_COND(isunordered(d1, d2) || d1 < d2);
break;
}
#undef BR_BINOP_COND
#undef BR_BINOP

case INTOP_ADD_I4:
LOCAL_VAR(ip[1], int32_t) = LOCAL_VAR(ip[2], int32_t) + LOCAL_VAR(ip[3], int32_t);
Expand Down Expand Up @@ -1682,6 +1686,7 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
case INTOP_CLT_UN_R8:
CMP_BINOP_FP(double, <, 1);
break;
#undef CMP_BINOP_FP

#define LDIND(dtype, ftype) \
do { \
Expand Down Expand Up @@ -1715,6 +1720,7 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
case INTOP_LDIND_R8:
LDIND(double, double);
break;
#undef LDIND
case INTOP_LDIND_VT:
{
char *src = LOCAL_VAR(ip[2], char*);
Expand Down Expand Up @@ -1757,6 +1763,7 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
case INTOP_STIND_R8:
STIND(double, double);
break;
#undef STIND
case INTOP_STIND_O:
{
char *dst = LOCAL_VAR(ip[1], char*);
Expand Down Expand Up @@ -2349,6 +2356,7 @@ do { \
LDELEM(double, double);
break;
}
#undef LDELEM
case INTOP_LDELEM_REF:
{
BASEARRAYREF arrayRef = LOCAL_VAR(ip[2], BASEARRAYREF);
Expand Down Expand Up @@ -2435,6 +2443,7 @@ do { \
STELEM(double, double);
break;
}
#undef STELEM
case INTOP_STELEM_REF:
{
BASEARRAYREF arrayRef = LOCAL_VAR(ip[1], BASEARRAYREF);
Expand Down Expand Up @@ -2613,6 +2622,31 @@ do \
COMPARE_EXCHANGE(int64_t);
break;
}
#undef COMPARE_EXCHANGE

#define EXCHANGE(type) \
do \
{ \
type* dst = LOCAL_VAR(ip[2], type*); \
NULL_CHECK(dst); \
type newValue = LOCAL_VAR(ip[3], type); \
type old = InterlockedExchangeT(dst, newValue); \
LOCAL_VAR(ip[1], type) = old; \
ip += 4; \
} while (0)

case INTOP_EXCHANGE_I4:
{
EXCHANGE(int32_t);
break;
}

case INTOP_EXCHANGE_I8:
{
EXCHANGE(int64_t);
break;
}
#undef EXCHANGE

case INTOP_CALL_FINALLY:
{
Expand Down
5 changes: 3 additions & 2 deletions src/coreclr/vm/prestub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2371,13 +2371,14 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo
pCode = DoBackpatch(pMT, pDispatchingMT, FALSE);

Return:
#if defined(FEATURE_INTERPRETER) && defined(FEATURE_JIT)
// Interpreter-FIXME: Call stubs are not yet supported on WASM
#if defined(FEATURE_INTERPRETER) && !defined(TARGET_WASM)
InterpByteCodeStart *pInterpreterCode = GetInterpreterCode();
if (pInterpreterCode != NULL)
{
CreateNativeToInterpreterCallStub(pInterpreterCode->Method);
}
#endif // FEATURE_INTERPRETER && FEATURE_JIT
#endif // FEATURE_INTERPRETER && !TARGET_WASM

RETURN pCode;
}
Expand Down
5 changes: 5 additions & 0 deletions src/mono/msbuild/apple/build/AppleBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@
</PropertyGroup>

<RemoveDir Directories="$(AppleBundleDir)" />

<!-- Copy static CoreCLR library for static linking scenarios. Tracking issue: https://github.com/dotnet/runtime/issues/116531 -->
<Copy SourceFiles="$(CoreCLRArtifactsPath)libcoreclr_static.a"
DestinationFiles="$(AppleBuildDir)libcoreclr_static.a"
Condition="'$(RuntimeFlavor)' == 'CoreCLR' and Exists('$(CoreCLRArtifactsPath)libcoreclr_static.a')" />
</Target>

<Target Name="_AppleResolveReferences">
Expand Down
2 changes: 1 addition & 1 deletion src/native/libs/System.Globalization.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI)
endif()

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ endif ()

install (TARGETS System.IO.Compression.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs)

if(CLR_CMAKE_HOST_ANDROID)
if(CLR_CMAKE_HOST_ANDROID OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_MACCATALYST)
install (TARGETS System.IO.Compression.Native-Static DESTINATION sharedFramework COMPONENT runtime)

foreach(BROTLI_LIB ${BROTLI_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion src/native/libs/System.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,6 @@ set_target_properties(System.Native-Static PROPERTIES OUTPUT_NAME System.Native

install (TARGETS System.Native-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs)

if(CLR_CMAKE_HOST_ANDROID)
if(CLR_CMAKE_HOST_ANDROID OR CLR_CMAKE_HOST_IOS OR CLR_CMAKE_HOST_TVOS OR CLR_CMAKE_HOST_MACCATALYST)
install (TARGETS System.Native-Static DESTINATION sharedFramework COMPONENT runtime)
endif()
10 changes: 7 additions & 3 deletions src/tasks/AppleAppBuilder/Xcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,20 @@ public string GenerateCMake(
toLink += $" \"-force_load {componentLibToLink}\"{Environment.NewLine}";
}

string[] dylibs = Directory.GetFiles(workspace, "*.dylib");
if (targetRuntime == TargetRuntime.CoreCLR)
{
foreach (string lib in dylibs)
// Interpreter-FIXME: CoreCLR on iOS currently supports only static linking.
// The build system needs to be updated to conditionally initialize the compiler at runtime based on an environment variable.
// Tracking issue: https://github.com/dotnet/runtime/issues/119006
string[] staticLibs = Directory.GetFiles(workspace, "*.a");
foreach (string lib in staticLibs)
{
toLink += $" \"-force_load {lib}\"{Environment.NewLine}";
toLink += $" \"{lib}\"{Environment.NewLine}";
}
}
else
{
string[] dylibs = Directory.GetFiles(workspace, "*.dylib");
// Sort the static libraries to link so the brotli libs are added to the list last (after the compression native libs)
List<string> staticLibsToLink = Directory.GetFiles(workspace, "*.a").OrderBy(libName => libName.Contains("brotli") ? 1 : 0).ToList();
foreach (string lib in staticLibsToLink)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,9 @@

public static class Program
{
[DllImport("__Internal")]
public static extern void mono_ios_set_summary(string value);

public static async Task<int> Main(string[] args)
public static int Main(string[] args)
{
mono_ios_set_summary($"Starting functional test");
int result = RunInterpreter();
Console.WriteLine("Done!");
await Task.Delay(5000);

return result;
}

[MethodImpl(MethodImplOptions.NoInlining)]
public unsafe static int RunInterpreter()
{
return 42;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
</PropertyGroup>

<ItemGroup>
<EnvironmentVariables Include="DOTNET_Interpreter=RunInterpreter" />
<EnvironmentVariables Include="DOTNET_InterpDump=RunInterpreter" />
<EnvironmentVariables Include="DOTNET_ReadyToRun=0" />
<EnvironmentVariables Include="DOTNET_InterpMode=3" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading