Skip to content

Commit 256f784

Browse files
committed
Fix some performance issues due to new InexactError
1 parent 3d11ba2 commit 256f784

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

base/inference.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct InferenceParams
2929
# reasonable defaults
3030
function InferenceParams(world::UInt;
3131
inlining::Bool = inlining_enabled(),
32-
inline_cost_threshold::Int = 100,
32+
inline_cost_threshold::Int = 150,
3333
inline_nonleaf_penalty::Int = 1000,
3434
inline_tupleret_bonus::Int = 400,
3535
max_methods::Int = 4,

base/int.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ const BitIntegerSmall = Union{BitIntegerSmall_types...}
2929
const BitSigned64T = Union{Type{Int8}, Type{Int16}, Type{Int32}, Type{Int64}}
3030
const BitUnsigned64T = Union{Type{UInt8}, Type{UInt16}, Type{UInt32}, Type{UInt64}}
3131

32+
throw_inexacterror(f::Symbol, ::Type{T}, val) where T =
33+
(@_noinline_meta; throw(InexactError(f, T, val)))
34+
3235
## integer comparisons ##
3336

3437
(<)(x::T, y::T) where {T<:BitSigned} = slt_int(x, y)
@@ -401,7 +404,7 @@ function is_top_bit_set(x::BitInteger)
401404
end
402405
function check_top_bit(x::BitInteger)
403406
@_inline_meta
404-
is_top_bit_set(x) && throw(InexactError(:check_top_bit, Integer, x))
407+
is_top_bit_set(x) && throw_inexacterror(:check_top_bit, typeof(x), x)
405408
x
406409
end
407410

@@ -411,15 +414,15 @@ function checked_trunc_sint{To,From}(::Type{To}, x::From)
411414
@_inline_meta
412415
y = trunc_int(To, x)
413416
back = sext_int(From, y)
414-
x == back || throw(InexactError(:trunc, To, x))
417+
x == back || throw_inexacterror(:trunc, To, x)
415418
y
416419
end
417420

418421
function checked_trunc_uint{To,From}(::Type{To}, x::From)
419422
@_inline_meta
420423
y = trunc_int(To, x)
421424
back = zext_int(From, y)
422-
x == back || throw(InexactError(:trunc, To, x))
425+
x == back || throw_inexacterror(:trunc, To, x)
423426
y
424427
end
425428

0 commit comments

Comments
 (0)