[Tizen] More R2R Compilation
authorDong-Heon Jung <clamp03@gmail.com>
Wed, 18 May 2022 04:59:29 +0000 (13:59 +0900)
committerDong-Heon Jung <clamp03@gmail.com>
Wed, 22 Jun 2022 09:25:09 +0000 (18:25 +0900)
Compiles more methods which have IsAggressiveOptimization attribute.

packaging/coreclr.spec
src/coreclr/clrdefinitions.cmake
src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs
src/coreclr/tools/Directory.Build.props
src/coreclr/vm/ecall.cpp
src/coreclr/vm/jitinterface.cpp
src/coreclr/vm/method.hpp

index 53f7b84..2365b66 100755 (executable)
@@ -318,19 +318,21 @@ export CXXFLAGS+="-fstack-protector-strong"
 %endif
 
 %define _source_version_flags /p:EnableSourceLink=false /p:DisableSourceLink=true /p:EnableSourceControlManagerQueries=false /p:EmbedUntrackedSources=false
-%define _build_args --keepnativesymbols true --arch %{_barch} --runtimeConfiguration %{dotnet_buildtype_clr} --librariesConfiguration %{dotnet_buildtype_fx} %{_source_version_flags}
+%define _build_args --keepnativesymbols true --arch %{_barch} --runtimeConfiguration %{dotnet_buildtype_clr} --librariesConfiguration %{dotnet_buildtype_fx} %{_source_version_flags} /p:DisableAggressiveOpt=true
 %define _build_args_release --keepnativesymbols true --arch %{_barch} --runtimeConfiguration Release --librariesConfiguration Release %{_source_version_flags}
+%define _native_opts --cmakeargs -DDISABLE_AGGRESSIVE_OPT=true
+%define _managed_opts -p:DefineConstants=DISABLE_AGGRESSIVE_OPT
 
 export NUGET_PACKAGES=%{_builddir}/%{name}-%{version}/.packages/
 export LD_LIBRARY_PATH=%{_builddir}/%{name}-%{version}/libicu-57.1/
 
 # Build native CoreCLR and native CoreFX
-./build.sh --portablebuild false %{_build_args} --subset clr.runtime+clr.jit+clr.iltools+libs.native --cmakeargs -DFEATURE_IBCLOGGER=true --cmakeargs -DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION=true --cmakeargs -DCLR_ADDITIONAL_LINKER_FLAGS=-Wl,-z,relro %{_pgo_flags}
+./build.sh --portablebuild false %{_build_args} --subset clr.runtime+clr.jit+clr.iltools+libs.native --cmakeargs -DFEATURE_IBCLOGGER=true --cmakeargs -DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION=true --cmakeargs -DCLR_ADDITIONAL_LINKER_FLAGS=-Wl,-z,relro %{_pgo_flags} %{_native_opts}
 
 %ifarch x86_64
 # Publish crossgen2 as a single file with self-contained
 ./build.sh --portablebuild false %{_build_args} --subset clr.alljits --cmakeargs -DFEATURE_IBCLOGGER=true --cmakeargs -DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION=true --cmakeargs -DCLR_ADDITIONAL_LINKER_FLAGS=-Wl,-z,relro %{_pgo_flags}
-./.dotnet/dotnet publish --self-contained true -r linux-%{_barch} ./src/coreclr/tools/aot/crossgen2/crossgen2.csproj -c %{dotnet_buildtype_clr} -p:PublishSingleFile=true
+./.dotnet/dotnet publish --self-contained true -r linux-%{_barch} ./src/coreclr/tools/aot/crossgen2/crossgen2.csproj -c %{dotnet_buildtype_clr} -p:PublishSingleFile=true %{_managed_opts}
 %endif
 
 %if 0%{skipmscorlib}
@@ -364,7 +366,7 @@ export LD_LIBRARY_PATH=%{_builddir}/%{name}-%{version}/libicu-57.1/
 # Build Release CoreCLR & CoreFX (these are required for some tests)
 
 # Build native CoreCLR and native CoreFX
-./build.sh --portablebuild false %{_build_args_release} --subset clr.runtime+clr.jit+clr.iltools+libs.native --cmakeargs -DFEATURE_IBCLOGGER=true --cmakeargs -DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION=true --cmakeargs -DCLR_ADDITIONAL_LINKER_FLAGS=-Wl,-z,relro %{_pgo_flags}
+./build.sh --portablebuild false %{_build_args_release} --subset clr.runtime+clr.jit+clr.iltools+libs.native --cmakeargs -DFEATURE_IBCLOGGER=true --cmakeargs -DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION=true --cmakeargs -DCLR_ADDITIONAL_LINKER_FLAGS=-Wl,-z,relro %{_pgo_flags} %{_native_opts}
 
 # Build mscorlib (System.Private.CoreLib.dll)
 ./build.sh --portablebuild false %{_build_args_release} --subset clr.corelib
index 7dd2904..70ea088 100644 (file)
@@ -199,6 +199,9 @@ endif(FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION)
 add_definitions(-DFEATURE_SVR_GC)
 add_definitions(-DFEATURE_SYMDIFF)
 add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_TIERED_COMPILATION>)
+if(DISABLE_AGGRESSIVE_OPT)
+    add_definitions(-DDISABLE_AGGRESSIVE_OPT)
+endif(DISABLE_AGGRESSIVE_OPT)
 if (CLR_CMAKE_TARGET_ARCH_AMD64)
    add_compile_definitions($<$<NOT:$<BOOL:$<TARGET_PROPERTY:CROSSGEN_COMPONENT>>>:FEATURE_ON_STACK_REPLACEMENT>)
 endif (CLR_CMAKE_TARGET_ARCH_AMD64)
index 182a87c..e78ef33 100644 (file)
@@ -149,14 +149,18 @@ namespace Internal.TypeSystem.Ecma
                 if ((methodImplAttributes & MethodImplAttributes.NoInlining) != 0)
                     flags |= MethodFlags.NoInlining;
 
+#if !DISABLE_AGGRESSIVE_OPT
                 // System.Reflection.Primitives we build against doesn't define AggressiveOptimization
                 const MethodImplAttributes MethodImplAttributes_AggressiveOptimization = (MethodImplAttributes)0x0200;
+#endif
 
                 // No optimization bit beats aggressive optimization bit (CLR compatible behavior)
                 if ((methodImplAttributes & MethodImplAttributes.NoOptimization) != 0)
                     flags |= MethodFlags.NoOptimization;
+#if !DISABLE_AGGRESSIVE_OPT
                 else if ((methodImplAttributes & MethodImplAttributes_AggressiveOptimization) != 0)
                     flags |= MethodFlags.AggressiveOptimization;
+#endif
 
                 if ((methodImplAttributes & MethodImplAttributes.AggressiveInlining) != 0)
                     flags |= MethodFlags.AggressiveInlining;
index b8e4a4e..86c1f91 100644 (file)
@@ -11,4 +11,7 @@
     <Optimize Condition="'$(Optimize)' == ''">true</Optimize>
     <DefineConstants>DEBUG;$(DefineConstants)</DefineConstants>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(DisableAggressiveOpt)' == 'true'">
+    <DefineConstants>DISABLE_AGGRESSIVE_OPT;$(DefineConstants)</DefineConstants>
+  </PropertyGroup>
 </Project>
index 3dd1c44..349a78b 100644 (file)
@@ -167,17 +167,25 @@ void ECall::PopulateManagedCastHelpers()
     //      see: https://github.com/dotnet/runtime/issues/5857
 
     pMD = CoreLibBinder::GetMethod((BinderMethodID)(METHOD__CASTHELPERS__STELEMREF));
+#ifdef DISABLE_AGGRESSIVE_OPT
+    pDest = pMD->GetMultiCallableAddrOfCode();
+#else // DISABLE_AGGRESSIVE_OPT
     pMD->DoPrestub(NULL);
     // This helper is marked AggressiveOptimization and its native code is in its final form.
     // Get the code directly to avoid PreStub indirection.
     pDest = pMD->GetNativeCode();
+#endif // DISABLE_AGGRESSIVE_OPT
     SetJitHelperFunction(CORINFO_HELP_ARRADDR_ST, pDest);
 
     pMD = CoreLibBinder::GetMethod((BinderMethodID)(METHOD__CASTHELPERS__LDELEMAREF));
+#ifdef DISABLE_AGGRESSIVE_OPT
+    pDest = pMD->GetMultiCallableAddrOfCode();
+#else // DISABLE_AGGRESSIVE_OPT
     pMD->DoPrestub(NULL);
     // This helper is marked AggressiveOptimization and its native code is in its final form.
     // Get the code directly to avoid PreStub indirection.
     pDest = pMD->GetNativeCode();
+#endif  // DISABLE_AGGRESSIVE_OPT
     SetJitHelperFunction(CORINFO_HELP_LDELEMA_REF, pDest);
 #endif  //CROSSGEN_COMPILE
 }
index 75d3160..5a16422 100644 (file)
@@ -6817,6 +6817,7 @@ DWORD CEEInfo::getMethodAttribsInternal (CORINFO_METHOD_HANDLE ftn)
 
     // Check for the aggressive optimization directive. AggressiveOptimization only makes sense for IL methods.
     DWORD ilMethodImplAttribs = 0;
+#ifndef DISABLE_AGGRESSIVE_OPT
     if (pMD->IsIL())
     {
         ilMethodImplAttribs = pMD->GetImplAttrs();
@@ -6825,6 +6826,7 @@ DWORD CEEInfo::getMethodAttribsInternal (CORINFO_METHOD_HANDLE ftn)
             result |= CORINFO_FLG_AGGRESSIVE_OPT;
         }
     }
+#endif // !DISABLE_AGGRESSIVE_OPT
 
     // Check for an inlining directive.
     if (pMD->IsNotInline())
index c929cbe..4ebb09d 100644 (file)
@@ -1416,9 +1416,13 @@ public:
     {
         WRAPPER_NO_CONTRACT;
 
+#ifndef DISABLE_AGGRESSIVE_OPT
         return
             IsIL() && // only makes sense for IL methods, and this implies !IsNoMetadata()
             IsMiAggressiveOptimization(GetImplAttrs());
+#else
+        return false;
+#endif // !DISABLE_AGGRESSIVE_OPT
     }
 
     // Does this method force the NativeCodeSlot to stay fixed after it