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

Fix more JET issues #951

Merged
merged 1 commit into from
Nov 17, 2023
Merged

Fix more JET issues #951

merged 1 commit into from
Nov 17, 2023

Conversation

fingolfin
Copy link
Member

Some found via @report_opt

Copy link

codecov bot commented Nov 1, 2023

Codecov Report

Merging #951 (eb677ba) into master (48d13e4) will increase coverage by 0.07%.
The diff coverage is 71.42%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #951      +/-   ##
==========================================
+ Coverage   75.70%   75.77%   +0.07%     
==========================================
  Files          51       51              
  Lines        4173     4177       +4     
==========================================
+ Hits         3159     3165       +6     
+ Misses       1014     1012       -2     
Files Coverage Δ
src/GAP.jl 86.08% <100.00%> (ø)
src/adapter.jl 71.28% <100.00%> (ø)
src/ccalls.jl 99.19% <100.00%> (ø)
src/constructors.jl 98.71% <100.00%> (ø)
src/julia_to_gap.jl 96.93% <100.00%> (+5.18%) ⬆️
src/gap_to_julia.jl 89.78% <0.00%> (-2.02%) ⬇️

@@ -219,7 +219,7 @@ function julia_to_gap(
elseif Wrappers.IsRecord(obj)
ret_val = NewPrecord(0)
recursion_dict[obj] = ret_val
for x in Vector{String}(Wrappers.RecNames(obj))
for x in Wrappers.RecNames(obj)::GapObj
Copy link
Member Author

Choose a reason for hiding this comment

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

This was a genuine bug here -- we are missing code coverage here.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this was wrong.
Looking at the function again, I am also not sure whether the statement

We have to do something only if recursive conversion is required

is correct: Don't we have to make at least a shallow copy?

@@ -219,7 +219,7 @@ function julia_to_gap(
elseif Wrappers.IsRecord(obj)
ret_val = NewPrecord(0)
recursion_dict[obj] = ret_val
for x in Vector{String}(Wrappers.RecNames(obj))
for x in Wrappers.RecNames(obj)::GapObj
Wrappers.ASS_REC(ret_val, x, julia_to_gap(Wrappers.ELM_REC(obj, x), recursion_dict; recursive = true))
Copy link
Member Author

Choose a reason for hiding this comment

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

(and this code is still wrong, I'll look into fixing it

Copy link
Member

Choose a reason for hiding this comment

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

What about

xx = Wrappers.RNamObj(x)
Wrappers.ASS_REC(ret_val, xx, julia_to_gap(Wrappers.ELM_REC(obj, xx), recursion_dict; recursive = true))

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. I just updated the PR accordingly and added a test.

Copy link
Member

@ThomasBreuer ThomasBreuer left a comment

Choose a reason for hiding this comment

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

Thanks.
This looks good, modulo the final fix in julia_to_gap.jl.

@@ -136,17 +136,17 @@ whereas `x` in the latter example lives in the Julia session.
"""
function evalstr(cmd::String)
res = evalstr_ex(cmd * ";")
if any(x->x[1] == false, res)
if any(x::GapObj->x[1] === false, res)
Copy link
Member

Choose a reason for hiding this comment

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

I read this as the recommendation to use always === or !== when comparing something with true, false, GAP.Globals.fail.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. It at least ensures that the compiler can always turn this into the most optimal code; here, it can't predict the type of x[1] so it should check at runtime whether there is a == method for whatever x[1] is plus a Bool... But we have extra information about the intent of the code, so that === is what we want, and can totally away runtime dispatch here.

Some found via @report_opt
@fingolfin fingolfin enabled auto-merge (squash) November 17, 2023 08:30
@fingolfin fingolfin merged commit 29d6b87 into oscar-system:master Nov 17, 2023
13 checks passed
@fingolfin fingolfin deleted the mh/more-JET branch November 17, 2023 08:45
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.

2 participants