You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of hiding the fragments of the method table in each TypeName, make one
variable `Core.GlobalMethods` with access to all methods. The need to split
them early for performance apparently had been long past since kwargs and
constructors were already using a single table and cache anyways. Some new
concepts introduced here:
- A single Method can now be added to multiple functions. So instead of using
eval in a for loop, we could define it just once (see example below).
- Several fields (`max_args`, `name`, and `backedges`) were moved from
MethodTable to their TypeName.
- TypeName currently has a (user-modifiable) field called `singletonname`. If
set to something other than `name`, it may be used for pretty printing of a
singleton object using its "canonical" (unmangled) name, particularly for
`function`.
- `Core.Builtin` method table entries are even more normal now, with valid
`sig` fields, and special logic to specifically prevent adding methods which
would become ambiguous with them (as that would violate the tfuncs we have
for them).
- `Core.GlobalMethods` is a `Base.Experimental.@MethodTable GlobalMethods`.
- Each `MethodTable` contains a separate `MethodCache` object for managing
fast dispatch lookups. We may want to use this for the `Method` field
containing the `invokes` list so that lookups there get more of the same
optimizations as global calls.
- Methods could be put into any number of different MethodTables (or none).
The `Method.primary_world` field is intended to reflect whether it is
currently put into the GlobalMethods table, and what world to use in the
GlobalMethods table for running its generator, and otherwise is meaningless.
- The lock for TypeName backedges is a single global lock now, in
`Core.GlobalMethods.mc`.
- The `backedges` in TypeName are stored on the "top-most" typename in the
hierarchy, to enable efficient lookup (although we might want to consider
replacing this entirely with a TypeMap). The "top-most" typename is the
typename of the type closest to Any, after union-splitting, which doesn't
have an intersection with Builtin (so Function and Any by implication
continue to not require scanning for missing backedges since it is not
permitted to add a Method applicable to all functions).
- Support for having backedges from experimental method tables was removed
since it was unsound and had been already replaced with staticdata.jl
several months ago.
- Documentation lookup for `IncludeInto` is fixed (previously attached only to
`Main.include` instead of all `include` functions).
Example: given this existing code in base/operators:
for op in (:+, :*, :&, :|, :xor, :min, :max, :kron)
@eval begin
($op)(a, b, c, xs...) = (@inline; afoldl($op, ($op)(($op)(a,b),c), xs...))
end
end
It could now instead be equivalently written as:
let ops = Union{typeof(+), typeof(*), typeof(&), typeof(|), typeof(xor), typeof(min), typeof(max), typeof(kron)}
(op::ops)(a, b, c, xs...) = (@inline; afoldl(op, (op)((op)(a,b),c), xs...))
end
FixesJuliaLang#57560
Copy file name to clipboardExpand all lines: Compiler/src/tfuncs.jl
+1-4Lines changed: 1 addition & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -3199,15 +3199,12 @@ function _hasmethod_tfunc(interp::AbstractInterpreter, argtypes::Vector{Any}, sv
3199
3199
isdispatchelem(ft) ||returnCallMeta(Bool, Any, Effects(), NoCallInfo()) # check that we might not have a subtype of `ft` at runtime, before doing supertype lookup below
0 commit comments