• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

JuliaLang / julia / #37632

26 Sep 2023 06:44AM UTC coverage: 86.999% (-0.9%) from 87.914%
#37632

push

local

web-flow
inference: make `throw` block deoptimization concrete-eval friendly (#49235)

The deoptimization can sometimes destroy the effects analysis and
disable [semi-]concrete evaluation that is otherwise possible. This is
because the deoptimization was designed with the type domain
profitability in mind (#35982), and hasn't been adequately considering
the effects domain.

This commit makes the deoptimization aware of the effects domain more
and enables the `throw` block deoptimization only when the effects
already known to be ineligible for concrete-evaluation.

In our current effect system, `ALWAYS_FALSE`/`false` means that the
effect can not be refined to `ALWAYS_TRUE`/`true` anymore (unless given
user annotation later). Therefore we can enable the `throw` block
deoptimization without hindering the chance of concrete-evaluation when
any of the following conditions are met:
- `effects.consistent === ALWAYS_FALSE`
- `effects.effect_free === ALWAYS_FALSE`
- `effects.terminates === false`
- `effects.nonoverlayed === false`

Here are some numbers:

| Metric | master | this commit | #35982 reverted (set
`unoptimize_throw_blocks=false`) |

|-------------------------|-----------|-------------|--------------------------------------------|
| Base (seconds) | 15.579300 | 15.206645 | 15.296319 |
| Stdlibs (seconds) | 17.919013 | 17.667094 | 17.738128 |
| Total (seconds) | 33.499279 | 32.874737 | 33.035448 |
| Precompilation (seconds) | 49.967516 | 49.421121 | 49.999998 |
| First time `plot(rand(10,3))` [^1] | `2.476678 seconds (11.74 M
allocations)` | `2.430355 seconds (11.77 M allocations)` | `2.514874
seconds (11.64 M allocations)` |
| First time `solve(prob, QNDF())(5.0)` [^2] | `4.469492 seconds (15.32
M allocations)` | `4.499217 seconds (15.41 M allocations)` | `4.470772
seconds (15.38 M allocations)` |

[^1]: With disabling precompilation of Plots.jl.
[^2]: With disabling precompilation of OrdinaryDiffEq.

These numbers ma... (continued)

7 of 7 new or added lines in 1 file covered. (100.0%)

73407 of 84377 relevant lines covered (87.0%)

11275130.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.0
/base/docs/utils.jl
1
# This file is a part of Julia. License is MIT: https://julialang.org/license
2

3
# Text / HTML objects
4

5
import .Base: print, show, ==, hash
6

7
export HTML, @html_str
8

9
export HTML, Text
10

11
"""
12
`HTML(s)`: Create an object that renders `s` as html.
13

14
    HTML("<div>foo</div>")
15

16
You can also use a stream for large amounts of data:
17

18
    HTML() do io
19
      println(io, "<div>foo</div>")
20
    end
21

22
!!! warning
23
    `HTML` is currently exported to maintain
24
    backwards compatibility, but this export
25
    is deprecated. It is recommended to use
26
    this type as `Docs.HTML` or to explicitly
27
    import it from `Docs`.
28
"""
29
mutable struct HTML{T}
30
    content::T
2✔
31
end
32

33
function HTML(xs...)
×
34
    HTML() do io
×
35
        for x in xs
×
36
            print(io, x)
×
37
        end
×
38
    end
39
end
40

41
show(io::IO, ::MIME"text/html", h::HTML) = print(io, h.content)
×
42
show(io::IO, ::MIME"text/html", h::HTML{<:Function}) = h.content(io)
×
43

44
"""
45
    @html_str -> Docs.HTML
46

47
Create an `HTML` object from a literal string.
48

49
# Examples
50
```jldoctest
51
julia> html"Julia"
52
HTML{String}("Julia")
53
```
54
"""
55
macro html_str(s)
1✔
56
    :(HTML($s))
1✔
57
end
58

59
function catdoc(xs::HTML...)
1✔
60
    HTML() do io
1✔
61
        for x in xs
62
            show(io, MIME"text/html"(), x)
63
        end
64
    end
65
end
66

67
export Text, @text_str
68

69
"""
70
`Text(s)`: Create an object that renders `s` as plain text.
71

72
    Text("foo")
73

74
You can also use a stream for large amounts of data:
75

76
    Text() do io
77
      println(io, "foo")
78
    end
79

80
!!! warning
81
    `Text` is currently exported to maintain
82
    backwards compatibility, but this export
83
    is deprecated. It is recommended to use
84
    this type as `Docs.Text` or to explicitly
85
    import it from `Docs`.
86
"""
87
mutable struct Text{T}
88
    content::T
3✔
89
end
90

91
print(io::IO, t::Text) = print(io, t.content)
1✔
92
print(io::IO, t::Text{<:Function}) = t.content(io)
1✔
93
show(io::IO, t::Text) = print(io, t)
2✔
94

95
==(t1::T, t2::T) where {T<:Union{HTML,Text}} = t1.content == t2.content
×
96
hash(t::T, h::UInt) where {T<:Union{HTML,Text}} = hash(T, hash(t.content, h))
×
97

98
"""
99
    @text_str -> Docs.Text
100

101
Create a `Text` object from a literal string.
102

103
# Examples
104
```jldoctest
105
julia> text"Julia"
106
Julia
107
```
108
"""
109
macro text_str(s)
1✔
110
    :(Text($s))
1✔
111
end
112

113
function catdoc(xs::Text...)
1✔
114
    Text() do io
1✔
115
        for x in xs
1✔
116
            show(io, MIME"text/plain"(), x)
1✔
117
        end
1✔
118
    end
119
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc