Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs/ilasm
diff options
context:
space:
mode:
authorAnkit Jain <radical@corewars.org>2006-01-13 19:10:53 +0300
committerAnkit Jain <radical@corewars.org>2006-01-13 19:10:53 +0300
commite2a3353ffc69ef26add7d254462155e951f660d4 (patch)
tree158a5917f9dc77298a5aae5d0864ba0bcce4ab78 /mcs/ilasm
parent36166ca1d54d4e0e3006c17aad1a201e8cf1702c (diff)
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. svn path=/trunk/mcs/; revision=55519
Diffstat (limited to 'mcs/ilasm')
-rw-r--r--mcs/ilasm/codegen/BaseMethodRef.cs21
-rw-r--r--mcs/ilasm/codegen/ChangeLog8
-rw-r--r--mcs/ilasm/codegen/GenericMethodSig.cs19
-rw-r--r--mcs/ilasm/codegen/GenericParamRef.cs8
-rw-r--r--mcs/ilasm/parser/ChangeLog6
-rw-r--r--mcs/ilasm/parser/ILParser.jay12
6 files changed, 67 insertions, 7 deletions
diff --git a/mcs/ilasm/codegen/BaseMethodRef.cs b/mcs/ilasm/codegen/BaseMethodRef.cs
index ae5b93085a0..73c7b1e2740 100644
--- a/mcs/ilasm/codegen/BaseMethodRef.cs
+++ b/mcs/ilasm/codegen/BaseMethodRef.cs
@@ -9,6 +9,7 @@
using System;
+using System.Collections;
namespace Mono.ILASM {
public abstract class BaseMethodRef {
@@ -23,6 +24,8 @@ namespace Mono.ILASM {
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 @@ namespace Mono.ILASM {
}
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;
+ }
+
}
}
diff --git a/mcs/ilasm/codegen/ChangeLog b/mcs/ilasm/codegen/ChangeLog
index 91fa9e17b45..bc54d88eb6f 100644
--- a/mcs/ilasm/codegen/ChangeLog
+++ b/mcs/ilasm/codegen/ChangeLog
@@ -1,5 +1,13 @@
2006-01-13 Ankit Jain <jankit@novell.com>
+ * 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 <jankit@novell.com>
+
Create BaseMethodRef from IMethodRef. Replace usage of IMethodRef
with BaseMethodRef in *all* files.
Remove implementations of IMethodRef's methods from derived classes.
diff --git a/mcs/ilasm/codegen/GenericMethodSig.cs b/mcs/ilasm/codegen/GenericMethodSig.cs
index 1d7d4d688f8..e8c74bec130 100644
--- a/mcs/ilasm/codegen/GenericMethodSig.cs
+++ b/mcs/ilasm/codegen/GenericMethodSig.cs
@@ -8,6 +8,7 @@
//
using System;
+using System.Collections;
namespace Mono.ILASM {
@@ -17,6 +18,8 @@ namespace Mono.ILASM {
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 @@ namespace Mono.ILASM {
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;
+ }
}
}
diff --git a/mcs/ilasm/codegen/GenericParamRef.cs b/mcs/ilasm/codegen/GenericParamRef.cs
index 4844304f30f..de4e282826e 100644
--- a/mcs/ilasm/codegen/GenericParamRef.cs
+++ b/mcs/ilasm/codegen/GenericParamRef.cs
@@ -21,6 +21,7 @@ namespace Mono.ILASM {
/* 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 @@ namespace Mono.ILASM {
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;
}
diff --git a/mcs/ilasm/parser/ChangeLog b/mcs/ilasm/parser/ChangeLog
index 5d91acf6441..a3198382fb1 100644
--- a/mcs/ilasm/parser/ChangeLog
+++ b/mcs/ilasm/parser/ChangeLog
@@ -1,5 +1,11 @@
2006-01-13 Ankit Jain <jankit@novell.com>
+ * 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 <jankit@novell.com>
+
* ILParser.jay: Update to use CodeGen.GetGlobalMethodRef &
CodeGen.GetGlobalFieldRef instead of creating objects.
diff --git a/mcs/ilasm/parser/ILParser.jay b/mcs/ilasm/parser/ILParser.jay
index 67580c6290c..1c1d69086e4 100644
--- a/mcs/ilasm/parser/ILParser.jay
+++ b/mcs/ilasm/parser/ILParser.jay
@@ -774,7 +774,7 @@ slashed_name : comp_name
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 @@ class_ref : OPEN_BRACKET slashed_name CLOSE_BRACKET slashed_name
| 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 @@ type : generic_class_ref
}
| 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 @@ method_ref : call_conv type type_spec DOUBLE_COLON method_name
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 @@ method_ref : call_conv type type_spec DOUBLE_COLON method_name
(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 @@ method_ref : call_conv type type_spec DOUBLE_COLON method_name
}
if (ga != null)
- methref = new GenericMethodRef (methref, new GenericMethodSig (ga));
+ methref = methref.GetGenericMethodRef (ga);
$$ = methref;
}