-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the way we do Int64 conversion to/from GAP
Previously, any Int64 too big to fit into a GAP immediate integer was put into a T_JULIA wrapper when passed to GAP, and unwrapped later. At the same time, `julia_to_gap` relied completely (and incorrectly) on the C kernel functions `julia_gap` and `gap_julia` to take care of *all* Int64 values. The result was that passing such an integer as argument to a GAP function did not work, not even if one explicitly used `julia_to_gap`. To fix this we do two things: 1. We teach the C kernel function `gap_julia` to convert "large" Int64 values to GAP big integers; this ensures that the many adapter functions we install for Int64 arguments work. 2. We teach the Julia function `julia_to_gap` to perform a range check on Int64 values, and deal with those too big to fit into an immediate integer separately. As it turns out, Julia generates quite efficient machine code for the range check, so performance should be fine. We also apply the same improvement to a few other integer types. The main drawback of that is that julia_to_gap(x::Int64) now is not type stable, and thus has to return a boxed Int64 value. But that's not an in issue in so far as that already now, whenever we call into GAP APIs, we have to box all Int64; so we only change the point at which we box it. Also, we violate the principle of roundtrip type fidelity (Int64 -> GAP large int -> MPtr), but that is just a minor concern. For really efficient conversions of e.g. Array{Int64,1} to GAP plists, we need dedicated conversion functions which directly copy over bits. These can be added transparently in the future.
- Loading branch information
Showing
4 changed files
with
42 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters