Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enables the interpreter on iOS #44911

Merged
merged 4 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
MonoRuntimeHeaders="$(MicrosoftNetCoreAppRuntimePackNativeDir)include\mono-2.0"
Assemblies="@(BundleAssemblies)"
MainLibraryFileName="AppleTestRunner.dll"
ForceInterpreter="$(MonoForceInterpreter)"
UseConsoleUITemplate="True"
GenerateXcodeProject="True"
BuildAppBundle="True"
Expand Down
7 changes: 2 additions & 5 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,7 @@
</ItemGroup>
<!-- iOS device specific options -->
<ItemGroup Condition="'$(TargetsiOS)' == 'true' and '$(TargetsiOSSimulator)' != 'true'">
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=ssa,com,interpreter,jit,portability,assembly_remapping,attach,verifier,appdomains,security,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging,remoting,shared_perfcounters,gac,eventpipe" />
<_MonoCMakeArgs Include="-DENABLE_INTERP_LIB=1"/>
<_MonoCMakeArgs Include="-DDISABLE_ICALL_TABLES=1"/>
<_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=0"/>
<_MonoCMakeArgs Include="-DENABLE_MINIMAL=ssa,com,jit,portability,assembly_remapping,attach,verifier,appdomains,security,sgen_remset,sgen_marksweep_par,sgen_marksweep_fixed,sgen_marksweep_fixed_par,sgen_copying,logging,remoting,shared_perfcounters,gac,eventpipe" />
<_MonoCMakeArgs Include="-DENABLE_VISIBILITY_HIDDEN=1"/>
<_MonoCMakeArgs Include="-DENABLE_LAZY_GC_THREAD_CREATION=1"/>
<_MonoCMakeArgs Include="-DENABLE_SIGALTSTACK=0"/>
Expand Down Expand Up @@ -419,7 +416,7 @@
<_MonoRuntimeFilePath Condition="'$(TargetsBrowser)' == 'true'">$(MonoObjDir)out\lib\libmonosgen-2.0.a</_MonoRuntimeFilePath>
<_MonoRuntimeFilePath Condition="'$(_MonoRuntimeFilePath)' == ''">$(MonoObjDir)out\lib\libmonosgen-2.0.so</_MonoRuntimeFilePath>
<_MonoRuntimeStaticFilePath Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true'">$(MonoObjDir)out\lib\libmonosgen-2.0.a</_MonoRuntimeStaticFilePath>
<_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true' or ('$(TargetsiOS)' == 'true' and '$(TargetsiOSSimulator)' != 'true')">true</_MonoIncludeInterpStaticFiles>
<_MonoIncludeInterpStaticFiles Condition="'$(TargetsBrowser)' == 'true'">true</_MonoIncludeInterpStaticFiles>
</PropertyGroup>
<PropertyGroup Condition="'$(BuildMonoAOTCrossCompiler)' == 'true'">
<_MonoAotCrossFilePath >$(MonoObjDir)cross\out\bin\mono-sgen</_MonoAotCrossFilePath>
Expand Down
1 change: 1 addition & 0 deletions src/mono/netcore/sample/iOS/Program.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
OutputDirectory="$(AppDir)"
Optimized="$(Optimized)"
UseAotForSimulator="$(UseAotForSimulator)"
ForceInterpreter="$(MonoForceInterpreter)"
AppDir="$(MSBuildThisFileDirectory)$(PublishDir)">
<Output TaskParameter="AppBundlePath" PropertyName="AppBundlePath" />
<Output TaskParameter="XcodeProjectPath" PropertyName="XcodeProjectPath" />
Expand Down
1 change: 0 additions & 1 deletion src/native/eventpipe/ds-ipc-posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ ipc_init_listener (
result_bind = bind (server_socket, server_address, server_address_len);
DS_EXIT_BLOCKING_PAL_SECTION;

EP_ASSERT (result_bind != -1);
if (result_bind == -1) {
if (callback)
callback (strerror (errno), errno);
Expand Down
14 changes: 12 additions & 2 deletions tools-local/tasks/mobile.tasks/AppleAppBuilder/AppleAppBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public class AppleAppBuilderTask : Task
/// </summary>
public bool UseAotForSimulator { get; set; }

/// <summary>
/// Forces the runtime to use the interpreter
/// </summary>
public bool ForceInterpreter { get; set; }

/// <summary>
/// Path to xcode project
/// </summary>
Expand Down Expand Up @@ -149,15 +154,20 @@ public override bool Execute()
}
}

if ((isDevice || UseAotForSimulator) && !assemblerFiles.Any())
if (((!ForceInterpreter && (isDevice || UseAotForSimulator)) && !assemblerFiles.Any()))
{
throw new InvalidOperationException("Need list of AOT files for device builds.");
}

if (ForceInterpreter && UseAotForSimulator)
{
throw new InvalidOperationException("Interpreter and AOT cannot be enabled at the same time");
}

if (GenerateXcodeProject)
{
XcodeProjectPath = Xcode.GenerateXCode(ProjectName, MainLibraryFileName, assemblerFiles,
AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, UseAotForSimulator, Optimized, NativeMainSource);
AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, UseAotForSimulator, ForceInterpreter, Optimized, NativeMainSource);

if (BuildAppBundle)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
//%DllMap%
}

#if TARGET_OS_IPHONE && (!TARGET_IPHONE_SIMULATOR || USE_AOT_FOR_SIMULATOR)
#if FORCE_INTERPRETER || (TARGET_OS_IPHONE && (!TARGET_IPHONE_SIMULATOR || USE_AOT_FOR_SIMULATOR))
void mono_jit_set_aot_mode (MonoAotMode mode);
void register_aot_modules (void);
#endif
Expand Down Expand Up @@ -228,7 +228,10 @@
// TODO: set TRUSTED_PLATFORM_ASSEMBLIES, APP_PATHS and NATIVE_DLL_SEARCH_DIRECTORIES
monovm_initialize(0, NULL, NULL);

#if TARGET_OS_IPHONE && (!TARGET_IPHONE_SIMULATOR || USE_AOT_FOR_SIMULATOR)
#if FORCE_INTERPRETER
os_log_info (OS_LOG_DEFAULT, "INTERP Enabled");
mono_jit_set_aot_mode (MONO_AOT_MODE_INTERP_ONLY);
#elif TARGET_OS_IPHONE && (!TARGET_IPHONE_SIMULATOR || USE_AOT_FOR_SIMULATOR)
register_dllmap ();
// register modules
register_aot_modules ();
Expand All @@ -249,7 +252,7 @@
}
mono_jit_init_version ("dotnet.ios", "mobile");

#if TARGET_OS_IPHONE && (!TARGET_IPHONE_SIMULATOR || USE_AOT_FOR_SIMULATOR)
#if !FORCE_INTERPRETER && TARGET_OS_IPHONE && (!TARGET_IPHONE_SIMULATOR || USE_AOT_FOR_SIMULATOR)
// device runtimes are configured to use lazy gc thread creation
MONO_ENTER_GC_UNSAFE;
mono_gc_init_finalizer_thread ();
Expand Down
14 changes: 12 additions & 2 deletions tools-local/tasks/mobile.tasks/AppleAppBuilder/Xcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static string GenerateXCode(
bool preferDylibs,
bool useConsoleUiTemplate,
bool useAotForSimulator,
bool forceInterpreter,
bool stripDebugSymbols,
string? nativeMainSource = null)
{
Expand Down Expand Up @@ -86,8 +87,17 @@ public static string GenerateXCode(
cmakeLists = cmakeLists.Replace("%NativeLibrariesToLink%", toLink);
cmakeLists = cmakeLists.Replace("%AotSources%", aotSources);
cmakeLists = cmakeLists.Replace("%AotModulesSource%", string.IsNullOrEmpty(aotSources) ? "" : "modules.m");
cmakeLists = cmakeLists.Replace("%Defines%",
useAotForSimulator ? "add_definitions(-DUSE_AOT_FOR_SIMULATOR=1)" : "");

string defines = "";
if (forceInterpreter)
{
defines = "add_definitions(-DFORCE_INTERPRETER=1)";
}
else if (useAotForSimulator)
{
defines = "add_definitions(-DUSE_AOT_FOR_SIMULATOR=1)";
}
cmakeLists = cmakeLists.Replace("%Defines%", defines);

string plist = Utils.GetEmbeddedResource("Info.plist.template")
.Replace("%BundleIdentifier%", projectName);
Expand Down