[m-rev.] for review: ssdb events for standard library
Julien Fischer
juliensf at csse.unimelb.edu.au
Fri May 28 02:44:42 AEST 2010
On Thu, 27 May 2010, Peter Wang wrote:
> I think this change is safe for 10.04 as well.
It should be fine, the major differences between the trunk are in the
runtime and deep_profiler directories.
> Branches: main, 10.04
>
> The source-to-source transformation is disabled on standard library modules
> because it would introduce cyclic dependencies between ssdb.m and the standard
> library. Disabling the transformation on the standard library is also useful
> for maintaining decent performance. However, no events are generated for calls
> to standard library procedures.
>
> In this patch, we introduce something like shallow tracing, for standard
> library procedures. Before the main ssdebug transformation, we replace calls
> and closures involving standard library predicates by local proxy predicates
> that simply forward the calls to the original predicates. During the main
> ssdebug pass the proxies are transformed as usual, so at runtime they will
> generate interface events, but in the guise of the predicates they proxy.
>
> compiler/ssdebug.m:
> Add the proxy predicates pass.
>
> Make the main ssdebug transformation handle proxy predicates specially,
> so the events look like they come from the original procedure.
>
> Don't perform the ssdebug transformation on procedures with arguments
> which are not fully input or fully output. This was previously only
> done for semidet procedures.
>
> Remove imports of unused modules.
>
> compiler/hlds_pred.m:
> Add pred_info_get_sym_name.
>
> compiler/layout_out.m:
> compiler/mercury_compile_middle_passes.m:
> Conform to changes.
>
...
> index acb310e..207647e 100755
> --- a/compiler/ssdebug.m
> +++ b/compiler/ssdebug.m
> @@ -7,13 +7,11 @@
> %-----------------------------------------------------------------------------%
> %
> % Module: transform_hlds.ssdebug.m.
> -% Main authors: oannet.
> +% Authors: oannet, wangp.
> %
> % The ssdebug module does a source to source tranformation on each procedure
> % which allows the procedure to be debugged.
> %
> -% XXX Only user-made procedures are debugged, not yet the library procedures.
> -%
> % Here is the transformation:
> %
> % original:
> @@ -120,7 +118,6 @@
> % )
> % ).
> %
> -%
> % detism_erroneous:
> %
> % p(...) :-
> @@ -130,7 +127,6 @@
> % <original body>
> % ).
> %
> -%
> % where CallVarDescs, ExitVarDescs are lists of var_value
> %
> % :- type var_value
> @@ -150,6 +146,15 @@
> %
> % The ProcId is of type ssdb.ssdb_proc_id.
> %
> +% The transformation is disabled on standard library predicates, because it
> +% would introduce cyclic dependencies between ssdb.m and the standard library.
> +% Programs in ssdebug grades already run rather slowly, so disabling the
> +% transformation on the standard library also improves the performance.
> +%
> +% Instead, for calls to standard library predicates, we create proxy predicates
> +% in the calling module and transform those instead. So we will only get
> +% events at the interface between non-library and library predicates.
> +%
> %-----------------------------------------------------------------------------%
> %-----------------------------------------------------------------------------%
...
> + % Look up the proxy for a predicate, creating one if appropriate.
> + %
> +:- pred lookup_proxy_pred(pred_id::in, maybe(pred_id)::out,
> + proxy_map::in, proxy_map::out, module_info::in, module_info::out) is det.
> +
> +lookup_proxy_pred(PredId, MaybeNewPredId, !ProxyMap, !ModuleInfo) :-
> + ( map.search(!.ProxyMap, PredId, MaybeNewPredId0) ->
> + MaybeNewPredId = MaybeNewPredId0
> + ;
> + module_info_pred_info(!.ModuleInfo, PredId, PredInfo),
> + PredModule = pred_info_module(PredInfo),
> + ( mercury_std_library_module_name(PredModule) ->
> + create_proxy_pred(PredId, NewPredId, !ModuleInfo),
> + MaybeNewPredId = yes(NewPredId)
> + ;
> + MaybeNewPredId = no
> + ),
> + svmap.det_insert(PredId, MaybeNewPredId, !ProxyMap)
> + ).
> +
> +:- pred create_proxy_pred(pred_id::in, pred_id::out,
> + module_info::in, module_info::out) is det.
> +
> +create_proxy_pred(PredId, NewPredId, !ModuleInfo) :-
> + some [!PredInfo] (
> + module_info_pred_info(!.ModuleInfo, PredId, !:PredInfo),
> + pred_info_set_import_status(status_local, !PredInfo),
> +
> + ProcIds = pred_info_procids(!.PredInfo),
> + list.foldl2(create_proxy_proc(PredId), ProcIds, !PredInfo, !ModuleInfo),
> +
> + % Change the name so that the proxy is not confused with the original.
> + Name = pred_info_name(!.PredInfo),
> + pred_info_set_name("ssdbpr_" ++ Name, !PredInfo),
I suggest: s/ssdpr_/SSDPR__/.
Also, you should probably include the callee's module qualifier in the
proxy name given that some names are quite common in the library.
That looks okay otherwise.
Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list