Skip to content

Commit 1750a83

Browse files
committed
remove redundant data_pointer_from_objref
1 parent 5dcd469 commit 1750a83

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

base/essentials.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ function getindex(v::SimpleVector, i::Int)
533533
throw(BoundsError(v,i))
534534
end
535535
t = @_gc_preserve_begin v
536-
x = unsafe_load(convert(Ptr{Ptr{Cvoid}},data_pointer_from_objref(v)) + i*sizeof(Ptr))
536+
x = unsafe_load(convert(Ptr{Ptr{Cvoid}},pointer_from_objref(v)) + i*sizeof(Ptr))
537537
x == C_NULL && throw(UndefRefError())
538538
o = unsafe_pointer_to_objref(x)
539539
@_gc_preserve_end t
@@ -542,7 +542,7 @@ end
542542

543543
function length(v::SimpleVector)
544544
t = @_gc_preserve_begin v
545-
l = unsafe_load(convert(Ptr{Int},data_pointer_from_objref(v)))
545+
l = unsafe_load(convert(Ptr{Int},pointer_from_objref(v)))
546546
@_gc_preserve_end t
547547
return l
548548
end
@@ -598,7 +598,7 @@ function isassigned end
598598
function isassigned(v::SimpleVector, i::Int)
599599
@boundscheck 1 <= i <= length(v) || return false
600600
t = @_gc_preserve_begin v
601-
x = unsafe_load(convert(Ptr{Ptr{Cvoid}},data_pointer_from_objref(v)) + i*sizeof(Ptr))
601+
x = unsafe_load(convert(Ptr{Ptr{Cvoid}},pointer_from_objref(v)) + i*sizeof(Ptr))
602602
@_gc_preserve_end t
603603
return x != C_NULL
604604
end

base/inference.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2715,7 +2715,7 @@ function abstract_eval(@nospecialize(e), vtypes::VarTable, sv::InferenceState)
27152715
spsig = sv.linfo.def.sig
27162716
if isa(spsig, UnionAll)
27172717
if !isempty(sv.linfo.sparam_vals)
2718-
env = data_pointer_from_objref(sv.linfo.sparam_vals) + sizeof(Ptr{Cvoid})
2718+
env = pointer_from_objref(sv.linfo.sparam_vals) + sizeof(Ptr{Cvoid})
27192719
rt = ccall(:jl_instantiate_type_in_env, Any, (Any, Any, Ptr{Any}), e.args[2], spsig, env)
27202720
else
27212721
rt = rewrap_unionall(e.args[2], spsig)

base/pointer.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ will not protect the object from garbage collection, so you must ensure that the
135135
remains referenced for the whole time that the `Ptr` will be used.
136136
"""
137137
pointer_from_objref(@nospecialize(x)) = ccall(:jl_value_ptr, Ptr{Cvoid}, (Any,), x)
138-
data_pointer_from_objref(@nospecialize(x)) = pointer_from_objref(x)::Ptr{Cvoid}
139138

140139
eltype(::Type{Ptr{T}}) where {T} = T
141140

base/refpointer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function unsafe_convert(P::Type{Ptr{T}}, b::RefValue{T}) where T
7373
end
7474
end
7575
function unsafe_convert(P::Type{Ptr{Any}}, b::RefValue{Any})
76-
return convert(P, data_pointer_from_objref(b))
76+
return convert(P, pointer_from_objref(b))
7777
end
7878
unsafe_convert(::Type{Ptr{Cvoid}}, b::RefValue{T}) where {T} = convert(Ptr{Cvoid}, unsafe_convert(Ptr{T}, b))
7979

@@ -93,7 +93,7 @@ function unsafe_convert(P::Type{Ptr{T}}, b::RefArray{T}) where T
9393
if isbits(T)
9494
convert(P, pointer(b.x, b.i))
9595
else
96-
convert(P, data_pointer_from_objref(b.x[b.i]))
96+
convert(P, pointer_from_objref(b.x[b.i]))
9797
end
9898
end
9999
function unsafe_convert(P::Type{Ptr{Any}}, b::RefArray{Any})

test/show.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ let repr = sprint(dump, Core.svec())
767767
end
768768
let sv = Core.svec(:a, :b, :c)
769769
# unsafe replacement of :c with #undef to test handling of incomplete SimpleVectors
770-
unsafe_store!(convert(Ptr{Ptr{Cvoid}}, Base.data_pointer_from_objref(sv)) + 3 * sizeof(Ptr), C_NULL)
770+
unsafe_store!(convert(Ptr{Ptr{Cvoid}}, Base.pointer_from_objref(sv)) + 3 * sizeof(Ptr), C_NULL)
771771
repr = sprint(dump, sv)
772772
@test repr == "SimpleVector\n 1: Symbol a\n 2: Symbol b\n 3: #undef\n"
773773
end

0 commit comments

Comments
 (0)