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

Ensure sizeof returns correctly for isbits Union arrays. Fixes #23321 #23335

Merged
merged 1 commit into from
Aug 21, 2017

Conversation

quinnj
Copy link
Member

@quinnj quinnj commented Aug 18, 2017

The only other question I have is whether we should also define sizeof(Union{Void, Int8}), i.e. should sizeof return for isbits Unions? I feel like we should, mainly because it does actually have a definitize size now in structs & array elements.

@JeffBezanson
Copy link
Sponsor Member

should sizeof return for isbits Unions

👍 Yes I agree it should.

src/builtins.c Outdated
elsize = sizeof(void*);
size_t len = jl_array_len(x);
return jl_box_long((!isboxed && jl_is_uniontype(ety)) ? len * elsize + len : len * elsize);
}
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

This logic should already be captured by ((jl_array_t*)x)->elsize. In fact, I believe it is.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Ah, except for the + len part. I'm not totally sure that should be reported as part of the array size; kind of a tough call.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, we can just use ->elsize. I updated the PR to not include the + len as part of the size. I think it will keep this more on the "optimization" side of things as opposed to necessarily committing to the layout. I also updated to give a size for isbits Union types.

elsize = ConstantInt::get(T_size, sizeof(void*));
}
else {
elsize = ConstantInt::get(T_size, jl_datatype_size(ety));
elsize = ConstantInt::get(T_size, elsz);
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

We should have a more convenient jl_type_size function for just getting the size.

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, we need the size and whether it's boxed anyway.

… Also defines sizeof on any isbits Union types
@quinnj
Copy link
Member Author

quinnj commented Aug 19, 2017

I'm guessing this is an unrelated libuv travis failure

	From worker 6:	Assertion failed: (args[0]), function jl_uv_call_close_callback, file /Users/travis/build/JuliaLang/julia/src/jl_uv.c, line 73.
	From worker 6:	
	From worker 6:	signal (6): Abort trap: 6
	From worker 6:	while loading no file, in expression starting on line 0
	From worker 6:	__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
	From worker 6:	Allocations: 224681289 (Pool: 224650756; Big: 30533); GC: 594

@fredrikekre
Copy link
Member

Looks like #23215

@quinnj
Copy link
Member Author

quinnj commented Aug 20, 2017

Do you want to take one more look @JeffBezanson?

@JeffBezanson JeffBezanson merged commit 7b1bf10 into master Aug 21, 2017
@JeffBezanson JeffBezanson deleted the jq/isbitsunionarraysizeof branch August 21, 2017 15:59
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.

3 participants