[m-dev.] fixed limits and more fixed limits

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Aug 11 21:01:38 AEST 2000


On 11-Aug-2000, Peter Ross <peter.ross at miscrit.be> wrote:
>     After adjacent strings are concatenated, a string cannot be longer than
>     2048 characters.
...
> static const struct mercury_data__module_layout_mdb__debugger_interface_struct mercury_data__module_layout_mdb__debugger_interface = {
...
> 	MR_string_const("\0<too many variables>\0HeadVar__1\0...", 3706),
...
> };
> 
> The only solution I can think of (apart from shooting the MSVC
> developers, only 2048 measly chars!) is to change the
> declaration from `MR_String f3' to `MR_String f3[]' and outputting an array.

?  I don't quite understand.  You can't change the declaration to
`MR_String f3[]' because that is an incomplete variable-length array type,
and you can't have a variable-length array inside a structure unless
it is the last field.  In any case, I don't see how you could make it
as an array of strings without considerably changing the code that
accesses it.  Did you mean an array of MR_Char?

So, extrapolating from what I think you meant, and elaborating further,
you could change things so that that field is the last field of the
MR_Module_Layout_Struct (in runtime/mercury_stack_layout.h, taking
care to also modify compiler/stack_layout.m to generate appropriate
data for the new order), and then change the type of the field from

	MR_String	MR_ml_string_table;

to
	MR_Char		MR_ml_string_table[MR_VARIABLE_SIZED];

Then you would also need to change llds_out.m, mlds_out.m, and c_util.m so
that multi_string_consts are output as

	{ 'a', 'b', 'c', ... }

rather than as

	MR_string_const("abc...", <length>)

or

	"abc..."

as they are currently output for the LLDS and MLDS back-ends respectively.
Doing that ought to avoid this fixed limit, I think.

The drawback of that approach is that it would break binary backwards
compatibility for debug grades.  Another alternative that would avoid that
would be to change compiler/stack_layout.m so that rather than generating
a multi_string_const Rval there, it generated an Rval which was just
a reference to the data, i.e. as in the following (completely untested
and undoubtably incomplete) diff:

Index: stack_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.47
diff -u -d -u -r1.47 stack_layout.m
--- stack_layout.m	2000/07/20 05:44:02	1.47
+++ stack_layout.m	2000/08/11 10:53:54
@@ -318,17 +318,22 @@
 		stack_layout__format_label_tables(EffLabelTables,
 			NumSourceFiles, SourceFileVectors,
 			LayoutInfo4, LayoutInfo),
+		StringTableRvalList = [
+			yes(const(multi_string_const(StringOffset,
+				ConcatStrings)))],
+		StringTableDefn = comp_gen_c_data(ModuleName, string_table,
+			Exported, StringRvalList, uniform(yes(string)), []),
+		StringTableName = data_addr(ModuleName, string_table)
 		Rvals = [yes(const(string_const(ModuleNameStr))),
 			yes(const(int_const(StringOffset))),
-			yes(const(multi_string_const(StringOffset,
-				ConcatStrings))),
+			yes(const(data_addr_const(StringTableName))),
 			yes(const(int_const(NumProcLayouts))),
 			yes(ProcLayoutVector),
 			yes(const(int_const(NumSourceFiles))),
 			yes(SourceFileVectors)],
 		ModuleLayouts = comp_gen_c_data(ModuleName, module_layout,
 			Exported, Rvals, uniform(no), []),
-		StaticLayouts = [ModuleLayouts | InternalLayouts]
+		StaticLayouts = [StringTable, ModuleLayouts | InternalLayouts]
 	;
 		StaticLayouts = InternalLayouts,
 		LayoutInfo = LayoutInfo3
Index: llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.262
diff -u -d -u -r1.262 llds.m
--- llds.m	2000/08/09 07:46:53	1.262
+++ llds.m	2000/08/11 10:54:40
@@ -903,6 +903,8 @@
 			% types
 	;	module_layout
 			% Layout information for the current module.
+	;	string_table
+			% The string table for the current module.
 	;	proc_layout(label)
 			% Layout structure for the procedure with the given
 			% entry label.


Either way, you might want to make this change conditional on some option
that is only enabled for MSVC, since outputting the string table as a string
rather than as an array of chars might lead to faster compile times
for non-MSVC compilers.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- 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