[m-dev.] For Review: Bytecode compiler

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jan 25 22:22:36 AEDT 2001


On 25-Jan-2001, Levi Cameron <l.cameron2 at ugrad.unimelb.edu.au> wrote:
> Changed code generator to output bytecode stubs if needed
> 
> bytecode/code_gen.m:
> 	Changed code generator to output bytecode call stub if
> 	procedure contains no foreign code

The code there doesn't match the log message....

> Index: code_gen.m
...
> +		GenBytecode = yes,
> +		\+ code_util__compiler_generated(PredInfo),
> +		\+ (Name = "main", Arity = 2),
> +		goal_has_foreign(Goal) = no

Here you don't generate stubs for main/2
and for compiler generated procedures.
The comments should explain why not.

> +code_gen__bytecode_stub(ModuleInfo, PredId, ProcId, BytecodeInstructions) :-
> +	
...
> +	append_list([
> +		"\t\tMB_Word* return_adr;\n",
> +		"\t\tMR_save_registers();\n",
> +		"\t\treturn_adr = MB_bytecode_call_entry(",
> +			"&",CallStructName,");\n",
> +		"\t\tMR_restore_registers();\n",
> +		"\t\tMR_GOTO(return_adr);\n"
> +		], BytecodeCall),

I suggest s/_adr/_addr/

>  %---------------------------------------------------------------------------%
> Index: hlds_goal.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
> retrieving revision 1.83
> diff -u -r1.83 hlds_goal.m
> --- hlds_goal.m	2001/01/16 15:44:21	1.83
> +++ hlds_goal.m	2001/01/22 05:59:06
> @@ -800,6 +800,12 @@
>  :- pred negate_goal(hlds_goal, hlds_goal_info, hlds_goal).
>  :- mode negate_goal(in, in, out) is det.
>  
> +	% Return yes if goal(s) contain any foreign code
> +:- func goal_has_foreign(hlds_goal) = bool.
> +:- mode goal_has_foreign(in) = out is det.
> +:- func goal_have_foreign(list(hlds_goal)) = bool.
> +:- mode goal_have_foreign(in) = out is det.

   s/goal_have_foreign/goals_have_foreign/
or s/goal_have_foreign/goal_list_has_foreign/

> +++ llds_out.m	2001/01/24 03:04:59
> @@ -418,6 +418,12 @@
>  		io__write_string("#include ""mercury_trace_base.h""\n")
>  	;
>  		io__write_string("#include ""mercury_imp.h""\n")
> +	),
> +	globals__io_lookup_bool_option(generate_bytecode, GenBytecode),
> +	(	{ GenBytecode = yes },
> +		io__write_string("#include ""mb_interface.h""\n")
> +	;	{ GenBytecode = no },
> +		io__write_string("")

io__write_string("") is a NOP.
You can delete that last line.

Otherwise, that looks good.
I'd like to see another diff when you've addressed those comments.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "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-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list