Skip to content

Commit 7d11d2c

Browse files
authored
Merge branch 'master' into reimplement_cosc_for_Float32_Float64
2 parents 21f5ee6 + 80f7db8 commit 7d11d2c

File tree

32 files changed

+326
-104
lines changed

32 files changed

+326
-104
lines changed

Compiler/src/abstractinterpretation.jl

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3485,7 +3485,59 @@ function refine_partial_type(@nospecialize t)
34853485
return t
34863486
end
34873487

3488+
abstract_eval_nonlinearized_foreigncall_name(interp::AbstractInterpreter, e, sstate::StatementState, sv::IRInterpretationState) = nothing
3489+
3490+
function abstract_eval_nonlinearized_foreigncall_name(interp::AbstractInterpreter, e, sstate::StatementState, sv::AbsIntState)
3491+
if isexpr(e, :call)
3492+
n = length(e.args)
3493+
argtypes = Vector{Any}(undef, n)
3494+
callresult = Future{CallMeta}()
3495+
i::Int = 1
3496+
nextstate::UInt8 = 0x0
3497+
local ai, res
3498+
function evalargs(interp, sv)
3499+
if nextstate === 0x1
3500+
@goto state1
3501+
elseif nextstate === 0x2
3502+
@goto state2
3503+
end
3504+
while i <= n
3505+
ai = abstract_eval_nonlinearized_foreigncall_name(interp, e.args[i], sstate, sv)
3506+
if !isready(ai)
3507+
nextstate = 0x1
3508+
return false
3509+
@label state1
3510+
end
3511+
argtypes[i] = ai[].rt
3512+
i += 1
3513+
end
3514+
res = abstract_call(interp, ArgInfo(e.args, argtypes), sstate, sv)
3515+
if !isready(res)
3516+
nextstate = 0x2
3517+
return false
3518+
@label state2
3519+
end
3520+
callresult[] = res[]
3521+
return true
3522+
end
3523+
evalargs(interp, sv) || push!(sv.tasks, evalargs)
3524+
return callresult
3525+
else
3526+
return Future(abstract_eval_basic_statement(interp, e, sstate, sv))
3527+
end
3528+
end
3529+
34883530
function abstract_eval_foreigncall(interp::AbstractInterpreter, e::Expr, sstate::StatementState, sv::AbsIntState)
3531+
callee = e.args[1]
3532+
if isexpr(callee, :call) && length(callee.args) > 1 && callee.args[1] == GlobalRef(Core, :tuple)
3533+
# NOTE these expressions are not properly linearized
3534+
abstract_eval_nonlinearized_foreigncall_name(interp, callee.args[2], sstate, sv)
3535+
if length(callee.args) > 2
3536+
abstract_eval_nonlinearized_foreigncall_name(interp, callee.args[3], sstate, sv)
3537+
end
3538+
else
3539+
abstract_eval_value(interp, callee, sstate, sv)
3540+
end
34893541
mi = frame_instance(sv)
34903542
t = sp_type_rewrap(e.args[2], mi, true)
34913543
for i = 3:length(e.args)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ and then use the command prompt to change into the resulting julia directory. By
9797
Julia. However, most users should use the [most recent stable version](https://github.com/JuliaLang/julia/releases)
9898
of Julia. You can get this version by running:
9999

100-
git checkout v1.11.5
100+
git checkout v1.11.6
101101

102102
To build the `julia` executable, run `make` from within the julia directory.
103103

base/int.jl

Lines changed: 158 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -850,14 +850,166 @@ widemul(x::Bool,y::Number) = x * y
850850
widemul(x::Number,y::Bool) = x * y
851851

852852

853-
# Int128 multiply and divide
854-
*(x::T, y::T) where {T<:Union{Int128,UInt128}} = mul_int(x, y)
853+
## wide multiplication, Int128 multiply and divide ##
854+
855+
if Core.sizeof(Int) == 4
856+
function widemul(u::Int64, v::Int64)
857+
local u0::UInt64, v0::UInt64, w0::UInt64
858+
local u1::Int64, v1::Int64, w1::UInt64, w2::Int64, t::UInt64
859+
860+
u0 = u & 0xffffffff; u1 = u >> 32
861+
v0 = v & 0xffffffff; v1 = v >> 32
862+
w0 = u0 * v0
863+
t = reinterpret(UInt64, u1) * v0 + (w0 >>> 32)
864+
w2 = reinterpret(Int64, t) >> 32
865+
w1 = u0 * reinterpret(UInt64, v1) + (t & 0xffffffff)
866+
hi = u1 * v1 + w2 + (reinterpret(Int64, w1) >> 32)
867+
lo = w0 & 0xffffffff + (w1 << 32)
868+
return Int128(hi) << 64 + Int128(lo)
869+
end
870+
871+
function widemul(u::UInt64, v::UInt64)
872+
local u0::UInt64, v0::UInt64, w0::UInt64
873+
local u1::UInt64, v1::UInt64, w1::UInt64, w2::UInt64, t::UInt64
874+
875+
u0 = u & 0xffffffff; u1 = u >>> 32
876+
v0 = v & 0xffffffff; v1 = v >>> 32
877+
w0 = u0 * v0
878+
t = u1 * v0 + (w0 >>> 32)
879+
w2 = t >>> 32
880+
w1 = u0 * v1 + (t & 0xffffffff)
881+
hi = u1 * v1 + w2 + (w1 >>> 32)
882+
lo = w0 & 0xffffffff + (w1 << 32)
883+
return UInt128(hi) << 64 + UInt128(lo)
884+
end
885+
886+
function *(u::Int128, v::Int128)
887+
u0 = u % UInt64; u1 = Int64(u >> 64)
888+
v0 = v % UInt64; v1 = Int64(v >> 64)
889+
lolo = widemul(u0, v0)
890+
lohi = widemul(reinterpret(Int64, u0), v1)
891+
hilo = widemul(u1, reinterpret(Int64, v0))
892+
t = reinterpret(UInt128, hilo) + (lolo >>> 64)
893+
w1 = reinterpret(UInt128, lohi) + (t & 0xffffffffffffffff)
894+
return Int128(lolo & 0xffffffffffffffff) + reinterpret(Int128, w1) << 64
895+
end
896+
897+
function *(u::UInt128, v::UInt128)
898+
u0 = u % UInt64; u1 = UInt64(u>>>64)
899+
v0 = v % UInt64; v1 = UInt64(v>>>64)
900+
lolo = widemul(u0, v0)
901+
lohi = widemul(u0, v1)
902+
hilo = widemul(u1, v0)
903+
t = hilo + (lolo >>> 64)
904+
w1 = lohi + (t & 0xffffffffffffffff)
905+
return (lolo & 0xffffffffffffffff) + UInt128(w1) << 64
906+
end
907+
908+
function _setbit(x::UInt128, i)
909+
# faster version of `return x | (UInt128(1) << i)`
910+
j = i >> 5
911+
y = UInt128(one(UInt32) << (i & 0x1f))
912+
if j == 0
913+
return x | y
914+
elseif j == 1
915+
return x | (y << 32)
916+
elseif j == 2
917+
return x | (y << 64)
918+
elseif j == 3
919+
return x | (y << 96)
920+
end
921+
return x
922+
end
855923

856-
div(x::Int128, y::Int128) = checked_sdiv_int(x, y)
857-
div(x::UInt128, y::UInt128) = checked_udiv_int(x, y)
924+
function divrem(x::UInt128, y::UInt128)
925+
iszero(y) && throw(DivideError())
926+
if (x >> 64) % UInt64 == 0
927+
if (y >> 64) % UInt64 == 0
928+
# fast path: upper 64 bits are zero, so we can fallback to UInt64 division
929+
q64, x64 = divrem(x % UInt64, y % UInt64)
930+
return UInt128(q64), UInt128(x64)
931+
else
932+
# this implies y>x, so
933+
return zero(UInt128), x
934+
end
935+
end
936+
n = leading_zeros(y) - leading_zeros(x)
937+
q = zero(UInt128)
938+
ys = y << n
939+
while n >= 0
940+
# ys == y * 2^n
941+
if ys <= x
942+
x -= ys
943+
q = _setbit(q, n)
944+
if (x >> 64) % UInt64 == 0
945+
# exit early, similar to above fast path
946+
if (y >> 64) % UInt64 == 0
947+
q64, x64 = divrem(x % UInt64, y % UInt64)
948+
q |= q64
949+
x = UInt128(x64)
950+
end
951+
return q, x
952+
end
953+
end
954+
ys >>>= 1
955+
n -= 1
956+
end
957+
return q, x
958+
end
858959

859-
rem(x::Int128, y::Int128) = checked_srem_int(x, y)
860-
rem(x::UInt128, y::UInt128) = checked_urem_int(x, y)
960+
function div(x::Int128, y::Int128)
961+
(x == typemin(Int128)) & (y == -1) && throw(DivideError())
962+
return Int128(div(BigInt(x), BigInt(y)))::Int128
963+
end
964+
div(x::UInt128, y::UInt128) = divrem(x, y)[1]
965+
966+
function rem(x::Int128, y::Int128)
967+
return Int128(rem(BigInt(x), BigInt(y)))::Int128
968+
end
969+
970+
function rem(x::UInt128, y::UInt128)
971+
iszero(y) && throw(DivideError())
972+
if (x >> 64) % UInt64 == 0
973+
if (y >> 64) % UInt64 == 0
974+
# fast path: upper 64 bits are zero, so we can fallback to UInt64 division
975+
return UInt128(rem(x % UInt64, y % UInt64))
976+
else
977+
# this implies y>x, so
978+
return x
979+
end
980+
end
981+
n = leading_zeros(y) - leading_zeros(x)
982+
ys = y << n
983+
while n >= 0
984+
# ys == y * 2^n
985+
if ys <= x
986+
x -= ys
987+
if (x >> 64) % UInt64 == 0
988+
# exit early, similar to above fast path
989+
if (y >> 64) % UInt64 == 0
990+
x = UInt128(rem(x % UInt64, y % UInt64))
991+
end
992+
return x
993+
end
994+
end
995+
ys >>>= 1
996+
n -= 1
997+
end
998+
return x
999+
end
1000+
1001+
function mod(x::Int128, y::Int128)
1002+
return Int128(mod(BigInt(x), BigInt(y)))::Int128
1003+
end
1004+
else
1005+
*(x::T, y::T) where {T<:Union{Int128,UInt128}} = mul_int(x, y)
1006+
1007+
div(x::Int128, y::Int128) = checked_sdiv_int(x, y)
1008+
div(x::UInt128, y::UInt128) = checked_udiv_int(x, y)
1009+
1010+
rem(x::Int128, y::Int128) = checked_srem_int(x, y)
1011+
rem(x::UInt128, y::UInt128) = checked_urem_int(x, y)
1012+
end
8611013

8621014
# issue #15489: since integer ops are unchecked, they shouldn't check promotion
8631015
for op in (:+, :-, :*, :&, :|, :xor)

deps/checksums/LibCURL-038790a793203248362cf2bd8d85e42f8c56a72d.tar.gz/md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

deps/checksums/LibCURL-038790a793203248362cf2bd8d85e42f8c56a72d.tar.gz/sha512

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6ba5e31a0c16c674613e1dbff141da43
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cca7f7af9f6ba5bfa74fe3bc5d67fe6f84a1661e3ed5ac4ee0f2e8d7c6c9cc52a2ec818deb4edde01b248ce3de7937d54be9bd20a36e231c9dd3f9ba5eff2bcc

doc/src/devdocs/ast.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,10 @@ for important details on how to modify these fields safely.
658658
The ABI to use when calling `fptr`. Some significant ones include:
659659

660660
* 0 - Not compiled yet
661-
* 1 - `JL_CALLABLE` `jl_value_t *(*)(jl_function_t *f, jl_value_t *args[nargs], uint32_t nargs)`
661+
* 1 - `JL_CALLABLE` `jl_value_t *(*)(jl_value_t *f, jl_value_t *args[nargs], uint32_t nargs)`
662662
* 2 - Constant (value stored in `rettype_const`)
663-
* 3 - With Static-parameters forwarded `jl_value_t *(*)(jl_svec_t *sparams, jl_function_t *f, jl_value_t *args[nargs], uint32_t nargs)`
664-
* 4 - Run in interpreter `jl_value_t *(*)(jl_method_instance_t *meth, jl_function_t *f, jl_value_t *args[nargs], uint32_t nargs)`
663+
* 3 - With Static-parameters forwarded `jl_value_t *(*)(jl_svec_t *sparams, jl_value_t *f, jl_value_t *args[nargs], uint32_t nargs)`
664+
* 4 - Run in interpreter `jl_value_t *(*)(jl_method_instance_t *meth, jl_value_t *f, jl_value_t *args[nargs], uint32_t nargs)`
665665

666666
* `min_world` / `max_world`
667667

doc/src/devdocs/build/build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ On Debian-based distributions (e.g. Ubuntu), you can easily install them with `a
181181
sudo apt-get install build-essential libatomic1 python gfortran perl wget m4 cmake pkg-config curl
182182
```
183183

184+
On Red Hat-based distributions (e.g. Fedora, CentOS), you can install them with `yum`:
185+
```
186+
sudo dnf install gcc gcc-c++ gcc-gfortran python3 perl wget m4 cmake pkgconfig curl
187+
```
188+
184189
Julia uses the following external libraries, which are automatically
185190
downloaded (or in a few cases, included in the Julia source
186191
repository) and then compiled from source the first time you run

doc/src/devdocs/debuggingtips.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ $2 = void
177177

178178
The most recent `jl_apply` is at frame #3, so we can go back there and look at the AST for the
179179
function `julia_convert_16886`. This is the uniqued name for some method of `convert`. `f` in
180-
this frame is a `jl_function_t*`, so we can look at the type signature, if any, from the `specTypes`
180+
this frame is a `jl_value_t*`, so we can look at the type signature, if any, from the `specTypes`
181181
field:
182182

183183
```

0 commit comments

Comments
 (0)