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

fixed int128 implementation #5564

Closed
wants to merge 1 commit into from

Conversation

omotorin
Copy link

I found some bugs in implementation of int128. It related with LLVMConstInt that works only with 64 bit integer and 128 bit will always cut to 64 bit. Also I've implemented to_int128/to_uint128 that needed to correct works codegen for 128 bit integer

@RX14 RX14 requested a review from asterite January 10, 2018 12:41
@@ -509,7 +541,7 @@ class String
end
end

private def to_u64_info(base, whitespace, underscore, prefix, strict)
private def to_u128_info(base, whitespace, underscore, prefix, strict)
Copy link
Contributor

@RX14 RX14 Jan 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about all to_i calls having to go through 128bit mathematics: it probably slows down the conversion process on processors without 128bit maths support (i.e. most of them).

I think it's a good idea to duplicate this method, and have both to_u64_info and to_u128_info. This can probably be done quite easily without extra boilerplate with macros.

If only we had a benchmark suite :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree. Also two test are failed because I extend to_u64_info method to support 128 bit integer and now they works incorrect with 64 bit.
I will fix it.

when :u128
# TODO: implement String#to_u128 and use it
@last = int128(node.value.to_u64)
@last = int128(node.value.to_u128)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the TODO above

@Sija
Copy link
Contributor

Sija commented Jan 10, 2018

Related to #5545

@asterite
Copy link
Member

@omotorin Thank you for this!

Some things:

  1. You should add specs to every functionality you add. There are currently no specs to parse 128 bit numbers.
  2. You modify the lexer but that change alone isn't enough. Please add specs, though I guess it will be hard to get right (it's a very custom logic to parse numbers). Plus maybe it's not good to us 128 bit integers to parse every number in a program. I could tackle this later in a separate PR if it turns out to be hard.

@Sija
Copy link
Contributor

Sija commented Feb 27, 2018

@omotorin Are you willing to continue?

@straight-shoota
Copy link
Member

straight-shoota commented Dec 9, 2020

Closing stale PR. Int128 support is tracked in #8373
Thank you anyways 👍

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.

None yet

6 participants