Bug 315312 (MONO60933) - [PATCH] Remove literals from static data
Summary: [PATCH] Remove literals from static data
Status: RESOLVED FIXED
Alias: MONO60933
Product: Mono: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Enhancement
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-30 17:49 UTC by Ben Maurer
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
patch (11.06 KB, patch)
2004-06-30 17:50 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 18:44:43 UTC


---- Reported by bmaurer@users.sf.net 2004-06-30 10:49:51 MST ----

Right now, literal fields consume space in static data. This increases the
space which must be checked by the gc and takes up additional memory.



---- Additional Comments From bmaurer@users.sf.net 2004-06-30 10:50:06 MST ----

Created an attachment (id=166377)
patch




---- Additional Comments From bmaurer@users.sf.net 2004-07-05 14:36:46 MST ----

using System;
using System.Reflection;

class T {

	public const bool a = true;
	public const byte b = 1;
	public const sbyte c = 1;
	public const char d = 'a';
	public const short e = 1;
	public const ushort f = 1;
	public const int g = 1;
	public const uint h = 1;
	public const long i = 1;
	public const ulong j = 1;
	public const double k = 1;
	public const float l = 1;
	public const string m = "la la la";
	public const string n = null;
	
	static void Main ()
	{
		X ("a", a);
		X ("b", b);
		X ("c", c);
		X ("d", d);
		X ("e", e);
		X ("f", f);
		X ("g", g);
		X ("h", h);
		X ("i", i);
		X ("j", j);
		X ("k", k);
		X ("l", l);
		X ("m", m);
		X ("n", n);
	}
	
	static void X (string n, object o)
	{
		if (! Object.Equals (typeof (T).GetField (n).GetValue (null), o))
			Console.WriteLine (n);
	}
}

Some confidence inspiring tests :-).



---- Additional Comments From bmaurer@users.sf.net 2004-07-05 14:38:10 MST ----

NB: My justification for combinding the RVA and constant data into one
pointer is that the spec says a variable can declare "optionally
either a <fieldInit> form or a data label". So, they are mutually
exclusive.



---- Additional Comments From lupus@ximian.com 2004-07-06 07:15:03 MST ----

Make the test return a non-zero value from Main if it fails.
It's also a good rule to use different values when testing multiple
cases like that: don't use the value '1' all the time.
In cases like this, the test should check the boundary conditions,
like: are signed and unsigned values handled correctly? The test
doesn't show, so it doesn't inspire much confidence.
That said, once you write a proper test case, commit it in mono/tests
and commit the patch.
And since you're working in this area: the spec says that the type of
the constant may not match the type of the field. This means that the
code was and remains incorrect: please write the test case in IL and
change the code to handle this case.




---- Additional Comments From bmaurer@users.sf.net 2004-07-06 12:37:07 MST ----

Fixed. I filed https://bugzilla.novell.com/show_bug.cgi?id=MONO61204 for the issue lupus addressed above.

Imported an attachment (id=166377)

Unknown operating system unknown. Setting to default OS "Other".