[m-rev.] for reviews: fix optimization in unify_proc.m
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Mar 31 20:03:49 AEST 2004
On 31-Mar-2004, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> For review by Fergus.
>
> Zoltan.
>
> compiler/unify_proc.m:
> Reenable an optimization of unify procedures for general du types
> after fixing the problem that caused it to be disabled. This required
> placing a feature on casts from constants to integers that ask the mode
> checker to preserve any binding information it has about the constant
> as the equivalent binding information about the integer.
>
> compiler/hlds_goal.m:
> Add this feature to the list of goal features.
>
> compiler/modecheck_call.m:
> When processing unsafe_cast goals, respect this feature.
>
> tests/hard_coded/det_complicated_unify2.m:
> Make this test case, which was the test case for the original problem
> with the optimization, even tougher, to make sure the new version
> works. Update the test case documentation.
>
> cvs diff: Diffing .
> cvs diff: Diffing analysis
> cvs diff: Diffing bindist
> cvs diff: Diffing boehm_gc
> cvs diff: Diffing boehm_gc/Mac_files
> cvs diff: Diffing boehm_gc/cord
> cvs diff: Diffing boehm_gc/cord/private
> cvs diff: Diffing boehm_gc/doc
> cvs diff: Diffing boehm_gc/include
> cvs diff: Diffing boehm_gc/include/private
> cvs diff: Diffing boehm_gc/tests
> cvs diff: Diffing browser
> cvs diff: Diffing bytecode
> cvs diff: Diffing compiler
> Index: compiler/hlds_goal.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_goal.m,v
> retrieving revision 1.113
> diff -u -b -r1.113 hlds_goal.m
> --- compiler/hlds_goal.m 31 Mar 2004 08:52:22 -0000 1.113
> +++ compiler/hlds_goal.m 31 Mar 2004 09:00:10 -0000
> @@ -742,8 +742,16 @@
> % be hidden. This is used e.g. by the tabling
> % transformation to preserve the set of events
> % generated by a tabled procedure.
> - ; tailcall. % This goal represents a tail call. This marker
> + ; tailcall % This goal represents a tail call. This marker
> % is used by deep profiling.
> + ; keep_constant_binding.
> + % This feature should only be attached to
> + % unsafe_cast goals that cast a value of an
> + % user-defined type to an integer. It tells
> + % the mode checker that if the first variable
> + % is known to be bound to a given constant,
> + % then the second variable should be set
> + % to the corresponding local tag value.
>
> % We can think of the goal that defines a procedure to be a tree,
> % whose leaves are primitive goals and whose interior nodes are
> Index: compiler/modes.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/modes.m,v
> retrieving revision 1.276
> diff -u -b -r1.276 modes.m
> --- compiler/modes.m 31 Mar 2004 08:52:23 -0000 1.276
> +++ compiler/modes.m 31 Mar 2004 09:06:36 -0000
> @@ -190,7 +190,8 @@
>
> % The following predicates are used by unique_modes.m.
>
> -:- import_module check_hlds__mode_info, hlds__hlds_data.
> +:- import_module check_hlds__mode_info.
> +:- import_module hlds__hlds_data.
>
> % Modecheck a unification.
>
> @@ -1193,9 +1194,43 @@
> error("modecheck_goal_expr: class_method_call")
> ;
> GenericCall = unsafe_cast,
> - modecheck_builtin_cast(Modes0, Args0, Args, Det, ExtraGoals,
> + (
> + goal_info_has_feature(GoalInfo0,
> + keep_constant_binding),
> + mode_info_get_instmap(!.ModeInfo, InstMap),
> + (
> + Args0 = [Arg1Prime, _Arg2Prime],
> + Modes0 = [Mode1Prime, Mode2Prime]
> + ->
> + Arg1 = Arg1Prime,
> + Mode1 = Mode1Prime,
> + Mode2 = Mode2Prime
> + ;
> + error("modecheck_goal_expr: bad unsafe_cast")
> + ),
> + Mode1 = in_mode,
> + Mode2 = out_mode,
> + instmap__lookup_var(InstMap, Arg1, Inst1),
> + Inst1 = bound(Unique, [functor(ConsId, [])]),
> + mode_info_get_module_info(!.ModeInfo, ModuleInfo),
> + module_info_types(ModuleInfo, TypeTable),
> + mode_info_get_var_types(!.ModeInfo, VarTypes),
> + map__lookup(VarTypes, Arg1, ArgType1),
> + type_to_ctor_and_args(ArgType1, ArgTypeCtor1, _),
> + map__lookup(TypeTable, ArgTypeCtor1, CtorDefn),
> + get_type_defn_body(CtorDefn, Body),
> + ConsTagValues = Body ^ du_type_cons_tag_values,
> + map__lookup(ConsTagValues, ConsId, ConsTag),
> + ConsTag = shared_local_tag(_, LocalTag)
> + ->
> + BoundInst = functor(int_const(LocalTag), []),
Why do you ignore the first argument of shared_local_tag here?
Won't that code give an incorrect result when the first argument of
shared_local_tag is non-zero?
Otherwise that change looks fine.
--
Fergus Henderson | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list