ILGenerator,对返回值null进行决策
il.Emit(OpCodes.Callvirt, _compactBinaryReader_ReadObject);
调用此函数并在特殊条件下提供返回值“null”。
之后决定是否跳转到标签或不
如果该值为空,我必须在方法
il.Emit(OpCodes.Dup);
il.Emit(OpCodes.Brfalse_S, DECISION);
调用给我一个异常“JIT 编译器遇到内部限制” 使用。当我调用该函数时,代码会正确构建。
也尝试过 OpCodes.Brfalse 。
我做错了什么?
il.Emit(OpCodes.Callvirt, _compactBinaryReader_ReadObject);
this function is called and at a special condition a return value of 'null' is provided.
if that value is null i have to take a decision whether to jump on to a label or not
using after the method call
il.Emit(OpCodes.Dup);
il.Emit(OpCodes.Brfalse_S, DECISION);
gives me an exception "JIT Compiler encountered an internal limitation." when i call that function, the code builds correctly though.
tried OpCodes.Brfalse too.
what am i doing wrong ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了上述问题的原因,
应该理解的一件事是,当出现异常时
“CLR:运行时代码生成验证”
抛出它意味着编写的代码格式不正确,并且当汇编器对其进行评估时,它不接受编写的代码,问题通常是因为堆栈具有额外的值或更少的值。
“JIT 编译器遇到内部限制。”当运行时它期望我们提供其他有价值的东西或者当需要其他东西时堆栈有其他东西时抛出。
简而言之,后面的异常是在运行时抛出的,另一个是在预运行条件不满足时抛出的。
无论如何,我找到了原因,堆栈上仍然存在一些值,如果满足条件,我不会弹出这些值,因此 POP OpCode 解决了问题,顺便说一句,Dup OpCode 从未解决过,它总是推送 null堆栈上的值而不是复制最上面的值。
Found reasonS to the above problem,
one thing which should be understood that when an exception of
'CLR: Verification for Runtime Code Generation'
is thrown it means the code written is not in the correct format and when it is evaluated by the assembler it does not accept the written code, problem is usually because of stacks having extra values or less.
"JIT Compiler encountered an internal limitation." is thrown when at runtime it was expecting something else we provide something else in value or when stack has something else when something else was required.
In short, the later exception is thrown at runtime and the other is thrown when pre Run conditions are not met.
anyways i found the reason, i had some values still present on stack that i did not pop if Condition was met, so the POP OpCode did the trick, and by the way for me the Dup OpCode never worked out, it always pushes a null value on stack rather than duplicating the top most value.