Delphi XE2、TWebBrowser、浮点数除以零 [英] Delphi XE2, TWebBrowser, float divide by zero

查看:22
本文介绍了Delphi XE2、TWebBrowser、浮点数除以零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Delphi 2010 和 Delphi 2007 中,我在 WebBrowserBeforeNavigate/WebBrowserDocumentComplete 上使用 Set8087CW 来防止 ActiveX 中的 FPU 错误削弱我的应用程序.

In Delphi 2010 and Delphi 2007 I am using Set8087CW on WebBrowserBeforeNavigate / WebBrowserDocumentComplete to prevent FPU errors inside ActiveX to cripple my application.

但不知何故,这在 Delphi XE2 中不起作用,至少在 64 位模式下是这样.

But somehow this is not working in Delphi XE2, at least when in 64bit mode.

当单击链接(任何)时,我得到浮动除以零".(将网站地址或内容初始加载到 TWebBrowser 工作正常.)

When clicking links (any) I get "float divide by zero". (The initial loading of a website address or content into TWebBrowser works fine.)

调用堆栈显示这发生在 system32D3D10Warp.dll 中(可能被 IE9 使用?)以响应 TApplication.ProcessMessage(以及两者之间的一些???)

The callstack shows this to happen inside system32D3D10Warp.dll (maybe used by IE9?) in response to TApplication.ProcessMessage (and some ??? inbetween the two)

推荐答案

您将需要屏蔽 64 位上的 SSE 异常,因为 64 位代码通常使用 SSE 来执行浮点运算.

You will need to mask SSE exceptions on 64 bit because 64 bit code typically uses SSE to perform floating point arithmetic.

调用 SetMXCSR 更改SSE 单元的控制状态.我个人会继续屏蔽 8087 异常,因为 64 位代码完全可以随意使用 8087 单元,如果它愿意的话.调用 Web 浏览器代码时要使用的魔术 MXCSR 值是 $1F80.这是 MXCSR 的默认 Windows 值.

Call SetMXCSR to change the control state of the SSE unit. Personally I would continue masking 8087 exceptions since 64 bit code is perfectly at liberty to use the 8087 unit should it so wish. The magic MXCSR value that you want to use when calling the web browser code is $1F80. This is the default Windows value for MXCSR.

或者,您可以调用 SetSSEExceptionMaskSetFPUExceptionMask 传递 exAllArithmeticExceptions屏蔽所有异常.这些方便的方法将使您的代码更具可读性.

Alternatively, you can call SetSSEExceptionMask and SetFPUExceptionMask passing exAllArithmeticExceptions to mask all exceptions. These convenience methods would make your code more readable.

如果您满足于只需要在 x86 下屏蔽 8087 和 x64 下的 SSE 上的异常,那么您只需调用 SetExceptionMask.这将改变x86下的8087控制状态和x64下的SSE控制状态.

If you are satisfied that you only need to mask exceptions on 8087 under x86 and SSE under x64 then you can just call SetExceptionMask. This will change the 8087 control state under x86 and change the SSE control state under x64.

如果我必须在设置整个控件状态或使用便捷方法更改状态的异常屏蔽部分之间做出选择,我会设置整个控件状态.这些 ActiveX 控件是在假设您将使用 MS 工具并期望特定的 FP 控件状态下编写的.我会给这些控件提供他们期望的确切控制状态,然后在从控件返回执行时恢复到 Delphi 控制状态.

If I had to choose between setting the entire control state or using the convenience methods to change just the exception masking part of the state, I would set the entire control state. These ActiveX controls are written under the assumption that you will be using MS tooling and expect a specific FP control state. I would give these controls the exact control state that they expect and then revert back to the Delphi control state when execution returns from the controls.

这篇关于Delphi XE2、TWebBrowser、浮点数除以零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆