@@ -48,24 +48,6 @@ anymap(f::Function, a::Array{Any,1}) = Any[ f(a[i]) for i in 1:length(a) ]
48
48
49
49
_topmod (m:: Module ) = ccall (:jl_base_relative_to , Any, (Any,), m):: Module
50
50
51
- # ######
52
- # AST #
53
- # ######
54
-
55
- # Meta expression head, these generally can't be deleted even when they are
56
- # in a dead branch but can be ignored when analyzing uses/liveness.
57
- is_meta_expr_head (head:: Symbol ) = head === :boundscheck || head === :meta || head === :loopinfo
58
- is_meta_expr (@nospecialize x) = isa (x, Expr) && is_meta_expr_head (x. head)
59
-
60
- function is_self_quoting (@nospecialize (x))
61
- return isa (x,Number) || isa (x,AbstractString) || isa (x,Tuple) || isa (x,Type) ||
62
- isa (x,Char) || x === nothing || isa (x,Function)
63
- end
64
-
65
- function quoted (@nospecialize (x))
66
- return is_self_quoting (x) ? x : QuoteNode (x)
67
- end
68
-
69
51
# ###########
70
52
# inlining #
71
53
# ###########
@@ -116,10 +98,6 @@ function is_inlineable_constant(@nospecialize(x))
116
98
return count_const_size (x) <= MAX_INLINE_CONST_SIZE
117
99
end
118
100
119
- is_nospecialized (method:: Method ) = method. nospecialize ≠ 0
120
-
121
- is_nospecializeinfer (method:: Method ) = method. nospecializeinfer && is_nospecialized (method)
122
-
123
101
# ##########################
124
102
# MethodInstance/CodeInfo #
125
103
# ##########################
@@ -192,74 +170,12 @@ function get_compileable_sig(method::Method, @nospecialize(atype), sparams::Simp
192
170
mt, atype, sparams, method, #= int return_if_compileable=# 1 )
193
171
end
194
172
195
- function get_nospecializeinfer_sig (method:: Method , @nospecialize (atype), sparams:: SimpleVector )
196
- isa (atype, DataType) || return method. sig
197
- mt = ccall (:jl_method_get_table , Any, (Any,), method)
198
- mt === nothing && return method. sig
199
- return ccall (:jl_normalize_to_compilable_sig , Any, (Any, Any, Any, Any, Cint),
200
- mt, atype, sparams, method, #= int return_if_compileable=# 0 )
201
- end
202
173
203
174
isa_compileable_sig (@nospecialize (atype), sparams:: SimpleVector , method:: Method ) =
204
175
! iszero (ccall (:jl_isa_compileable_sig , Int32, (Any, Any, Any), atype, sparams, method))
205
176
206
- # eliminate UnionAll vars that might be degenerate due to having identical bounds,
207
- # or a concrete upper bound and appearing covariantly.
208
- function subst_trivial_bounds (@nospecialize (atype))
209
- if ! isa (atype, UnionAll)
210
- return atype
211
- end
212
- v = atype. var
213
- if isconcretetype (v. ub) || v. lb === v. ub
214
- subst = try
215
- atype{v. ub}
216
- catch
217
- # Note in rare cases a var bound might not be valid to substitute.
218
- nothing
219
- end
220
- if subst != = nothing
221
- return subst_trivial_bounds (subst)
222
- end
223
- end
224
- return UnionAll (v, subst_trivial_bounds (atype. body))
225
- end
226
-
227
177
has_typevar (@nospecialize (t), v:: TypeVar ) = ccall (:jl_has_typevar , Cint, (Any, Any), t, v) != 0
228
178
229
- # If removing trivial vars from atype results in an equivalent type, use that
230
- # instead. Otherwise we can get a case like issue #38888, where a signature like
231
- # f(x::S) where S<:Int
232
- # gets cached and matches a concrete dispatch case.
233
- function normalize_typevars (method:: Method , @nospecialize (atype), sparams:: SimpleVector )
234
- at2 = subst_trivial_bounds (atype)
235
- if at2 != = atype && at2 == atype
236
- atype = at2
237
- sp_ = ccall (:jl_type_intersection_with_env , Any, (Any, Any), at2, method. sig):: SimpleVector
238
- sparams = sp_[2 ]:: SimpleVector
239
- end
240
- return Pair {Any,SimpleVector} (atype, sparams)
241
- end
242
-
243
- # get a handle to the unique specialization object representing a particular instantiation of a call
244
- @inline function specialize_method (method:: Method , @nospecialize (atype), sparams:: SimpleVector ; preexisting:: Bool = false )
245
- if isa (atype, UnionAll)
246
- atype, sparams = normalize_typevars (method, atype, sparams)
247
- end
248
- if is_nospecializeinfer (method)
249
- atype = get_nospecializeinfer_sig (method, atype, sparams)
250
- end
251
- if preexisting
252
- # check cached specializations
253
- # for an existing result stored there
254
- return ccall (:jl_specializations_lookup , Any, (Any, Any), method, atype):: Union{Nothing,MethodInstance}
255
- end
256
- return ccall (:jl_specializations_get_linfo , Ref{MethodInstance}, (Any, Any, Any), method, atype, sparams)
257
- end
258
-
259
- function specialize_method (match:: MethodMatch ; kwargs... )
260
- return specialize_method (match. method, match. spec_types, match. sparams; kwargs... )
261
- end
262
-
263
179
"""
264
180
is_declared_inline(method::Method) -> Bool
265
181
0 commit comments