Skip to content

Commit

Permalink
add extra convenience kwargs to CustomParams and code_typed
Browse files Browse the repository at this point in the history
  • Loading branch information
jrevels committed Dec 21, 2018
1 parent c8c48a2 commit 6646d1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 6 additions & 3 deletions base/compiler/params.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,19 @@ struct Params
inline_cost_threshold::Int = DEFAULT_PARAMS.inline_cost_threshold,
inline_nonleaf_penalty::Int = DEFAULT_PARAMS.inline_nonleaf_penalty,
inline_tupleret_bonus::Int = DEFAULT_PARAMS.inline_tupleret_bonus,
ipo_constant_propagation::Bool = true,
aggressive_constant_propagation::Bool = false,
max_methods::Int = DEFAULT_PARAMS.MAX_METHODS,
tupletype_depth::Int = DEFAULT_PARAMS.TUPLE_COMPLEXITY_LIMIT_DEPTH,
tuple_splat::Int = DEFAULT_PARAMS.MAX_TUPLE_SPLAT,
union_splitting::Int = DEFAULT_PARAMS.MAX_UNION_SPLITTING,
apply_union_enum::Int = DEFAULT_PARAMS.MAX_APPLY_UNION_ENUM)
return new(Vector{InferenceResult}(),
world, false,
inlining, true, false, inline_cost_threshold, inline_nonleaf_penalty,
inline_tupleret_bonus, max_methods, union_splitting, apply_union_enum,
tupletype_depth, tuple_splat)
inlining, ipo_constant_propagation, aggressive_constant_propagation,
inline_cost_threshold, inline_nonleaf_penalty, inline_tupleret_bonus,
max_methods, union_splitting, apply_union_enum, tupletype_depth,
tuple_splat)
end
function Params(world::UInt)
inlining = inlining_enabled()
Expand Down
7 changes: 4 additions & 3 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,10 @@ generic function and type signature. The keyword argument `optimize` controls wh
additional optimizations, such as inlining, are also applied.
The keyword debuginfo controls the amount of code metadata present in the output.
"""
function code_typed(@nospecialize(f), @nospecialize(types=Tuple); optimize=true, debuginfo::Symbol=:default)
function code_typed(@nospecialize(f), @nospecialize(types=Tuple);
optimize=true, debuginfo::Symbol=:default,
world = ccall(:jl_get_world_counter, UInt, ()),
params = Core.Compiler.Params(world))
ccall(:jl_is_in_pure_context, Bool, ()) && error("code reflection cannot be used from generated functions")
if isa(f, Core.Builtin)
throw(ArgumentError("argument is not a generic function"))
Expand All @@ -954,8 +957,6 @@ function code_typed(@nospecialize(f), @nospecialize(types=Tuple); optimize=true,
end
types = to_tuple_type(types)
asts = []
world = ccall(:jl_get_world_counter, UInt, ())
params = Core.Compiler.Params(world)
for x in _methods(f, types, -1, world)
meth = func_for_method_checked(x[3], types)
(code, ty) = Core.Compiler.typeinf_code(meth, x[1], x[2], optimize, params)
Expand Down

0 comments on commit 6646d1e

Please sign in to comment.