26
26
end
27
27
28
28
# Use caller's world age.
29
- const _caller_world = typemax (UInt)
30
- const _parser_world_age = Ref {UInt} (_caller_world )
29
+ const _latest_world = typemax (UInt)
30
+ const _parser_world_age = Ref {UInt} (_latest_world )
31
31
32
32
function core_parser_hook (code, filename, lineno, offset, options)
33
- # `hook` is always _core_parser_hook, but that's hidden from the compiler
34
- # via a Ref to prevent invalidation / recompilation when other packages are
35
- # loaded. This wouldn't seem like it should be necessary given the use of
36
- # invoke_in_world, but it is in Julia-1.7.3. I'm not sure exactly which
37
- # latency it's removing.
38
- hook = _core_parser_hook_ref[]
39
- if _parser_world_age[] != _caller_world
40
- Base. invoke_in_world (_parser_world_age[], hook,
33
+ # NB: We need an inference barrier of one type or another here to prevent
34
+ # invalidations. The invokes provide this currently.
35
+ if _parser_world_age[] != _latest_world
36
+ Base. invoke_in_world (_parser_world_age[], _core_parser_hook,
41
37
code, filename, lineno, offset, options)
42
38
else
43
- hook ( code, filename, lineno, offset, options)
39
+ Base . invokelatest (_core_parser_hook, code, filename, lineno, offset, options)
44
40
end
45
41
end
46
42
150
146
Base. Meta. ParseError (e:: JuliaSyntax.ParseError ) = e
151
147
152
148
const _default_parser = Core. _parse
153
- # NB: Never reassigned, but the compiler doesn't know this!
154
- const _core_parser_hook_ref = Ref {Function} (_core_parser_hook)
155
149
156
150
"""
157
151
enable_in_core!([enable=true; freeze_world_age, debug_filename])
@@ -169,7 +163,7 @@ Keyword arguments:
169
163
"""
170
164
function enable_in_core! (enable= true ; freeze_world_age = true ,
171
165
debug_filename = get (ENV , " JULIA_SYNTAX_DEBUG_FILE" , nothing ))
172
- _parser_world_age[] = freeze_world_age ? Base. get_world_counter () : _caller_world
166
+ _parser_world_age[] = freeze_world_age ? Base. get_world_counter () : _latest_world
173
167
if enable && ! isnothing (debug_filename)
174
168
_debug_log[] = open (debug_filename, " w" )
175
169
elseif ! enable && ! isnothing (_debug_log[])
0 commit comments