From 8ce55b03864353cd7566da5f4cb8433ec5c4580f Mon Sep 17 00:00:00 2001 From: Dong-Heon Jung Date: Wed, 18 May 2022 13:59:29 +0900 Subject: [PATCH] [Tizen] More R2R Compilation Compiles more methods which have IsAggressiveOptimization attribute. --- packaging/coreclr.spec | 10 ++++++---- src/coreclr/clrdefinitions.cmake | 3 +++ src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs | 4 ++++ src/coreclr/tools/Directory.Build.props | 3 +++ src/coreclr/vm/ecall.cpp | 8 ++++++++ src/coreclr/vm/jitinterface.cpp | 2 ++ src/coreclr/vm/method.hpp | 4 ++++ 7 files changed, 30 insertions(+), 4 deletions(-) diff --git a/packaging/coreclr.spec b/packaging/coreclr.spec index 53f7b84..2365b66 100755 --- a/packaging/coreclr.spec +++ b/packaging/coreclr.spec @@ -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 diff --git a/src/coreclr/clrdefinitions.cmake b/src/coreclr/clrdefinitions.cmake index 7dd2904..70ea088 100644 --- a/src/coreclr/clrdefinitions.cmake +++ b/src/coreclr/clrdefinitions.cmake @@ -199,6 +199,9 @@ endif(FEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION) add_definitions(-DFEATURE_SVR_GC) add_definitions(-DFEATURE_SYMDIFF) add_compile_definitions($<$>>: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($<$>>:FEATURE_ON_STACK_REPLACEMENT>) endif (CLR_CMAKE_TARGET_ARCH_AMD64) diff --git a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs index 182a87c..e78ef33 100644 --- a/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs +++ b/src/coreclr/tools/Common/TypeSystem/Ecma/EcmaMethod.cs @@ -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; diff --git a/src/coreclr/tools/Directory.Build.props b/src/coreclr/tools/Directory.Build.props index b8e4a4e..86c1f91 100644 --- a/src/coreclr/tools/Directory.Build.props +++ b/src/coreclr/tools/Directory.Build.props @@ -11,4 +11,7 @@ true DEBUG;$(DefineConstants) + + DISABLE_AGGRESSIVE_OPT;$(DefineConstants) + diff --git a/src/coreclr/vm/ecall.cpp b/src/coreclr/vm/ecall.cpp index 3dd1c44..349a78b 100644 --- a/src/coreclr/vm/ecall.cpp +++ b/src/coreclr/vm/ecall.cpp @@ -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 } diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 75d3160..5a16422 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -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()) diff --git a/src/coreclr/vm/method.hpp b/src/coreclr/vm/method.hpp index c929cbe..4ebb09d 100644 --- a/src/coreclr/vm/method.hpp +++ b/src/coreclr/vm/method.hpp @@ -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 -- 2.7.4