Enable selecting the sgen major mode (#1546)

* [mmp/mtouch] Add option for concurrent sgen

* [msbuild] Add support for concurrent sgen properties

* [mmp] Test for concurrent sgen option
This commit is contained in:
Vlad Brezae 2017-01-24 08:28:15 +02:00 коммит произвёл Rolf Bjarne Kvinge
Родитель 0b37471271
Коммит cd9292ffdd
11 изменённых файлов: 45 добавлений и 7 удалений

Просмотреть файл

@ -58,6 +58,9 @@ namespace Xamarin.Mac.Tasks
public bool IsAppExtension { get; set; }
[Required]
public bool EnableSGenConc { get; set; }
public bool UseXamMacFullFramework { get; set; }
public string ApplicationName { get; set; }
@ -150,6 +153,9 @@ namespace Xamarin.Mac.Tasks
if (Profiling)
args.Add ("/profiling");
if (EnableSGenConc)
args.Add ("/sgen-conc");
switch ((LinkMode ?? string.Empty).ToLower ()) {
case "full":
break;
@ -240,6 +246,7 @@ namespace Xamarin.Mac.Tasks
Log.LogTaskProperty ("Architecture", Architecture);
Log.LogTaskProperty ("ArchiveSymbols", ArchiveSymbols);
Log.LogTaskProperty ("Debug", Debug);
Log.LogTaskProperty ("EnableSGenConc", EnableSGenConc);
Log.LogTaskProperty ("ExplicitReferences", ExplicitReferences);
Log.LogTaskProperty ("ExtraArguments", ExtraArguments);
Log.LogTaskProperty ("FrameworkRoot", FrameworkRoot);

Просмотреть файл

@ -54,6 +54,7 @@ Copyright (C) 2013-2014 Xamarin. All rights reserved.
<MonoMacResourcePrefix Condition="'$(MonoMacResourcePrefix)' == ''">Resources</MonoMacResourcePrefix>
<XamMacResourcePrefix Condition="'$(XamMacResourcePrefix)' == ''">$(MonoMacResourcePrefix)</XamMacResourcePrefix>
<IsAppExtension Condition="'$(IsAppExtension)' == ''">False</IsAppExtension>
<EnableSGenConc Condition="'$(EnableSGenConc)' == ''">false</EnableSGenConc>
</PropertyGroup>
<PropertyGroup>

Просмотреть файл

@ -536,7 +536,8 @@ Copyright (C) 2014 Xamarin. All rights reserved.
IntermediateOutputPath="$(IntermediateOutputPath)mmp-cache"
AppManifest="$(_AppManifest)"
SdkVersion="$(MacOSXSdkVersion)"
IsAppExtension="$(IsAppExtension)">
IsAppExtension="$(IsAppExtension)"
EnableSGenConc="$(EnableSGenConc)">
<Output TaskParameter="NativeLibraries" ItemName="_NativeLibrary" />
</Mmp>
</Target>

Просмотреть файл

@ -106,6 +106,9 @@ namespace Xamarin.iOS.Tasks
public ITaskItem[] LinkDescriptions { get; set; }
[Required]
public bool EnableSGenConc { get; set; }
[Required]
public bool LinkerDumpDependencies { get; set; }
@ -400,6 +403,9 @@ namespace Xamarin.iOS.Tasks
if (LinkerDumpDependencies)
args.Add ("--linkerdumpdependencies");
if (EnableSGenConc)
args.Add ("--sgen-conc");
switch (LinkMode.ToLowerInvariant ()) {
case "sdkonly": args.Add ("--linksdkonly"); break;
case "none": args.Add ("--nolink"); break;
@ -638,6 +644,7 @@ namespace Xamarin.iOS.Tasks
Log.LogTaskProperty ("CompiledEntitlements", CompiledEntitlements);
Log.LogTaskProperty ("Debug", Debug);
Log.LogTaskProperty ("EnableGenericValueTypeSharing", EnableGenericValueTypeSharing);
Log.LogTaskProperty ("EnableSGenConc", EnableSGenConc);
Log.LogTaskProperty ("Entitlements", Entitlements);
Log.LogTaskProperty ("ExecutableName", ExecutableName);
Log.LogTaskProperty ("ExtraArgs", ExtraArgs);

Просмотреть файл

@ -49,6 +49,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
<MtouchEnableBitcode Condition="'$(MtouchEnableBitcode)' == ''">False</MtouchEnableBitcode>
<MtouchUseThumb Condition="'$(MtouchUseThumb)' == ''">False</MtouchUseThumb>
<MtouchProjectDirectory>$(MSBuildProjectDirectory)</MtouchProjectDirectory>
<MtouchEnableSGenConc Condition="'$(MtouchEnableSGenConc)' == ''">False</MtouchEnableSGenConc>
<IsMacEnabled>true</IsMacEnabled>
<MtouchTargetsEnabled>$(IsMacEnabled)</MtouchTargetsEnabled>

Просмотреть файл

@ -747,6 +747,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
UseFloat32="$(MtouchFloat32)"
UseThumb="$(MtouchUseThumb)"
EnableBitcode="$(MtouchEnableBitcode)"
EnableSGenConc="$(MtouchEnableSGenConc)"
AppExtensionReferences="@(_ResolvedAppExtensionReferences)"
ArchiveSymbols="$(MonoSymbolArchive)"
Verbosity="$(MtouchVerbosity)"

Просмотреть файл

@ -427,6 +427,17 @@ namespace Xamarin.MMP.Tests
});
}
[Test]
public void Unified_SgenConcurrent_Test ()
{
RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) {
CSProjConfig = "<MonoBundlingExtraArgs>--sgen-conc</MonoBundlingExtraArgs>"
};
TI.TestUnifiedExecutable (test);
});
}
[Test]
public void Unified_ShouldGenerateMachineConfigInBundle_WithEmptyOption ()
{

Просмотреть файл

@ -55,6 +55,7 @@ namespace Xamarin.Bundler {
public Mono.Linker.I18nAssemblies I18n;
public bool? EnableCoopGC;
public bool EnableSGenConc;
public MarshalObjectiveCExceptionMode MarshalObjectiveCExceptions;
public MarshalManagedExceptionMode MarshalManagedExceptions;
public bool IsDefaultMarshalManagedExceptionMode;

Просмотреть файл

@ -21,6 +21,7 @@ namespace Xamarin.Bundler {
static void AddSharedOptions (Application app, Mono.Options.OptionSet options)
{
options.Add ("coop:", "If the GC should run in cooperative mode.", v => { app.EnableCoopGC = ParseBool (v, "coop"); }, hidden: true);
options.Add ("sgen-conc", "Enable the concurrent garbage collector.", v => { app.EnableSGenConc = true; });
options.Add ("marshal-objectivec-exceptions:", "Specify how Objective-C exceptions should be marshalled. Valid values: default, unwindmanagedcode, throwmanagedexception, abort and disable. The default depends on the target platform (on watchOS the default is 'throwmanagedexception', while on all other platforms it's 'disable').", v => {
switch (v) {
case "default":

Просмотреть файл

@ -1080,6 +1080,11 @@ namespace Xamarin.Bundler {
if (App.EnableDebug)
sw.WriteLine ("\txamarin_debug_mode = TRUE;");
if (App.EnableSGenConc)
sw.WriteLine ("\tsetenv (\"MONO_GC_PARAMS\", \"major=marksweep-conc\", 1);");
else
sw.WriteLine ("\tsetenv (\"MONO_GC_PARAMS\", \"major=marksweep\", 1);");
if (aot.IsAOT)
sw.WriteLine ("\txamarin_mac_aot = TRUE;");

Просмотреть файл

@ -242,16 +242,18 @@ namespace Xamarin.Bundler {
public string MonoGCParams {
get {
// Configure sgen to use a small nursery
if (IsTodayExtension) {
return "nursery-size=512k,soft-heap-limit=8m";
} else if (Platform == ApplePlatform.WatchOS) {
string ret = "nursery-size=512k";
if (IsTodayExtension || Platform == ApplePlatform.WatchOS) {
// A bit test shows different behavior
// Sometimes apps are killed with ~100mb allocated,
// but I've seen apps allocate up to 240+mb as well
return "nursery-size=512k,soft-heap-limit=8m";
} else {
return "nursery-size=512k";
ret += ",soft-heap-limit=8m";
}
if (EnableSGenConc)
ret += ",major=marksweep-conc";
else
ret += ",major=marksweep";
return ret;
}
}