Conversation
This is WIP towards #11902. Only bits tuples are supported, and this has only so far been tested on Mac/LLVM37
|
This basically works now, but it's not particularly useful, because the intermediate ref allocation does still happen, so even something simple like ends up allocating. @JeffBezanson do we have anything in there right now that could deal with this? |
|
i was expecting this to be implemented via the existing pointerref / pointerset intrinsics (possible with the addition of a new gep intrinsic). what's the rationale for adding this as a builtin function instead? |
|
I was concerned about GC behavior, which is why I added a new intrinsic that atomically does this so no random pointers are flying around. |
fair enough. a lot of the Ref code is built around late / lazy conversion to pointer under the premise that we can use that to ensure Ref ends up assigned to some local variable before having since |
|
Except it doesn't. It returns the assigned value. |
it isn't supposed to: julia> x=[1,2,3]
3-element Array{Int64,1}:
1
2
3
julia> setindex!(x, 5, 2)
3-element Array{Int64,1}:
1
5
3 |
|
Oh, huh, why did I think it returned the assigned value? |
|
Oh, yeah: |
|
In any case though, after inlining is the Ref still guaranteed to be live? |
|
it doesn't really matter if it's alive or not once you've lost the reference to it, since you wouldn't be able to take the final value back out anyways |
|
what if the base case (and new intrinsic) was then the implementation code could look something like: function setindex!{T}(ref::Ref{T}, val, indices)
ptr = unsafe_convert(::Ptr{T}, ref)
offset = Intrinsics.offsetof(T, indices)
unsafe_store!(ptr + offset, val)
ref
end |
|
(tagged 0.4.0 because underlying issue is also tagged 0.4.0) |
|
Not enough progress has been made, kicking to 1.0. |
|
Superseded by #21912 |
This is WIP towards #11902. Only bits tuples are supported, and this
has only so far been tested on Mac/LLVM37