[m-rev.] for review: fix lost `impure' goal features

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 28 01:51:06 AEDT 2003


On 28-Feb-2003, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> 
> Fix bugs in the handling of purity in the optimization passes
> (in particular constraint propagation), which caused purity
> annotations on goals to be lost. This caused
> tests/tabling/unused_args to fail on earth.

> Index: compiler/hlds_goal.m
...
> -goal_info_init(NonLocals, InstMapDelta, Detism, GoalInfo) :-
> +goal_info_init(NonLocals, InstMapDelta, Detism, Purity, GoalInfo) :-
>  	goal_info_init(GoalInfo0),
>  	goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo1),
>  	goal_info_set_instmap_delta(GoalInfo1, InstMapDelta, GoalInfo2),
> -	goal_info_set_determinism(GoalInfo2, Detism, GoalInfo).
> +	goal_info_set_determinism(GoalInfo2, Detism, GoalInfo3),
> +	add_goal_info_purity_feature(GoalInfo3, Purity, GoalInfo).
>  
> -goal_info_init(NonLocals, InstMapDelta, Detism, Context, GoalInfo) :-
> +goal_info_init(NonLocals, InstMapDelta, Detism, Purity, Context, GoalInfo) :-
>  	goal_info_init(GoalInfo0),
>  	goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo1),
>  	goal_info_set_instmap_delta(GoalInfo1, InstMapDelta, GoalInfo2),
>  	goal_info_set_determinism(GoalInfo2, Detism, GoalInfo3),
> -	goal_info_set_context(GoalInfo3, Context, GoalInfo).
> +	goal_info_set_context(GoalInfo3, Context, GoalInfo4),
> +	add_goal_info_purity_feature(GoalInfo4, Purity, GoalInfo).

I'm worried that this change might significantly decrease efficiency.

The call to add_goal_info_purity_feature will result in two calls to
goal_info_remove_feature.  Each of those calls will allocate a goal_info,
and will also call set__delete, which will call set_ordlist__delete,
which will allocate a cons cell and call set__ordlist_difference, which
will finally return.  So that's an extra four heap cells (18 words)
of garbage and an extra four intermodule procedure calls, for each call
to goal_info_init.

Also, in the current implementation, goal_info_set_* get inlined
and the intermediate datastructures that they produce are eliminated.
But goal_info_init/1 is not getting inlined, so that's another unnecessary
goal_info allocation.

Calls to goal_info_init/4 are probably quite frequent, so I think it is
worth manually inlining the calls to goal_info_init/1 and goal_info_set_*,
and computing the goal_features directly from the purity (this could
still be done by a predicate in purity.m, but one that just returns
a set of goal_features rather than a goal_info).

Otherwise, that change looks good.  Thanks.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  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