Skip to content

Commit dbc808c

Browse files
committed
wip
1 parent cab3d62 commit dbc808c

File tree

7 files changed

+31
-24
lines changed

7 files changed

+31
-24
lines changed

Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
2929
CRC32c = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"
3030
CatIndices = "aafaddc9-749c-510e-ac4f-586e18779b91"
3131
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
32-
Debugger = "31a5f54b-26ea-5ae9-a837-f05ce5417438"
3332
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
3433
EndpointRanges = "340492b5-2a47-5f55-813d-aca7ddf97656"
3534
EponymTuples = "97e2ac4a-e175-5f49-beb1-4d6866a6cdc3"
@@ -58,4 +57,4 @@ SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
5857
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5958

6059
[targets]
61-
test = ["Test", "Base64", "CRC32c", "CatIndices", "Dates", "DelimitedFiles", "EndpointRanges", "EponymTuples", "Example", "Future", "IndirectArrays", "InteractiveUtils", "Libdl", "LinearAlgebra", "Logging", "MappedArrays", "Markdown", "Mmap", "Printf", "Profile", "Random", "Requires", "RoundingIntegers", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "SuiteSparse", "Debugger"]
60+
test = ["Test", "Base64", "CRC32c", "CatIndices", "Dates", "DelimitedFiles", "EndpointRanges", "EponymTuples", "Example", "Future", "IndirectArrays", "InteractiveUtils", "Libdl", "LinearAlgebra", "Logging", "MappedArrays", "Markdown", "Mmap", "Printf", "Profile", "Random", "Requires", "RoundingIntegers", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "SuiteSparse"]

src/legacy_loading.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function parse_pkg_files(id::PkgId)
156156
# To reduce compiler latency, use runtime dispatch for `queue_includes!`.
157157
# `queue_includes!` requires compilation of the whole parsing/expression-splitting infrastructure,
158158
# and it's better to wait to compile it until we actually need it.
159-
worldage[] = Base.get_world_counter()
159+
#worldage[] = Base.get_world_counter()
160160
invoke_revisefunc(queue_includes!, pkgdata, id)
161161
return pkgdata
162162
end

src/loading.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ function parse_pkg_files(id::PkgId)
4848
# To reduce compiler latency, use runtime dispatch for `queue_includes!`.
4949
# `queue_includes!` requires compilation of the whole parsing/expression-splitting infrastructure,
5050
# and it's better to wait to compile it until we actually need it.
51-
worldage[] = Base.get_world_counter()
5251
invoke_revisefunc(queue_includes!, pkgdata, id)
5352
return pkgdata
5453
end

src/lowered.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ The other keyword arguments are more straightforward:
177177
function methods_by_execution!(@nospecialize(recurse), methodinfo, docexprs, mod::Module, ex::Expr;
178178
mode::Symbol=:eval, disablebp::Bool=true, always_rethrow::Bool=false, kwargs...)
179179
mode (:sigs, :eval, :evalmeth, :evalassign) || error("unsupported mode ", mode)
180-
lwr = _lower(mod, ex, worldage[])
180+
lwr = lower_in_reviseworld(mod, ex)
181181
isa(lwr, Expr) || return nothing, nothing
182182
if lwr.head === :error || lwr.head === :incomplete
183183
error("lowering returned an error, ", lwr)

src/packagedef.jl

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,14 @@ const silence_pkgs = Set{Symbol}()
198198
const depsdir = joinpath(dirname(@__DIR__), "deps")
199199
const silencefile = Ref(joinpath(depsdir, "silence.txt")) # Ref so that tests don't clobber
200200

201-
#"""
202-
# Revise.worldage
203-
#
204-
#The world age Revise was started in. Needed so that Revise doesn't delete methods
205-
#from under itself.
206-
#"""
207-
#const worldage = Ref{Union{Nothing,UInt}}(nothing)
208-
using CodeTracking: worldage
201+
"""
202+
Revise.worldage
203+
204+
The world age Revise was started in. Needed so that Revise doesn't delete methods
205+
from under itself.
206+
"""
207+
const worldage = Ref{Union{Nothing,UInt}}(nothing)
208+
#using CodeTracking: worldage
209209

210210
##
211211
## The inputs are sets of expressions found in each file.
@@ -639,6 +639,7 @@ function handle_deletions(pkgdata, file)
639639
topmod = first(keys(mexsold))
640640
fileok = file_exists(filep)
641641
mexsnew = fileok ? parse_source(filep, topmod) : ModuleExprsSigs(topmod)
642+
worldage[] = Base.get_world_counter()
642643
if mexsnew !== nothing
643644
delete_missing!(mexsold, mexsnew)
644645
end
@@ -732,6 +733,7 @@ function revise(; throw=false)
732733

733734
# Do all the deletion first. This ensures that a method that moved from one file to another
734735
# won't get redefined first and deleted second.
736+
@show worldage[] = Base.get_world_counter()
735737
revision_errors = []
736738
queue = sort!(collect(revision_queue); lt=pkgfileless)
737739
finished = eltype(revision_queue)[]
@@ -764,6 +766,7 @@ function revise(; throw=false)
764766
mode (:sigs, :eval, :evalmeth, :evalassign) || error("unsupported mode ", mode)
765767
exsold = get(fi.modexsigs, mod, empty_exs_sigs)
766768
for rex in keys(exsnew)
769+
@show Base.get_world_counter()
767770
sigs, includes = eval_rex(rex, exsold, mod; mode=mode)
768771
if sigs !== nothing
769772
exsnew[rex] = sigs
@@ -1191,13 +1194,17 @@ if VERSION < v"1.6.0-DEV.1162"
11911194
const lower_in_reviseworld = Meta.lower
11921195
else
11931196
function invoke_revisefunc(f, args...; kwargs...)
1194-
@show worldage[]
1195-
Base.show_backtrace(backtrace[1:2])
1197+
#@show worldage[]
1198+
#@show Base.get_world_counter()
1199+
#Base.show_backtrace(stdout, backtrace()[1:4])
1200+
#println()
11961201
return Base.invoke_in_world(worldage[], f, args...; kwargs...)
11971202
end
11981203
function lower_in_reviseworld(m::Module, @nospecialize(ex))
1199-
@show worldage[]
1200-
Base.show_backtrace(backtrace[1:2])
1204+
#@show worldage[]
1205+
#@show Base.get_world_counter()
1206+
#Base.show_backtrace(stdout, backtrace()[1:1])
1207+
#println()
12011208
return ccall(:jl_expand_in_world, Any,
12021209
(Any, Ref{Module}, Cstring, Cint, Csize_t),
12031210
ex, m, "none", 0, worldage[],
@@ -1209,7 +1216,7 @@ end
12091216
# This uses invokelatest not for reasons of world age but to ensure that the call is made at runtime.
12101217
# This allows `revise_first` to be compiled without compiling `revise` itself, and greatly
12111218
# reduces the overhead of using Revise.
1212-
revise_first(ex) = Expr(:toplevel, :(isempty($revision_queue) || (worldage[] = Base.get_world_counter(); invoke_revisefunc($revise))), ex)
1219+
revise_first(ex) = Expr(:toplevel, :(isempty($revision_queue) || (#=worldage[] = Base.get_world_counter(); =#invoke_revisefunc($revise))), ex)
12131220

12141221
@noinline function run_backend(backend)
12151222
while true
@@ -1362,6 +1369,8 @@ function __init__()
13621369
# Set the lookup callbacks
13631370
CodeTracking.method_lookup_callback[] = x -> (worldage[] = Base.get_world_counter(); invoke_revisefunc(get_def, x))
13641371
CodeTracking.expressions_callback[] = x -> (worldage[] = Base.get_world_counter(); invoke_revisefunc(get_expressions, x))
1372+
CodeTracking.method_lookup_callback[] = get_def
1373+
CodeTracking.expressions_callback[] = get_expressions
13651374

13661375
# Watch the manifest file for changes
13671376
mfile = manifest_file()

src/pkgs.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ function maybe_add_includes_to_pkgdata!(pkgdata::PkgData, file::AbstractString,
171171
parse_source!(fi.modexsigs, fullfile, mod)
172172
if eval_now
173173
# Use runtime dispatch to reduce latency
174-
Base.invoke_in_world(worldage[], instantiate_sigs!, fi.modexsigs; mode=:eval)
174+
#Base.invoke_in_world(worldage[], instantiate_sigs!, fi.modexsigs; mode=:eval)
175+
Base.invokelatest(instantiate_sigs!, fi.modexsigs; mode=:eval)
175176
end
176177
end
177178
# Add to watchlist
@@ -237,7 +238,8 @@ function _add_require(sourcefile, modcaller, idmod, modname, expr)
237238
end
238239
end
239240
if complex
240-
Base.invoke_in_world(worldage[], eval_require_now, pkgdata, fileidx, filekey, sourcefile, modcaller, expr)
241+
#Base.invoke_in_world(worldage[], eval_require_now, pkgdata, fileidx, filekey, sourcefile, modcaller, expr)
242+
Base.invokelatest(eval_require_now, pkgdata, fileidx, filekey, sourcefile, modcaller, expr)
241243
end
242244
finally
243245
unlock(requires_lock)

test/runtests.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ using Revise.CodeTracking
44
using Revise.JuliaInterpreter
55
using Test
66

7-
@show VERSION
8-
97
@test isempty(detect_ambiguities(Revise))
108

119
using Pkg, Unicode, Distributed, InteractiveUtils, REPL, UUIDs
@@ -473,8 +471,8 @@ end
473471
@eval @test $(fn4)() == 4
474472
@eval @test $(fn5)() == 5
475473
@eval @test $(fn6)() == 6
476-
m = @show @eval first(methods($fn1))
477-
rex = Revise.RelocatableExpr(@show definition(m))
474+
m = @eval first(methods($fn1))
475+
rex = Revise.RelocatableExpr(definition(m))
478476
@test rex == Revise.RelocatableExpr(:( $fn1() = 1 ))
479477
# Check that definition returns copies
480478
rex2 = deepcopy(rex)

0 commit comments

Comments
 (0)