-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Milestone
Description
Description
When inspecting MSIL code generated by Dependency Injection dynamic compilation using ILEmit, everytime there is a ldloca.s instruction, 3 nop operations are also generated.
Configuration
- Which version of .NET is the code running on? .NET Framework 4.62
- What OS and version, and what distro if applicable? Windows 11 (22000.194)
- What is the architecture (x64, x86, ARM, ARM64)? x64
Other information
To reproduce the issue, compile Microsoft.Extensions.DependencyInjection using SAVE_ASSEMBLIES symbol. Then run ServiceProviderILEmitContainerTests.ScopedServiceCanBeResolved and inspect MSIL code in artifacts\bin\Microsoft.Extensions.DependencyInjection.Tests\net462-*\Test*.dll
[...]
IL_0047: ldloc.2 // sync
IL_0048: ldloca.s lockTaken
IL_004a: nop
IL_004b: nop
IL_004c: nop
IL_004d: call void [mscorlib]System.Threading.Monitor::Enter(object, bool&)
IL_0052: ldloc.1 // resolvedServices
IL_0053: ldloc.0 // key
IL_0054: ldloca.s service
IL_0056: nop
IL_0057: nop
IL_0058: nop
IL_0059: callvirt instance bool class [mscorlib]System.Collections.Generic.IDictionary`2<valuetype [Microsoft.Extensions.DependencyInjection]Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCacheKey, object>::TryGetValue(!0/*valuetype [Microsoft.Extensions.DependencyInjection]Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCacheKey*/, !1/*object*/&)
IL_005e: brtrue IL_007c
[...]