Skip to content

Commit 6b36a30

Browse files
committed
add expand_early field to GeneratedFunctionStub [ci skip]
1 parent e4e9ea7 commit 6b36a30

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

base/boot.jl

+1
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ struct GeneratedFunctionStub
454454
spnames::Union{Void, Array{Any,1}}
455455
line::Int
456456
file::Symbol
457+
expand_early::Bool
457458
end
458459

459460
# invoke and wrap the results of @generated

base/inference.jl

+15-12
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,20 @@ end
19111911

19121912
function method_for_inference_heuristics(infstate::InferenceState)
19131913
m = infstate.src.method_for_inference_heuristics
1914-
return m === nothing ? infstate.linfo.def : m
1914+
return isa(m, Method) ? m : infstate.linfo.def
1915+
end
1916+
1917+
function method_for_inference_heuristics(method::Method, @nospecialize(sig), sparams, world)
1918+
if isdefined(method, :generator) && method.generator.expand_early
1919+
method_instance = code_for_method(method, sig, sparams, world, false)
1920+
if isa(method_instance, MethodInstance)
1921+
cinfo = get_staged(method_instance)
1922+
if isa(cinfo, CodeInfo) && isa(cinfo.method_for_inference_heuristics, Method)
1923+
return cinfo.method_for_inference_heuristics
1924+
end
1925+
end
1926+
end
1927+
return method
19151928
end
19161929

19171930
function abstract_call_method(method::Method, @nospecialize(f), @nospecialize(sig), sparams::SimpleVector, sv::InferenceState)
@@ -1922,17 +1935,7 @@ function abstract_call_method(method::Method, @nospecialize(f), @nospecialize(si
19221935
# Returns the topmost occurrence of that repeated edge.
19231936
cyclei = 0
19241937
infstate = sv
1925-
if isdefined(method, :generator) # && method.generator.expand_early
1926-
method_instance = code_for_method(method, sig, sparams, sv.params.world, false)
1927-
if isa(method_instance, MethodInstance)
1928-
cinfo = get_staged(method_instance)
1929-
if isa(cinfo, CodeInfo) && isa(cinfo.method_for_inference_heuristics, Method)
1930-
checked_method = cinfo.method_for_inference_heuristics
1931-
end
1932-
end
1933-
else
1934-
checked_method = method
1935-
end
1938+
checked_method = method_for_inference_heuristics(method, sig, sparams, sv.params.world)
19361939
while !(infstate === nothing)
19371940
infstate = infstate::InferenceState
19381941
if method === infstate.linfo.def && infstate.linfo.specTypes == sig

src/julia-syntax.scm

+2-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@
362362
'nothing
363363
(cons 'list (map car sparams)))
364364
,(if (null? loc) 0 (cadr loc))
365-
(inert ,(if (null? loc) 'none (caddr loc))))))))
365+
(inert ,(if (null? loc) 'none (caddr loc)))
366+
false)))))
366367
(list gf))
367368
'()))
368369
(types (llist-types argl))

src/method.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ static void jl_method_set_source(jl_method_t *m, jl_code_info_t *src)
419419
else if (jl_expr_nargs(st) == 2 && jl_exprarg(st, 0) == (jl_value_t*)generated_sym) {
420420
m->generator = NULL;
421421
jl_value_t *gexpr = jl_exprarg(st, 1);
422-
if (jl_expr_nargs(gexpr) == 6) {
423-
// expects (new (core GeneratedFunctionStub) funcname argnames sp line file)
422+
if (jl_expr_nargs(gexpr) == 7) {
423+
// expects (new (core GeneratedFunctionStub) funcname argnames sp line file expandearly)
424424
jl_value_t *funcname = jl_exprarg(gexpr, 1);
425425
assert(jl_is_symbol(funcname));
426426
if (jl_get_global(m->module, (jl_sym_t*)funcname) != NULL) {

0 commit comments

Comments
 (0)