Author: ankit
Date: 2006-01-13 11:10:53 -0500 (Fri, 13 Jan 2006)
New Revision: 55519
Modified:
trunk/mcs/class/PEAPI/ChangeLog
trunk/mcs/class/PEAPI/Metadata.cs
trunk/mcs/ilasm/codegen/BaseMethodRef.cs
trunk/mcs/ilasm/codegen/ChangeLog
trunk/mcs/ilasm/codegen/GenericMethodSig.cs
trunk/mcs/ilasm/codegen/GenericParamRef.cs
trunk/mcs/ilasm/parser/ChangeLog
trunk/mcs/ilasm/parser/ILParser.jay
Log:
In ilasm/codegen:
* GenericParamRef.cs (GenericParamRef.Resolve): Ensure no duplicate
GenParams get added to the TypeSpec table.
* GenericMethodSig.cs (GenericMethodSig.GetInstance): Cache sigs in a
static hashtable.
* BaseMethodRef.cs (BaseMethodRef.GetGenericMethodRef): Cache
GenericMethodRefs.
In ilasm/parser:
* ILParser.jay: Update to use codegen.GetTypeRef instead of creating
TypeRefs.
Update to use BaseMethodRef.GetGenericMethodRef instead of creating
them.
In class/PEAPI:
* Metadata.cs (GenericMethodSig): Ensure sig is added to the blob only
once.
Modified: trunk/mcs/class/PEAPI/ChangeLog
===================================================================
--- trunk/mcs/class/PEAPI/ChangeLog 2006-01-13 16:09:11 UTC (rev 55518)
+++ trunk/mcs/class/PEAPI/ChangeLog 2006-01-13 16:10:53 UTC (rev 55519)
@@ -1,3 +1,7 @@
+2006-01-13 Ankit Jain <[EMAIL PROTECTED]>
+
+ * Metadata.cs (GenericMethodSig): Ensure sig is added to the blob only
once.
+
2006-01-10 Ankit Jain <[EMAIL PROTECTED]>
* Metadata.cs (GenParam): Don't use GetTypeSpec to create typespec for
GenParam.
Modified: trunk/mcs/class/PEAPI/Metadata.cs
===================================================================
--- trunk/mcs/class/PEAPI/Metadata.cs 2006-01-13 16:09:11 UTC (rev 55518)
+++ trunk/mcs/class/PEAPI/Metadata.cs 2006-01-13 16:10:53 UTC (rev 55519)
@@ -1983,7 +1983,6 @@
private int index;
private string param_name;
private uint sigIx = 0;
- private bool done = false;
public GenParam (int index, string name, GenParamType ptype) :
base ((byte) ptype)
{
@@ -2115,10 +2114,13 @@
public class GenericMethodSig {
private Type[] gen_param;
+ private bool done;
+ private uint sigIx = 0;
public GenericMethodSig (Type[] gen_param)
{
this.gen_param = gen_param;
+ done = false;
}
internal void TypeSig (MemoryStream str)
@@ -2131,9 +2133,14 @@
internal uint GetSigIx (MetaData md)
{
+ if (done)
+ return sigIx;
+
MemoryStream sig = new MemoryStream();
TypeSig (sig);
- return md.AddToBlobHeap (sig.ToArray());
+ sigIx = md.AddToBlobHeap (sig.ToArray());
+ done = true;
+ return sigIx;
}
}
Modified: trunk/mcs/ilasm/codegen/BaseMethodRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/BaseMethodRef.cs 2006-01-13 16:09:11 UTC (rev
55518)
+++ trunk/mcs/ilasm/codegen/BaseMethodRef.cs 2006-01-13 16:10:53 UTC (rev
55519)
@@ -9,6 +9,7 @@
using System;
+using System.Collections;
namespace Mono.ILASM {
public abstract class BaseMethodRef {
@@ -23,6 +24,8 @@
protected bool is_resolved;
protected int gen_param_count;
+ protected Hashtable gen_method_table;
+
public BaseMethodRef (BaseTypeRef owner, PEAPI.CallConv
call_conv,
BaseTypeRef ret_type, string name, BaseTypeRef[]
param, int gen_param_count)
{
@@ -51,6 +54,24 @@
}
public abstract void Resolve (CodeGen code_gen);
+
+ public GenericMethodRef GetGenericMethodRef (GenericArguments
gen_args)
+ {
+ GenericMethodRef methref = null;
+
+ if (gen_method_table == null)
+ gen_method_table = new Hashtable ();
+ else
+ methref = (GenericMethodRef) gen_method_table
[gen_args.ToString ()];
+
+ if (methref == null) {
+ methref = new GenericMethodRef (this,
GenericMethodSig.GetInstance (gen_args));
+ gen_method_table [gen_args.ToString ()] =
methref;
+ }
+
+ return methref;
+ }
+
}
}
Modified: trunk/mcs/ilasm/codegen/ChangeLog
===================================================================
--- trunk/mcs/ilasm/codegen/ChangeLog 2006-01-13 16:09:11 UTC (rev 55518)
+++ trunk/mcs/ilasm/codegen/ChangeLog 2006-01-13 16:10:53 UTC (rev 55519)
@@ -1,5 +1,13 @@
2006-01-13 Ankit Jain <[EMAIL PROTECTED]>
+ * GenericParamRef.cs (GenericParamRef.Resolve): Ensure no duplicate
+ GenParams get added to the TypeSpec table.
+ * GenericMethodSig.cs (GenericMethodSig.GetInstance): Cache sigs in a
+ static hashtable.
+ * BaseMethodRef.cs (BaseMethodRef.GetGenericMethodRef): Cache
GenericMethodRefs.
+
+2006-01-13 Ankit Jain <[EMAIL PROTECTED]>
+
Create BaseMethodRef from IMethodRef. Replace usage of IMethodRef
with BaseMethodRef in *all* files.
Remove implementations of IMethodRef's methods from derived classes.
Modified: trunk/mcs/ilasm/codegen/GenericMethodSig.cs
===================================================================
--- trunk/mcs/ilasm/codegen/GenericMethodSig.cs 2006-01-13 16:09:11 UTC (rev
55518)
+++ trunk/mcs/ilasm/codegen/GenericMethodSig.cs 2006-01-13 16:10:53 UTC (rev
55519)
@@ -8,6 +8,7 @@
//
using System;
+using System.Collections;
namespace Mono.ILASM {
@@ -17,6 +18,8 @@
private bool is_resolved;
private PEAPI.GenericMethodSig sig;
+ private static Hashtable sig_table;
+
public GenericMethodSig (GenericArguments gen_args)
{
this.gen_args = gen_args;
@@ -38,6 +41,22 @@
return sig;
}
+ public static GenericMethodSig GetInstance (GenericArguments
gen_args)
+ {
+ GenericMethodSig sig = null;
+
+ if (sig_table == null)
+ sig_table = new Hashtable ();
+ else
+ sig = (GenericMethodSig) sig_table
[gen_args.ToString ()];
+
+ if (sig == null) {
+ sig = new GenericMethodSig (gen_args);
+ sig_table [gen_args.ToString ()] = sig;
+ }
+
+ return sig;
+ }
}
}
Modified: trunk/mcs/ilasm/codegen/GenericParamRef.cs
===================================================================
--- trunk/mcs/ilasm/codegen/GenericParamRef.cs 2006-01-13 16:09:11 UTC (rev
55518)
+++ trunk/mcs/ilasm/codegen/GenericParamRef.cs 2006-01-13 16:10:53 UTC (rev
55519)
@@ -21,6 +21,7 @@
/* Unmodified GenParam */
private PEAPI.GenParam param;
private bool is_added; /* Added to TypeSpec table ? */
+ private static Hashtable param_table = new Hashtable ();
public GenericParamRef (PEAPI.GenParam gen_param, string
full_name)
: this (gen_param, full_name, null)
@@ -67,7 +68,12 @@
if (is_added)
return;
- code_gen.PEFile.AddGenericParam (param);
+ string key = param.Type.ToString () +
param.Index.ToString ();
+ if (param_table [key] == null) {
+ code_gen.PEFile.AddGenericParam (param);
+ param_table [key] = param;
+ }
+
is_added = true;
}
Modified: trunk/mcs/ilasm/parser/ChangeLog
===================================================================
--- trunk/mcs/ilasm/parser/ChangeLog 2006-01-13 16:09:11 UTC (rev 55518)
+++ trunk/mcs/ilasm/parser/ChangeLog 2006-01-13 16:10:53 UTC (rev 55519)
@@ -1,5 +1,11 @@
2006-01-13 Ankit Jain <[EMAIL PROTECTED]>
+ * ILParser.jay: Update to use codegen.GetTypeRef instead of creating
+ TypeRefs.
+ Update to use BaseMethodRef.GetGenericMethodRef instead of creating
them.
+
+2006-01-13 Ankit Jain <[EMAIL PROTECTED]>
+
* ILParser.jay: Update to use CodeGen.GetGlobalMethodRef &
CodeGen.GetGlobalFieldRef instead of creating objects.
Modified: trunk/mcs/ilasm/parser/ILParser.jay
===================================================================
--- trunk/mcs/ilasm/parser/ILParser.jay 2006-01-13 16:09:11 UTC (rev 55518)
+++ trunk/mcs/ilasm/parser/ILParser.jay 2006-01-13 16:10:53 UTC (rev 55519)
@@ -774,7 +774,7 @@
class_ref : OPEN_BRACKET slashed_name CLOSE_BRACKET slashed_name
{
if (codegen.IsThisAssembly ((string) $2)) {
- $$ = new TypeRef ((string) $4, false,
null);
+ $$ = codegen.GetTypeRef ((string) $4);
} else {
$$ = codegen.ExternTable.GetTypeRef
((string) $2, (string) $4, false);
}
@@ -782,7 +782,7 @@
| OPEN_BRACKET D_MODULE slashed_name CLOSE_BRACKET
slashed_name
{
if (codegen.IsThisModule ((string) $3)) {
- $$ = new TypeRef ((string) $5, false,
null);
+ $$ = codegen.GetTypeRef ((string) $5);
} else {
$$ =
codegen.ExternTable.GetModuleTypeRef ((string) $3, (string) $5, false);
}
@@ -887,7 +887,7 @@
}
| K_VALUETYPE slashed_name typars_clause
{
- TypeRef t_ref = new TypeRef ((string) $2,
true, null);
+ TypeRef t_ref = codegen.GetTypeRef ((string)
$2);
t_ref.MakeValueClass ();
if ($3 != null)
$$ = t_ref.GetGenericTypeInst
((GenericArguments) $3);
@@ -2418,7 +2418,7 @@
if (codegen.IsThisAssembly ("mscorlib")) {
PrimitiveTypeRef prim = owner as
PrimitiveTypeRef;
if (prim != null && prim.SigMod == "")
- owner = new TypeRef
(prim.Name, false, null);
+ owner = codegen.GetTypeRef
(prim.Name);
}
methref = owner.GetMethodRef ((BaseTypeRef) $2,
@@ -2456,7 +2456,7 @@
(string) $3, param_list, (ga != null ?
ga.Count : 0));
if (ga != null)
- methref = new GenericMethodRef
(methref, new GenericMethodSig (ga));
+ methref = methref.GetGenericMethodRef
(ga);
$$ = methref;
}
@@ -2483,7 +2483,7 @@
}
if (ga != null)
- methref = new GenericMethodRef
(methref, new GenericMethodSig (ga));
+ methref = methref.GetGenericMethodRef
(ga);
$$ = methref;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches