Skip to content

Commit

Permalink
feat: Disable gsharedvt by default, add EnableAotGSharedVT to restore it
Browse files Browse the repository at this point in the history
gsharedvt enabled reduces AOT Dictionary<,> by 2.5x times, since net7.
  • Loading branch information
jeromelaban committed Mar 30, 2022
1 parent 2ffad97 commit d730c18
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/Uno.Wasm.Bootstrap/ShellTask.cs
Expand Up @@ -193,6 +193,10 @@ public partial class ShellTask_v0 : Microsoft.Build.Utilities.Task

public bool EnableAOTDeduplication { get; set; } = true;

public bool EnableAotGSharedVT { get; set; } = false;

public string? AotCompilerOptions { get; set; }

public bool GenerateAOTProfile { get; set; } = false;

public string? NinjaAdditionalParameters { get; set; }
Expand Down Expand Up @@ -811,6 +815,11 @@ private void RunPackager()
referencePathsParameter += $" \"{AlignPath(aotProfilerSupport)}\"";
}

if(string.IsNullOrEmpty(AotCompilerOptions) && EnableAotGSharedVT)
{
AotCompilerOptions = $"-O=gsharedvt";
}

if (EnableLogProfiler)
{
var logProfilerSupport = Path.Combine(BuildTaskBasePath, "..", "tools", "support", "Uno.Wasm.LogProfiler.dll");
Expand All @@ -829,6 +838,7 @@ private void RunPackager()
packagerParams.Add($"--runtime-config={RuntimeConfiguration} ");
packagerParams.Add(aotOptions);
packagerParams.Add(aotProfile);
packagerParams.Add($"--aot-compiler-opts=\"{AotCompilerOptions}\"");
packagerParams.Add(EmccLinkOptimization ? "--emcc-link-optimization" : "");
packagerParams.Add(MonoILLinker ? "--linker --link-mode=all" : "");
packagerParams.Add(referencePathsParameter);
Expand Down
2 changes: 2 additions & 0 deletions src/Uno.Wasm.Bootstrap/build/Uno.Wasm.Bootstrap.targets
Expand Up @@ -213,6 +213,8 @@
GenerateAOTProfile="$(WasmShellGenerateAOTProfile)"
AotProfile="@(WasmShellEnableAotProfile)"
AOTProfileExcludedMethods="$(WasmShellAOTProfileExcludedMethods)"
EnableAotGSharedVT="$(WasmShellEnableAotGSharedVT)"
AotCompilerOptions="$(WasmShellAotCompilerOptions)"
GenerateAOTProfileDebugList="$(WasmShellGenerateAOTProfileDebugList)"
EnableLogProfiler="$(WasmShellEnableLogProfiler)"
LogProfilerOptions="$(WasmShellLogProfilerOptions)"
Expand Down
7 changes: 5 additions & 2 deletions src/Uno.Wasm.Packager/packager.cs
Expand Up @@ -142,6 +142,7 @@ enum AssemblyKind {
Console.WriteLine ("\t--runtime-config=x sets the mono runtime to use (defaults to release).");
Console.WriteLine ("\t--aot-assemblies=x List of assemblies to AOT in AOT+INTERP mode.");
Console.WriteLine ("\t--skip-aot-assemblies=x List of assemblies to skip AOT in AOT+INTERP mode.");
Console.WriteLine ("\t--aot-compiler-opts=x Adjust aot compiler options.");
Console.WriteLine ("\t--aot-profile=x Use 'x' as the AOT profile.");
Console.WriteLine ("\t--link-mode=sdkonly|all Set the link type used for AOT. (EXPERIMENTAL)");
Console.WriteLine ("\t--pinvoke-libs=x DllImport libraries used.");
Expand Down Expand Up @@ -457,6 +458,7 @@ class WasmOptions {
var runtimepack_dir = "";
string coremode, usermode;
string aot_profile = null;
string aot_compiler_options = "";
string wasm_runtime_path = null;
var runtime_config = "release";
string extra_emccflags = "";
Expand Down Expand Up @@ -504,6 +506,7 @@ class WasmOptions {
{ "aot-profile=", s => aot_profile = s },
{ "runtime-config=", s => runtime_config = s },
{ "skip-aot-assemblies=", s => skip_aot_assemblies = s },
{ "aot-compiler-opts=", s => aot_compiler_options = s },
{ "link-mode=", s => linkModeParm = s },
{ "link-descriptor=", s => linkDescriptor = s },
{ "pinvoke-libs=", s => pinvoke_libs = s },
Expand Down Expand Up @@ -1160,10 +1163,10 @@ class WasmOptions {

// Rules
ninja.WriteLine ("rule aot");
ninja.WriteLine ($" command = {aot_cross_prefix} $cross --debug {profiler_aot_args} -O=gsharedvt --aot=$aot_args,$aot_base_args,depfile=$depfile,llvm-outfile=$outfile $src_file");
ninja.WriteLine ($" command = {aot_cross_prefix} $cross --debug {profiler_aot_args} {aot_compiler_options} --aot=$aot_args,$aot_base_args,depfile=$depfile,llvm-outfile=$outfile $src_file");
ninja.WriteLine (" description = [AOT] $src_file -> $outfile");
ninja.WriteLine ("rule aot-instances");
ninja.WriteLine ($" command = {aot_cross_prefix} $cross --debug {profiler_aot_args} -O=gsharedvt --aot=$aot_base_args,llvm-outfile=$outfile,dedup-include=$dedup_image $src_files");
ninja.WriteLine ($" command = {aot_cross_prefix} $cross --debug {profiler_aot_args} {aot_compiler_options} --aot=$aot_base_args,llvm-outfile=$outfile,dedup-include=$dedup_image $src_files");
ninja.WriteLine (" description = [AOT-INSTANCES] $outfile");
ninja.WriteLine ("rule mkdir");

Expand Down

0 comments on commit d730c18

Please sign in to comment.