[m-dev.] for review: fix block nesting hits fixed limit in MSVC

Peter Ross petdr at cs.mu.OZ.AU
Sat Jul 8 02:18:56 AEST 2000


Hi,

For Fergus to review when he gets back.

===================================================================


Estimated hours taken: 4

Avoid a fixed limit problem where only N levels of block nesting is
allowed in the MSVC compiler.

compiler/ml_code_gen.m:
    ml_join_decls creates block nesting proportional to the size of the
    disjunction when generating disjunctions in a model_non context.
    Now we always create a block for each arm of the disjunction.  This
    allows us to safely concatenate blocks together, and hence only nest
    blocks one level deeper.

Index: ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.52
diff -u -r1.52 ml_code_gen.m
--- ml_code_gen.m	2000/06/06 06:21:22	1.52
+++ ml_code_gen.m	2000/07/07 16:01:31
@@ -2411,8 +2411,10 @@
 	% (the HLDS should not contain singleton disjunctions,
 	% but this code is needed to handle recursive calls to ml_gen_disj)
 	%
-ml_gen_disj([SingleGoal], CodeModel, _, MLDS_Decls, MLDS_Statements) -->
-	ml_gen_goal(CodeModel, SingleGoal, MLDS_Decls, MLDS_Statements).
+ml_gen_disj([SingleGoal], CodeModel, Context, [], [MLDS_Statement]) -->
+	ml_gen_goal(CodeModel, SingleGoal, Goal_Decls, Goal_Statements),
+	{ MLDS_Statement = ml_gen_block(Goal_Decls, Goal_Statements,
+			Context) }.
 
 ml_gen_disj([First | Rest], CodeModel, Context,
 		MLDS_Decls, MLDS_Statements) -->
@@ -2429,9 +2431,18 @@
 		ml_gen_goal(model_non, First, FirstDecls, FirstStatements),
 		ml_gen_disj(Rest, model_non, Context,
 			RestDecls, RestStatements),
-		{ ml_join_decls(FirstDecls, FirstStatements,
-			RestDecls, RestStatements, Context,
-			MLDS_Decls, MLDS_Statements) }
+
+		(
+			{ RestDecls = [] }
+		->
+			{ FirstBlock = ml_gen_block(FirstDecls,
+					FirstStatements, Context) },
+			{ MLDS_Decls = [] },
+			{ MLDS_Statements = [FirstBlock | RestStatements] }
+		;
+			{ error("ml_gen_disj: RestDecls not empty.") }
+		)
+
 	; /* CodeModel is model_det or model_semi */
 		%
 		% model_det/model_semi disj:

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