Skip to content

Commit cf1f1e8

Browse files
committed
remove jl_alignment in favour of datatype_alignment
1 parent 295f1ef commit cf1f1e8

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

base/atomics.jl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
using Core.Intrinsics: llvmcall
44

5-
import Base: setindex!, getindex, unsafe_convert
5+
import Base: setindex!, getindex, unsafe_convert, datatype_alignment
66
import Base.Sys: ARCH, WORD_SIZE
77

88
export
@@ -321,9 +321,6 @@ inttype(::Type{Float16}) = Int16
321321
inttype(::Type{Float32}) = Int32
322322
inttype(::Type{Float64}) = Int64
323323

324-
325-
alignment(::Type{T}) where {T} = ccall(:jl_alignment, Cint, (Any,), T)
326-
327324
# All atomic operations have acquire and/or release semantics, depending on
328325
# whether the load or store values. Most of the time, this is what one wants
329326
# anyway, and it's only moderately expensive on most hardware.
@@ -335,39 +332,39 @@ for typ in atomictypes
335332
if VersionNumber(Base.libllvm_version) >= v"3.8"
336333
@eval getindex(x::Atomic{$typ}) =
337334
llvmcall($"""
338-
%rv = load atomic $rt %0 acquire, align $(alignment(typ))
335+
%rv = load atomic $rt %0 acquire, align $(datatype_alignment(typ))
339336
ret $lt %rv
340337
""", $typ, Tuple{Ptr{$typ}}, unsafe_convert(Ptr{$typ}, x))
341338
@eval setindex!(x::Atomic{$typ}, v::$typ) =
342339
llvmcall($"""
343-
store atomic $lt %1, $lt* %0 release, align $(alignment(typ))
340+
store atomic $lt %1, $lt* %0 release, align $(datatype_alignment(typ))
344341
ret void
345342
""", Void, Tuple{Ptr{$typ},$typ}, unsafe_convert(Ptr{$typ}, x), v)
346343
else
347344
if typ <: Integer
348345
@eval getindex(x::Atomic{$typ}) =
349346
llvmcall($"""
350-
%rv = load atomic $rt %0 acquire, align $(alignment(typ))
347+
%rv = load atomic $rt %0 acquire, align $(datatype_alignment(typ))
351348
ret $lt %rv
352349
""", $typ, Tuple{Ptr{$typ}}, unsafe_convert(Ptr{$typ}, x))
353350
@eval setindex!(x::Atomic{$typ}, v::$typ) =
354351
llvmcall($"""
355-
store atomic $lt %1, $lt* %0 release, align $(alignment(typ))
352+
store atomic $lt %1, $lt* %0 release, align $(datatype_alignment(typ))
356353
ret void
357354
""", Void, Tuple{Ptr{$typ},$typ}, unsafe_convert(Ptr{$typ}, x), v)
358355
else
359356
@eval getindex(x::Atomic{$typ}) =
360357
llvmcall($"""
361358
%iptr = bitcast $lt* %0 to $ilt*
362-
%irv = load atomic $irt %iptr acquire, align $(alignment(typ))
359+
%irv = load atomic $irt %iptr acquire, align $(datatype_alignment(typ))
363360
%rv = bitcast $ilt %irv to $lt
364361
ret $lt %rv
365362
""", $typ, Tuple{Ptr{$typ}}, unsafe_convert(Ptr{$typ}, x))
366363
@eval setindex!(x::Atomic{$typ}, v::$typ) =
367364
llvmcall($"""
368365
%iptr = bitcast $lt* %0 to $ilt*
369366
%ival = bitcast $lt %1 to $ilt
370-
store atomic $ilt %ival, $ilt* %iptr release, align $(alignment(typ))
367+
store atomic $ilt %ival, $ilt* %iptr release, align $(datatype_alignment(typ))
371368
ret void
372369
""", Void, Tuple{Ptr{$typ},$typ}, unsafe_convert(Ptr{$typ}, x), v)
373370
end

src/julia_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ extern jl_mutex_t gc_perm_lock;
132132
void *jl_gc_perm_alloc_nolock(size_t sz, int zero);
133133
void *jl_gc_perm_alloc(size_t sz, int zero);
134134

135-
JL_DLLEXPORT int jl_alignment(void* ty);
136-
137135
#define JL_SMALL_BYTE_ALIGNMENT 16
138136
#define JL_CACHE_BYTE_ALIGNMENT 64
139137
#define GC_MAX_SZCLASS (2032-sizeof(void*))

src/threading.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -832,15 +832,6 @@ void jl_init_threading(void)
832832
void jl_start_threads(void) { }
833833

834834
#endif // !JULIA_ENABLE_THREADING
835-
836-
// Make gc alignment available for threading
837-
// see threads.jl alignment
838-
JL_DLLEXPORT int jl_alignment(void* ty)
839-
{
840-
assert(jl_is_datatype(ty));
841-
return jl_datatype_align(ty);
842-
}
843-
844835
#ifdef __cplusplus
845836
}
846837
#endif

0 commit comments

Comments
 (0)