Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Truffle] Adding overflow specializations for Fixnum#abs. #2782

Merged
merged 1 commit into from Mar 30, 2015

Conversation

bjfish
Copy link
Contributor

@bjfish bjfish commented Mar 30, 2015

Fixes #2781

@chrisseaton
Copy link
Contributor

Hmm... I'm not sure this is the best approach. You have a compare, and then a jump to deoptimize in the fastest case. A single jo to deoptimize would be tighter. The code for Math.abs is:

    public static int abs(int a) {
        return (a < 0) ? -a : a;
    }

Perhaps we'd be better off writing that inline, and then just replacing the - with ExactMath.subtractExact?

And then of course you'd need the fallback cases similar to as you have.

@bjfish
Copy link
Contributor Author

bjfish commented Mar 30, 2015

@chrisseaton updated to use ExactMath

chrisseaton added a commit that referenced this pull request Mar 30, 2015
[Truffle] Adding overflow specializations for Fixnum#abs.
@chrisseaton chrisseaton merged commit c83f089 into jruby:master Mar 30, 2015
@bjfish bjfish deleted the truffle_fixnum_abs_fix branch March 30, 2015 18:36
@chrisseaton chrisseaton added this to the truffle-dev milestone Mar 30, 2015
@chrisseaton
Copy link
Contributor

Thanks - take a look at jt --asm of the two to see why it's better this way.

@enebo enebo added this to the Non-Release milestone Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Truffle] Expected Absolute Value for Fixnum
4 participants