Skip to content

Commit

Permalink
more test things
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Sep 19, 2023
1 parent 64bc200 commit 603f321
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1916,12 +1916,13 @@ static jl_cgval_t typed_load(jl_codectx_t &ctx, Value *ptr, Value *idx_0based, j
Value *fld0 = ctx.builder.CreateStructGEP(elty, data, 0);
LoadInst *load0 = ctx.builder.CreateAlignedLoad(elty->getStructElementType(0), fld0, Align(alignment), false);
load0->setOrdering(Order);
maybe_mark_load_dereferenceable(load0, true, sizeof(void*)*2, alignof(void*));
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, tbaa);
ai.scope = MDNode::concatenate(aliasscope, ai.scope);
ai.decorateInst(load0);
Value *fld1 = ctx.builder.CreateStructGEP(elty, data, 1);
LoadInst *load1 = ctx.builder.CreateAlignedLoad(elty->getStructElementType(1), fld1, Align(alignment), false);
static_assert(offsetof(jl_genericmemoryref_t, data) == 0, "wrong field order");
maybe_mark_load_dereferenceable(load1, true, sizeof(void*)*2, alignof(void*));
load1->setOrdering(Order);
ai.decorateInst(load1);
instr = Constant::getNullValue(elty);
Expand Down
10 changes: 6 additions & 4 deletions stdlib/Mmap/src/Mmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,9 @@ Forces synchronization between the in-memory version of a memory-mapped `Array`
[`BitArray`](@ref) and the on-disk version.
"""
function sync!(m::Array, flags::Integer=MS_SYNC)
offset = rem(UInt(pointer(m)), PAGESIZE)
ptr = pointer(m) - offset
ptr = pointer(m)
offset = rem(UInt(ptr), PAGESIZE)
ptr = ptr - offset
mmaplen = sizeof(m) + offset
GC.@preserve m @static if Sys.isunix()
systemerror("msync",
Expand Down Expand Up @@ -429,8 +430,9 @@ Advises the kernel on the intended usage of the memory-mapped `array`, with the
`flag` being one of the available `MADV_*` constants.
"""
function madvise!(m::Array, flag::Integer=MADV_NORMAL)
offset = rem(UInt(pointer(m)), PAGESIZE)
ptr = pointer(m) - offset
ptr = pointer(m)
offset = rem(UInt(ptr), PAGESIZE)
ptr = ptr - offset
mmaplen = sizeof(m) + offset
GC.@preserve m begin
systemerror("madvise",
Expand Down
31 changes: 21 additions & 10 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1562,32 +1562,43 @@ end
f_typeof_tfunc(x) = typeof(x)
@test Base.return_types(f_typeof_tfunc, (Union{<:T, Int} where T<:Complex,)) == Any[Union{Type{Int}, Type{Complex{T}} where T<:Real}]

# memoryref, memoryrefget_tfunc / memoryrefset_tfunc
import Core.Compiler: Const
# memoryref_tfunc, memoryrefget_tfunc, memoryrefset_tfunc
let memoryref_tfunc(@nospecialize xs...) = Core.Compiler.memoryref_tfunc(Core.Compiler.fallback_lattice, xs...)
memoryrefget_tfunc(@nospecialize xs...) = Core.Compiler.memoryrefget_tfunc(Core.Compiler.fallback_lattice, xs...)
memoryrefset_tfunc(@nospecialize xs...) = Core.Compiler.memoryrefset_tfunc(Core.Compiler.fallback_lattice, xs...)
@test memoryref_tfunc(Memory{Int}) == MemoryRef{:not_atomic, Int}
@test memoryref_tfunc(Memory{Integer}) == MemoryRef{:not_atomic, Integer}
@test memoryref_tfunc(MemoryRef{:not_atomic, Int}, Int) == MemoryRef{:not_atomic, Int}
@test_broken memoryref_tfunc(Memory{Int}, Int) == MemoryRef{:not_atomic, Int}
@test memoryref_tfunc(MemoryRef{:not_atomic, Int}, Int, Symbol) == Union{}
@test memoryref_tfunc(MemoryRef{:not_atomic, Int}, Int, Bool) == MemoryRef{:not_atomic, Int}
@test memoryref_tfunc(Memory{Int}, Int) == Union{}
@test memoryref_tfunc(Any, Any, Any) == Any # TODO: make this MemoryRef?
@test memoryref_tfunc(Any, Any) == Any # TODO: make this MemoryRef?
@test memoryref_tfunc(Any) == MemoryRef
@test memoryrefget_tfunc(MemoryRef{:not_atomic, Int}, Symbol, Bool) === Int
@test memoryrefget_tfunc(MemoryRef{:not_atomic, <:Integer}, Symbol, Bool) === Integer
@test memoryrefget_tfunc(MemoryRef{:not_atomic, Int}, Any, Any) === Int
@test memoryrefget_tfunc(MemoryRef{:not_atomic,<:Integer}, Symbol, Bool) === Integer
@test memoryrefget_tfunc(MemoryRef, Symbol, Bool) === Any
@test memoryrefget_tfunc(MemoryRef{:not_atomic}, Symbol, Bool) === Any
@test memoryrefget_tfunc(Vector{Int}, Symbol, Bool) === Union{}
@test memoryrefget_tfunc(String, Symbol, Bool) === Union{}
@test_throws MethodError memoryrefget_tfunc(MemoryRef{:not_atomic, Int}, Int, Int, Symbol, Bool) === Union{}
@test memoryrefget_tfunc(MemoryRef{:not_atomic, Int}, String, Bool) === Union{}
@test memoryrefget_tfunc(MemoryRef{:not_atomic, Int}, Symbol, String) === Union{}
@test memoryrefget_tfunc(Any, Any, Any) === Any
@test memoryrefset_tfunc(MemoryRef{:not_atomic, Int}, Int, Symbol, Bool) === MemoryRef{:not_atomic, Int}
let ua = MemoryRef{:not_atomic, <:Integer}
let ua = MemoryRef{:not_atomic,<:Integer}
@test memoryrefset_tfunc(ua, Int, Symbol, Bool) === ua
end
@test memoryrefset_tfunc(MemoryRef, Int, Symbol, Bool) === MemoryRef
@test memoryrefset_tfunc(MemoryRef{:not_atomic}, Int, Symbol, Bool) === MemoryRef{:not_atomic}
@test memoryrefset_tfunc(Any, Int, Symbol, Bool) === Any
@test_throws MethodError memoryrefset_tfunc(MemoryRef{:not_atomic, String}, Symbol, Bool) === Union{}
@test memoryrefset_tfunc(MemoryRef{:not_atomic, String}, Int, Symbol, Bool) === Union{}
@test memoryrefset_tfunc(String, Char, Symbol, Bool) === Union{}
@test memoryrefset_tfunc(MemoryRef{:not_atomic, Int}, Float64, Symbol, Bool) === Union{}
@test_throws MethodError memoryrefset_tfunc(MemoryRef{:not_atomic, Int}, Int, Int, Symbol, Bool) === Union{}
@test memoryrefset_tfunc(MemoryRef{:not_atomic, Int}, Float64, Symbol, Bool) === Union{}
@test memoryrefset_tfunc(MemoryRef{:not_atomic, Int}, Any, Symbol, Bool) === MemoryRef{:not_atomic, Int}
@test memoryrefset_tfunc(MemoryRef{:not_atomic, Int}, Any, Any, Any) === MemoryRef{:not_atomic, Int}
@test memoryrefset_tfunc(MemoryRef{:not_atomic}, Any, Any, Any) === MemoryRef{:not_atomic}
@test memoryrefset_tfunc(MemoryRef, Any, Any, Any) === MemoryRef
@test memoryrefset_tfunc(Any, Any, Any, Any) === Any # TODO: make this MemoryRef?
end

let tuple_tfunc(@nospecialize xs...) =
Expand Down

0 comments on commit 603f321

Please sign in to comment.