Skip to content

Commit

Permalink
more adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Jan 5, 2024
1 parent ee27f94 commit f8bba03
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
17 changes: 9 additions & 8 deletions src/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ function lookup_expr(frame, e::Expr)
error("invalid lookup expr ", e)

Check warning on line 77 in src/interpret.jl

View check run for this annotation

Codecov / codecov/patch

src/interpret.jl#L77

Added line #L77 was not covered by tests
end


# This is used only for new struct/abstract/primitive nodes.
# The most important issue is that in these expressions, :call Exprs can be nested,
# and hence our re-use of the `callargs` field of Frame would introduce
Expand All @@ -103,18 +102,20 @@ function lookup_or_eval(@nospecialize(recurse), frame, @nospecialize(node))
f = ex.args[1]
if f === Core.svec
popfirst!(ex.args)
return f(ex.args...)
return Core.svec(ex.args...)
elseif f === Core.apply_type
popfirst!(ex.args)
return f(ex.args...)
elseif f === Core.typeof && length(ex.args) == 2
return f(ex.args[2])
return Core.apply_type(ex.args...)
elseif f === typeof && length(ex.args) == 2
return typeof(ex.args[2])

Check warning on line 110 in src/interpret.jl

View check run for this annotation

Codecov / codecov/patch

src/interpret.jl#L110

Added line #L110 was not covered by tests
elseif f === typeassert && length(ex.args) == 3
return typeassert(ex.args[2], ex.args[3])
elseif f === Base.getproperty && length(ex.args) == 3
return f(ex.args[2], ex.args[3])
return Base.getproperty(ex.args[2], ex.args[3])
elseif f === Core.Compiler.Val && length(ex.args) == 2
return f(ex.args[2])
return Core.Compiler.Val(ex.args[2])
elseif f === Val && length(ex.args) == 2
return f(ex.args[2])
return Val(ex.args[2])
else
Base.invokelatest(error, "unknown call f introduced by ccall lowering ", f)

Check warning on line 120 in src/interpret.jl

View check run for this annotation

Codecov / codecov/patch

src/interpret.jl#L120

Added line #L120 was not covered by tests
end
Expand Down
2 changes: 0 additions & 2 deletions src/optimize.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const calllike = (:call, :foreigncall)

const compiled_calls = Dict{Any,Any}()

# Pre-frame-construction lookup
Expand Down
5 changes: 0 additions & 5 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ which will cause all calls to be evaluated via the interpreter.
struct Compiled end
Base.similar(::Compiled, sz) = Compiled() # to support similar(stack, 0)

# A type used transiently in renumbering CodeInfo SSAValues (to distinguish a new SSAValue from an old one)
struct NewSSAValue
id::Int
end

# Our own replacements for Core types. We need to do this to ensure we can tell the difference
# between "data" (Core types) and "code" (our types) if we step into Core.Compiler
struct SSAValue
Expand Down
4 changes: 4 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ function scan_ssa_use!(used::BitSet, @nospecialize(stmt))
while iterval !== nothing
useref, state = iterval
val = Core.Compiler.getindex(useref)
if isexpr(val, :call)
# work around for a linearization bug in Julia (https://github.com/JuliaLang/julia/pull/52497)
scan_ssa_use!(used, val)
end
if isa(val, SSAValue)
push!(used, val.id)
end
Expand Down

0 comments on commit f8bba03

Please sign in to comment.