[m-rev.] diff: IL back-end: improve commit handling

Tyson Dowd trd at cs.mu.OZ.AU
Fri Jul 13 22:02:24 AEST 2001


On 13-Jul-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> compiler/mlds_to_il.m:
> 	Handle do_commit instructions by just doing the equivalent of
> 	"throw new mercury::runtime::Commit();".  This is more efficient
> 	than the old code that we used to generate, which would assign
> 	the result of the newobj instruction to a variable or environment
> 	field, only to immediately get it back again.


It's worth noting that the code is that poor because new_object cannot
be used as an rval -- this is an MLDS limitation.

If the old code was generated to assign to a local variable (which is the code
produced before you backed out my change) the peephole optimizer will
reduce it to the same code as you generate.

But if it is generated as an environment field, this doesn't work and
you get dumb code.

> 
> Workspace: /home/mars/fjh/ws1/mercury
> Index: compiler/ml_code_gen.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
> retrieving revision 1.93
> diff -u -d -r1.93 ml_code_gen.m
> --- compiler/ml_code_gen.m	2001/07/12 23:58:38	1.93
> +++ compiler/ml_code_gen.m	2001/07/13 10:58:07
> @@ -1599,29 +1601,9 @@
>  		{ DoCommitStmt = do_commit(lval(CommitRefLval)) },
>  		{ DoCommitStatement = 
>  			mlds__statement(DoCommitStmt, MLDS_Context) },
> -		=(MLDSGenInfo),
> -		{ ml_gen_info_get_module_info(MLDSGenInfo, ModuleInfo) },
> -		{ module_info_globals(ModuleInfo, Globals) },
> -		{ globals__get_target(Globals, Target) },
> -		{ Target = il ->
> -				% XXX would be a good performance thing
> -				% to re-use the same pre-allocated commit
> -				% object over and over again, instead of
> -				% allocating them each time.
> -			NewCommitObject = mlds__statement(
> -				atomic(new_object(CommitRefLval, no,
> -					mlds__commit_type, no, no, [], [])),
> -					MLDS_Context),
> -			DoCommitBody = ml_gen_block([], 
> -				[NewCommitObject,
> -				DoCommitStatement],
> -				Context)
> -		;
> -			DoCommitBody = DoCommitStatement
> -		},
>  		/* pop nesting level */
>  		ml_gen_nondet_label_func(SuccessFuncLabel, Context,
> -			DoCommitBody, SuccessFunc),
> +			DoCommitStatement, SuccessFunc),
>  

Doesn't this code leave an unused variable lying around (the commit
variable in the environment)?

Otherwise this is fine. 

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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