[m-rev.] diff: IL back-end: emit .zeroinit only for --verifiable-code

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Aug 3 23:07:12 AEST 2001


Estimated hours taken: 0.25
Branches: main

compiler/mlds_to_il.m:
	Don't emit ".zeroinit" directives unless --verifiable-code is enabled.
	The code that the Mercury compiler generates doesn't require it, and
	omitting it may lead to slightly faster code.

Workspace: /home/venus/fjh/ws-venus4/mercury
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.59
diff -u -d -r1.59 mlds_to_il.m
--- compiler/mlds_to_il.m	3 Aug 2001 12:34:58 -0000	1.59
+++ compiler/mlds_to_il.m	3 Aug 2001 12:57:55 -0000
@@ -1004,7 +1004,9 @@
 
 		% Generate the entire method contents.
 	DebugIlAsm =^ debug_il_asm,
-	{ MethodBody = make_method_defn(DebugIlAsm, InstrsTree) },
+	VerifiableCode =^ verifiable_code,
+	{ MethodBody = make_method_defn(DebugIlAsm, VerifiableCode,
+		InstrsTree) },
 	{ list__append(EntryPoint, MethodBody, MethodContents) },
 
 	{ ClassDecl = ilasm__method(methodhead(Attrs, MemberName,
@@ -3478,23 +3480,25 @@
 
 %-----------------------------------------------------------------------------
 
-:- func make_method_defn(bool, instr_tree) = method_defn.
-make_method_defn(DebugIlAsm, InstrTree) = MethodDecls :-
+:- func make_method_defn(bool, bool, instr_tree) = method_defn.
+make_method_defn(DebugIlAsm, VerifiableCode, InstrTree) = MethodDecls :-
 	( DebugIlAsm = yes,
 		Add = 1
 	; DebugIlAsm = no,
 		Add = 0
 	),
 	Instrs = list__condense(tree__flatten(InstrTree)),
-	MethodDecls = [
-		maxstack(int32(calculate_max_stack(Instrs) + Add)),
-			% note that we only need .zeroinit to ensure
-			% verifiability; for nonverifiable code,
-			% we could omit that (it ensures that all
-			% variables are initialized to zero).
-		zeroinit,
-		instrs(Instrs)
-		].
+	MaxStack = maxstack(int32(calculate_max_stack(Instrs) + Add)),
+		% .zeroinit (which initializes all variables to zero)
+		% is required for verifiable code.  But if we're generating
+		% non-verifiable code, then we can skip it.  The code that
+		% the Mercury compiler generates doesn't require it, and
+		% omitting it may lead to slightly faster code.
+	( VerifiableCode = yes ->
+		MethodDecls = [MaxStack, zeroinit, instrs(Instrs)]
+	;
+		MethodDecls = [MaxStack, instrs(Instrs)]
+	).
 
 %-----------------------------------------------------------------------------
 % Some useful functions for generating IL fragments.

-- 
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