TargetedPatchingOptOut: quot;Performance critical to inline across NGen image boundariesquot;?(TargetedPatchingOptOut:“性能对跨 NGen 图像边界内联至关重要?)
问题描述
浏览了一些使用反射器的框架类,注意到一些方法和属性具有以下属性
Been going through some framework classes using reflector and noticed a number of the methods and properties have the following attribute
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
我很确定我在其他地方也看到过上述评论,但从未跟进.
I'm pretty sure I have also seen the above comment somewhere else and never followed it up.
谁能告诉我这在 C# 和任何其他上下文中意味着什么?
Could someone please tell me what this means in the C# and any other context?
推荐答案
它告诉 NGen 即使在不同的程序集中也可以内联它所应用的方法.
It tells NGen that it is OK to inline the method it's applied to even in a different assembly.
例如:
String.Equals有[TargetedPatchingOptOut]- 您编写了一个调用
String.Equals 的程序 - 您运行 NGen这个程序以获得最佳性能
- NGen 将内联
String.Equals调用,将方法调用指令替换为方法中的实际代码.
方法调用(稍微)昂贵,因此对于经常调用的方法来说,这是一种性能提升.
String.Equalshas[TargetedPatchingOptOut]- You write a program that calls
String.Equals - You run NGen on this program for maximum performance
- NGen will inline the
String.Equalscall, replacing the method call instruction with the actual code in the method.
Method calls are (slightly) expensive, so this is a performance boost for frequently-called methods.
但是,如果 Microsoft 在 String.Equals 中发现安全漏洞,他们不能只更新 mscorlib.dll,因为这不会影响您刚刚 NGen 的程序集'd.(因为它具有未引用 String.Equals 的原始机器代码).
我假设如果这真的发生了,安全更新会清除 NGen 存储.
However, if Microsoft finds a security hole in String.Equals, they cannot just update mscorlib.dll, because that won't affect the assembly that you just NGen'd. (Since it has raw machine code without referencing String.Equals).
I assume that if that were to actually happen, the security update would clear the NGen store.
请注意,此属性仅在 .NET Framework 程序集中有用.你自己不需要它.您可以在此处找到更多信息:https://stackoverflow.com/a/14982340/631802
Note that this attribute is only useful in the .NET Framework assemblies. You don't need it in your own. You can find more information about that here: https://stackoverflow.com/a/14982340/631802
这篇关于TargetedPatchingOptOut:“性能对跨 NGen 图像边界内联至关重要"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:TargetedPatchingOptOut:“性能对跨 NGen 图像边界内联至关重要"?
基础教程推荐
- C# 从 List<List<int>> 中删除重 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- WPF 模态进度窗口 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
