Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,20 @@ default_access_order(a::GenericMemory{:atomic}) = :monotonic
default_access_order(a::GenericMemoryRef{:not_atomic}) = :not_atomic
default_access_order(a::GenericMemoryRef{:atomic}) = :monotonic

getindex(A::GenericMemory, i::Int) = (@_noub_if_noinbounds_meta;
memoryrefget(memoryrefnew(memoryrefnew(A), i, @_boundscheck), default_access_order(A), false))
function getindex(A::GenericMemory, i::Int)
@_noub_if_noinbounds_meta
@_effect_free_terminates_locally_meta
elt = eltype(A)
if (Any <: elt) || (isconcretetype(elt) && isbitstype(elt))
@boundscheck checkbounds(A, i)
let ptr = pointer(A), ord = Base.default_access_order(A)
GC.@preserve A unsafe_load(ptr, i, ord)
end
else
memoryrefget(memoryrefnew(memoryrefnew(A), i, @_boundscheck), default_access_order(A), false)
end
end

getindex(A::GenericMemoryRef) = memoryrefget(A, default_access_order(A), @_boundscheck)

"""
Expand Down