Bugzilla – Bug 315312
[PATCH] Remove literals from static data
Last modified: 2007-09-15 21:24:46 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".