ClojureScript

Use unchecked-*-int functions for real 32-bit math

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    r2173

Description

Currently the unchecked-* functions and macros simply alias the primitive js operators. It would be nice if the unchecked-*-int family of functions and macros implemented C/Java-like signed int operations with silent overflows (just like in Clojure) using asm.js coersion idioms. This should also allow us to share such code between clojure and clojurescript without worrying about their different numerics.

A use case is that porting hash algorithms from java to clojurescript is trickier and more verbose than it needs to be.

Activity

Hide
David Nolen added a comment -

This sounds interesting, would like to see more thoughts on approach, benchmarks etc.

Show
David Nolen added a comment - This sounds interesting, would like to see more thoughts on approach, benchmarks etc.
Hide
David Nolen added a comment -

Bump, this enhancements sound simple & fine.

Show
David Nolen added a comment - Bump, this enhancements sound simple & fine.
David Nolen made changes -
Field Original Value New Value
Priority Minor [ 4 ] Major [ 3 ]
Hide
Francis Avila added a comment -

I'll have time to do this in about a week. The implementation is straightforward (basically use xor 0 everywhere). The goal is correctness, but I expect performance to be as good as or better than it is now on most platforms. I'm not sure if advanced mode will drop intermediate truncations or what impact this has on performance.

Some higher-level numeric analysis using the asm.js type system is possible but I doubt it's worth it.

Show
Francis Avila added a comment - I'll have time to do this in about a week. The implementation is straightforward (basically use xor 0 everywhere). The goal is correctness, but I expect performance to be as good as or better than it is now on most platforms. I'm not sure if advanced mode will drop intermediate truncations or what impact this has on performance. Some higher-level numeric analysis using the asm.js type system is possible but I doubt it's worth it.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated: