On 09/07/2017 10:12 AM, Ben Kelly wrote:
On Thu, Sep 7, 2017 at 10:09 AM, Nathan Froyd <nfr...@mozilla.com> wrote:
On Thu, Sep 7, 2017 at 10:04 AM, Ben Kelly <bke...@mozilla.com> wrote:
On Mon, Aug 14, 2017 at 10:44 AM, Tristan Bourvon <tbour...@mozilla.com>
wrote:
Here's the RFC of the overflow builtins:
http://clang-developers.42468.n3.nabble.com/RFC-Introduce-
overflow-builtins-td3838320.html
Along with the tracking issue: https://bugs.llvm.org/show_
bug.cgi?id=12290
And the patch:
https://github.com/llvm-mirror/clang/commit/
98d1ec1e99625176626b0bcd44cef7
df6e89b289
There's also another patch that was added on top of this one which adds
more overflow builtins:
https://github.com/llvm-mirror/clang/commit/
c41c63fbf84cc904580e733d1123d3
b03bb5584c
It seems clear that this optimization could bring big performance
improvements on hot functions. It could also reduce binary size
substantially (we're talking about 14->5 instructions in their case).
Do we have a bug filed to investigate these overflow builtins? Should we
file one?
There is bug 1356936 for mozilla::CheckedInt; I don't know how many
saturating-style arithmetic implementations we have in the tree, or
whether similar bugs exist for those.
I guess my impression was this would be something we would want the jit to
emit in its bytecode. But maybe I don't fully understand.
These are LLVM/gcc builtins, which allow the C++ compiler code generator
to understand that a high-level operation like
<https://searchfox.org/mozilla-central/rev/67f38de2443e6b613d874fcf4d2cd1f2fc3d5e97/mfbt/CheckedInt.h#256>
is actually just checking whether an addition overflows, so that it can
generate efficient machine code based on that. For example, on x86 you
can use the overflow bit alongside instructions such as JO (jump on
overflow) or JNO (jump on not overflow) to do these checks more
efficiently, but without the builtins the compiler won't be able to
decipher what the IsAddValid function is trying to do and would instead
generate more inefficient code that does bit manipulation.
If our JIT code emits overflow checks, it can directly emit the more
efficient machine code as it has an assembler and it doesn't need to
rely on C++ compiler intrinsics like this.
Hope this helps!
Cheers,
Ehsan
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform