[Mono-devel-list] ilasm and PEAPI patches

Jackson Harper jackson at ximian.com
Sat Jun 26 23:49:55 EDT 2004


Hello,

	Attached are some patches to ilasm and PEAPI. ChangeLogs are included
in the patch. If you test make sure to patch and rebuild PEAPI then
ilasm. 

	After applying these patches all the il tests in `make testjit` still
pass.

Love,
Jackson


-------------- next part --------------
? Driver.cs.2
? asm.il
? bug-53147.il
? custom-attr.EXE
? data.exe.dump
? data.ms.DLL.dump
? data2.exe.dump
? dup.il
? full_key.il
? gac_lib.dll
? ilasm.exe.dump
? ilasm.patches
? ilasm2.il
? out.dll
? y.output
? codegen/ExternTable.cs.2
? codegen/ExternTable.cs.new
? codegen/ExternTypeRef.cs.new
? codegen/GlobalModuleTypeRef.cs
? codegen/ModuleRef.cs
? parser/ILParser.jay.patch
? tests/bug-53147.il
? tests/bug-b.il
? tests/call.il
? tests/custom-attr.il
? tests/data.il
? tests/data.ms.DLL
? tests/data2.il
? tests/diff.cs
? tests/m1.il
? tests/md-arrays-a.il
? tests/mig.il
? tests/test-assembly-info.il
? tests/test-bound-array.il
Index: ChangeLog
===================================================================
RCS file: /cvs/public/mcs/ilasm/ChangeLog,v
retrieving revision 1.55
diff -u -r1.55 ChangeLog
--- ChangeLog	24 Jun 2004 19:10:11 -0000	1.55
+++ ChangeLog	27 Jun 2004 02:48:59 -0000
@@ -1,3 +1,7 @@
+2004-06-26  Jackson Harper  <jackson at ximian.com>
+
+	* Report.cs: Fix quiet.
+	
 2004-06-24  Jackson Harper  <jackson at ximian.com>
 
 	* Report.cs: Add new mehtod for displaying messages.
Index: Report.cs
===================================================================
RCS file: /cvs/public/mcs/ilasm/Report.cs,v
retrieving revision 1.5
diff -u -r1.5 Report.cs
--- Report.cs	24 Jun 2004 19:10:11 -0000	1.5
+++ Report.cs	27 Jun 2004 02:48:59 -0000
@@ -37,9 +37,6 @@
                 public void AssembleFile (string file, string listing,
                                           string target, string output)
                 {
-                        if (quiet)
-                                return;
-
                         Console.WriteLine ("Assembling '{0}' , {1}, to {2} --> '{3}'", file,
                                            GetListing (listing), target, output);
                         Console.WriteLine ();
@@ -53,6 +50,8 @@
 
                 public void Message (string message)
                 {
+                        if (quiet)
+                                return;
                         Console.WriteLine (message);
                 }
                 
Index: codegen/ChangeLog
===================================================================
RCS file: /cvs/public/mcs/ilasm/codegen/ChangeLog,v
retrieving revision 1.149
diff -u -r1.149 ChangeLog
--- codegen/ChangeLog	24 Jun 2004 19:12:01 -0000	1.149
+++ codegen/ChangeLog	27 Jun 2004 02:49:00 -0000
@@ -1,3 +1,13 @@
+2004-06-26  Jackson Harper  <jackson at ximian.com>
+
+	* TypeDef.cs: Preserve the order of fields in a class. Then after
+	all the fields have been defined reset the order in PEAPI to the
+	correct order. This is done so sequential layouts actually
+	work. The order needs to be reset because it can be lost during
+	the recursive definition phase.
+	* MethodDef.cs: Use and ExternModule for pinvoke data's module
+	refs. This way we don't get duplicate module refs.
+	
 2004-06-24  Jackson Harper  <jackson at ximian.com>
 
 	* MethodDef.cs: Report when defining methods just like MS.
Index: codegen/MethodDef.cs
===================================================================
RCS file: /cvs/public/mcs/ilasm/codegen/MethodDef.cs,v
retrieving revision 1.33
diff -u -r1.33 MethodDef.cs
--- codegen/MethodDef.cs	24 Jun 2004 19:12:01 -0000	1.33
+++ codegen/MethodDef.cs	27 Jun 2004 02:49:00 -0000
@@ -47,7 +47,7 @@
                 private bool init_locals;
                 private int max_stack;
                 private bool pinvoke_info;
-                private string pinvoke_mod;
+                private ExternModule pinvoke_mod;
                 private string pinvoke_name;
                 private PEAPI.PInvokeAttr pinvoke_attr;
 
@@ -119,7 +119,7 @@
                         return type_list;
                 }
 
-                public void AddPInvokeInfo (PEAPI.PInvokeAttr pinvoke_attr, string pinvoke_mod,
+                public void AddPInvokeInfo (PEAPI.PInvokeAttr pinvoke_attr, ExternModule pinvoke_mod,
                                 string pinvoke_name)
                 {
                         this.pinvoke_attr = pinvoke_attr;
@@ -367,7 +367,7 @@
                                 customattr.AddTo (code_gen, methoddef);
 
                         if (pinvoke_info) {
-                                methoddef.AddPInvokeInfo (code_gen.PEFile.AddExternModule (pinvoke_mod),
+                                methoddef.AddPInvokeInfo (pinvoke_mod.ModuleRef,
                                                 (pinvoke_name != null ? pinvoke_name : name), pinvoke_attr);
 
                         }
Index: codegen/TypeDef.cs
===================================================================
RCS file: /cvs/public/mcs/ilasm/codegen/TypeDef.cs,v
retrieving revision 1.25
diff -u -r1.25 TypeDef.cs
--- codegen/TypeDef.cs	24 Jun 2004 19:12:01 -0000	1.25
+++ codegen/TypeDef.cs	27 Jun 2004 02:49:01 -0000
@@ -29,6 +29,7 @@
                 private ArrayList impl_list;
                 private PEAPI.ClassDef classdef;
                 private Hashtable field_table;
+                private ArrayList field_list;
                 private Hashtable method_table;
                 private ArrayList customattr_list;
                 private ArrayList event_list;
@@ -55,7 +56,10 @@
                         this.name = name;
                         this.parent = parent;
                         this.impl_list = impl_list;
+
                         field_table = new Hashtable ();
+                        field_list = new ArrayList ();
+
                         method_table = new Hashtable ();
 
                         size = -1;
@@ -145,6 +149,7 @@
                 public void AddFieldDef (FieldDef fielddef)
                 {
                         field_table.Add (fielddef.Name, fielddef);
+                        field_list.Add (fielddef);
                 }
 
                 public void AddMethodDef (MethodDef methoddef)
@@ -297,9 +302,13 @@
 
                 public void DefineContents (CodeGen code_gen)
                 {
-                        foreach (FieldDef fielddef in field_table.Values) {
+                        ArrayList fielddef_list = new ArrayList ();
+                        foreach (FieldDef fielddef in field_list) {
                                 fielddef.Define (code_gen, classdef);
+                                fielddef_list.Add (fielddef.PeapiFieldDef);
                         }
+
+                        classdef.SetFieldOrder (fielddef_list);
 
                         foreach (MethodDef methoddef in method_table.Values) {
                                 methoddef.Define (code_gen, this);
Index: parser/ChangeLog
===================================================================
RCS file: /cvs/public/mcs/ilasm/parser/ChangeLog,v
retrieving revision 1.139
diff -u -r1.139 ChangeLog
--- parser/ChangeLog	19 Jun 2004 23:25:52 -0000	1.139
+++ parser/ChangeLog	27 Jun 2004 02:49:01 -0000
@@ -1,3 +1,9 @@
+2004-06-26  Jackson Harper  <jackson at ximian.com>
+
+	* ILParser.jay: vtable fixups use the int32 or int64 keyword, not
+	actual int values. When adding modules for pinvoke info use the
+	ExternTable so we dont get duplicate modules.
+	
 2004-06-19  Jackson Harper  <jackson at ximian.com>
 
 	* ILParser.jay: Resolve method pointers that are being treated as
Index: parser/ILParser.jay
===================================================================
RCS file: /cvs/public/mcs/ilasm/parser/ILParser.jay,v
retrieving revision 1.144
diff -u -r1.144 ILParser.jay
--- parser/ILParser.jay	19 Jun 2004 23:25:52 -0000	1.144
+++ parser/ILParser.jay	27 Jun 2004 02:49:02 -0000
@@ -438,8 +438,8 @@
 			;
 
 vtfixup_attr		: /* EMPTY */
-			| vtfixup_attr int32
-			| vtfixup_attr int64
+			| vtfixup_attr K_INT32
+			| vtfixup_attr K_INT64
 			| vtfixup_attr K_FROMUNMANAGED
 			| vtfixup_attr K_CALLMOSTDERIVED
 			;
@@ -1499,7 +1499,8 @@
                                 codegen.BeginMethodDef (methdef);
 
                                 if (pinvoke_info) {
-                                        methdef.AddPInvokeInfo (pinvoke_attr, pinvoke_mod, pinvoke_meth);
+                                        ExternModule mod = codegen.ExternTable.AddModule (pinvoke_mod);
+                                        methdef.AddPInvokeInfo (pinvoke_attr, mod, pinvoke_meth);
                                         pinvoke_info = false;
                                 }
 
-------------- next part --------------
? PEAPI.patches
Index: ChangeLog
===================================================================
RCS file: /cvs/public/mcs/class/PEAPI/ChangeLog,v
retrieving revision 1.44
diff -u -r1.44 ChangeLog
--- ChangeLog	19 Jun 2004 23:12:20 -0000	1.44
+++ ChangeLog	27 Jun 2004 02:16:35 -0000
@@ -1,3 +1,12 @@
+2004-06-26  Jackson Harper  <jackson at ximian.com>
+
+	* PEAPI.cs: Add a method to set the fields list. This is needed so
+	that sequentially laid out fields are laid out in the right
+	order. When building custom attribute tables actually emit the
+	custom attribute data. When writing the .sdata section make sure
+	to pad to its size. The constants itself will not make up the
+	entire section because it is aligned on 512 byte blocks.
+	
 2004-06-19  Jackson Harper  <jackson at ximian.com>
 
 	* PEAPI.cs: Make sure the sentinel is placed properly for vararg
Index: PEAPI.cs
===================================================================
RCS file: /cvs/public/mcs/class/PEAPI/PEAPI.cs,v
retrieving revision 1.46
diff -u -r1.46 PEAPI.cs
--- PEAPI.cs	19 Jun 2004 23:12:20 -0000	1.46
+++ PEAPI.cs	27 Jun 2004 02:16:43 -0000
@@ -1821,7 +1821,12 @@
       fields.Add(field);
       return field;
     }
-
+
+    public void SetFieldOrder (ArrayList fields)
+    {
+            this.fields = fields;
+    }
+
     /// <summary>
     /// Add a method to this class
     /// </summary>
@@ -2646,7 +2651,7 @@
 
     internal sealed override void BuildTables(MetaData md) {
       BinaryWriter bw = new BinaryWriter(new MemoryStream());
-      bw.Write((ushort)1);
+      bw.Write(byteVal);
       md.AddToTable(MDTable.CustomAttribute, this);
       MemoryStream str = (MemoryStream)bw.BaseStream;
       valIx = md.AddToBlobHeap(str.ToArray());
@@ -3482,9 +3487,13 @@
      }
 
     private void WriteSDataSection() {
+      long size = sdata.Size ();
+      long start = BaseStream.Position;
       for (int i=0; i < data.Count; i++) {
         ((DataConstant)data[i]).Write(this);
-      }
+      }
+      while (BaseStream.Position < (start + size))
+              Write ((byte) 0);
     }
 
                 private void WriteRsrcSection() {


More information about the Mono-devel-list mailing list