@@ -493,8 +493,31 @@ function uncompressed_ast(m::Method, s::CodeInfo)
493
493
return s
494
494
end
495
495
496
+ # this type mirrors jl_cgparams_t (documented in julia.h)
497
+ immutable CodegenParams
498
+ cached:: Cint
499
+
500
+ runtime:: Cint
501
+ exceptions:: Cint
502
+ track_allocations:: Cint
503
+ code_coverage:: Cint
504
+ static_alloc:: Cint
505
+ dynamic_alloc:: Cint
506
+
507
+ CodegenParams (;cached:: Bool = true ,
508
+ runtime:: Bool = true , exceptions:: Bool = true ,
509
+ track_allocations:: Bool = true , code_coverage:: Bool = true ,
510
+ static_alloc:: Bool = true , dynamic_alloc:: Bool = true ) =
511
+ new (Cint (cached),
512
+ Cint (runtime), Cint (exceptions),
513
+ Cint (track_allocations), Cint (code_coverage),
514
+ Cint (static_alloc), Cint (dynamic_alloc))
515
+ end
516
+
496
517
# Printing code representations in IR and assembly
497
- function _dump_function (f:: ANY , t:: ANY , native:: Bool , wrapper:: Bool , strip_ir_metadata:: Bool , dump_module:: Bool , syntax:: Symbol = :att )
518
+ function _dump_function (f:: ANY , t:: ANY , native:: Bool , wrapper:: Bool ,
519
+ strip_ir_metadata:: Bool , dump_module:: Bool , syntax:: Symbol = :att ,
520
+ optimize:: Bool = true , params:: CodegenParams = CodegenParams ())
498
521
ccall (:jl_is_in_pure_context , Bool, ()) && error (" code reflection cannot be used from generated functions" )
499
522
if isa (f, Core. Builtin)
500
523
throw (ArgumentError (" argument is not a generic function" ))
@@ -509,17 +532,19 @@ function _dump_function(f::ANY, t::ANY, native::Bool, wrapper::Bool, strip_ir_me
509
532
meth = func_for_method_checked (meth, tt)
510
533
linfo = ccall (:jl_specializations_get_linfo , Ref{Core. MethodInstance}, (Any, Any, Any), meth, tt, env)
511
534
# get the code for it
512
- return _dump_function (linfo, native, wrapper, strip_ir_metadata, dump_module, syntax)
535
+ return _dump_function (linfo, native, wrapper, strip_ir_metadata, dump_module, syntax, optimize, params )
513
536
end
514
537
515
- function _dump_function (linfo:: Core.MethodInstance , native:: Bool , wrapper:: Bool , strip_ir_metadata:: Bool , dump_module:: Bool , syntax:: Symbol = :att )
538
+ function _dump_function (linfo:: Core.MethodInstance , native:: Bool , wrapper:: Bool ,
539
+ strip_ir_metadata:: Bool , dump_module:: Bool , syntax:: Symbol = :att ,
540
+ optimize:: Bool = true , params:: CodegenParams = CodegenParams ())
516
541
if syntax != :att && syntax != :intel
517
542
throw (ArgumentError (" 'syntax' must be either :intel or :att" ))
518
543
end
519
544
if native
520
- llvmf = ccall (:jl_get_llvmf_decl , Ptr{Void}, (Any, Bool), linfo, wrapper)
545
+ llvmf = ccall (:jl_get_llvmf_decl , Ptr{Void}, (Any, Bool, CodegenParams ), linfo, wrapper, params )
521
546
else
522
- llvmf = ccall (:jl_get_llvmf_defn , Ptr{Void}, (Any, Bool), linfo, wrapper)
547
+ llvmf = ccall (:jl_get_llvmf_defn , Ptr{Void}, (Any, Bool, Bool, CodegenParams ), linfo, wrapper, optimize, params )
523
548
end
524
549
if llvmf == C_NULL
525
550
error (" could not compile the specified method" )
0 commit comments