提交 88cfaf8a 编写于 作者: N nsz

fix i386 fegetround and make fesetround faster

Note that the new fesetround has slightly different semantics:

Storing the floating-point environment with fnstenv makes the
next fldenv (or fldcw) "non-signaling", so unmasked and pending
exceptions does not invoke the exception handler.
(These are rare since exceptions are handled immediately and by
default all exceptions are masked anyway. But if one manually
unmasks an exception in the control word then either sets the
corresponding exception flag in the status word or the execution
of an exception raising floating-point operation gets interrupted
then it may happen).
So the old implementation did not trap in some rare cases
where the new implementation traps.

However POSIX does not specify anything like the x87 exception
handling traps and the fnstenv/fldenv pair is significantly slower
than the fnstcw/fldcw pair (new code is about 5x faster here and
it's dominated by the function call overhead).
上级 d3fc7247
...@@ -32,22 +32,22 @@ feraiseexcept: ...@@ -32,22 +32,22 @@ feraiseexcept:
fesetround: fesetround:
mov 4(%esp),%ecx mov 4(%esp),%ecx
xor %eax,%eax xor %eax,%eax
sub $32,%esp sub $4,%esp
fnstenv (%esp) fnstcw (%esp)
andb $0xf3,1(%esp) andb $0xf3,1(%esp)
or %ecx,(%esp) or %cx,(%esp)
fldenv (%esp) fldcw (%esp)
add $32,%esp add $4,%esp
ret ret
.global fegetround .global fegetround
.type fegetround,@function .type fegetround,@function
fegetround: fegetround:
sub $28,%esp sub $4,%esp
fnstenv (%esp) fnstcw (%esp)
mov 4(%esp),%eax mov (%esp),%ax
add $28,%esp add $4,%esp
and $0xc,%ah and $0xc00,%eax
ret ret
.global fegetenv .global fegetenv
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册