Author: raja
Date: 2007-01-12 11:17:43 -0500 (Fri, 12 Jan 2007)
New Revision: 70928

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/class-internals.h
   trunk/mono/mono/metadata/class.c
   trunk/mono/mono/metadata/icall.c
   trunk/mono/mono/metadata/loader.c
   trunk/mono/mono/metadata/reflection.c
   trunk/mono/mono/metadata/verify.c
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/mini.c
Log:
In metadata:
        Prepare to simplify GenericMethod handling.
        * class-internals.h (mono_method_get_context): New accessor function.
        * class.c, icall.c, loader.c, reflection.c, verify.c: Use accessor
        rather than directly accessing '->context' field.

In mini:
        * mini.c (mono_method_to_ir): Use new MonoGenericContext accessor.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2007-01-12 16:16:48 UTC (rev 70927)
+++ trunk/mono/mono/metadata/ChangeLog  2007-01-12 16:17:43 UTC (rev 70928)
@@ -1,5 +1,10 @@
 2007-01-12  Raja R Harinath  <[EMAIL PROTECTED]>
 
+       Prepare to simplify GenericMethod handling.
+       * class-internals.h (mono_method_get_context): New accessor function.
+       * class.c, icall.c, loader.c, reflection.c, verify.c: Use accessor
+       rather than directly accessing '->context' field.
+
        * class-internals.h (_MonoGenericParam.method): Move ...
        (_MonoGenericContainer): ... here.  Add into union with klass field.
        * class.c, icall.c, loader.c, metadata.c, reflection.c:

Modified: trunk/mono/mono/metadata/class-internals.h
===================================================================
--- trunk/mono/mono/metadata/class-internals.h  2007-01-12 16:16:48 UTC (rev 
70927)
+++ trunk/mono/mono/metadata/class-internals.h  2007-01-12 16:17:43 UTC (rev 
70928)
@@ -622,6 +622,9 @@
 MonoGenericContext*
 mono_generic_class_get_context (MonoGenericClass *gclass) MONO_INTERNAL;
 
+MonoGenericContext*
+mono_method_get_context (MonoMethod *method) MONO_INTERNAL;
+
 MonoMethod*
 mono_class_inflate_generic_method_full (MonoMethod *method, MonoClass 
*klass_hint, MonoGenericContext *context);
 

Modified: trunk/mono/mono/metadata/class.c
===================================================================
--- trunk/mono/mono/metadata/class.c    2007-01-12 16:16:48 UTC (rev 70927)
+++ trunk/mono/mono/metadata/class.c    2007-01-12 16:17:43 UTC (rev 70928)
@@ -667,9 +667,10 @@
 
        /* The `method' has already been instantiated before -> we need to 
create a new context. */
        while (method->is_inflated) {
+               MonoGenericContext *method_context = mono_method_get_context 
(method);
                MonoMethodInflated *imethod = (MonoMethodInflated *) method;
-               context = inflate_generic_context (imethod->context, context);
-               if (context == imethod->context)
+               context = inflate_generic_context (method_context, context);
+               if (context == method_context)
                        return method;
                method = imethod->declaring;
        }
@@ -724,17 +725,24 @@
 /**
  * mono_get_inflated_method:
  *
- * For performance reasons, mono_class_inflate_generic_method() does not 
actually instantiate the
- * method, it just "prepares" it for that.  If you really need to fully 
instantiate the method
- * (including its signature and header), call this method.
- * FIXME: Martin? this description looks completely wrong.
+ * Obsolete.  We keep it around since it's mentioned in the public API.
  */
-MonoMethod *
+MonoMethod*
 mono_get_inflated_method (MonoMethod *method)
 {
        return method;
 }
 
+MonoGenericContext*
+mono_method_get_context (MonoMethod *method)
+{
+       MonoMethodInflated *imethod;
+       if (!method->is_inflated)
+               return NULL;
+       imethod = (MonoMethodInflated *) method;
+       return imethod->context;
+}
+
 /** 
  * mono_class_find_enum_basetype:
  * @class: The enum class

Modified: trunk/mono/mono/metadata/icall.c
===================================================================
--- trunk/mono/mono/metadata/icall.c    2007-01-12 16:16:48 UTC (rev 70927)
+++ trunk/mono/mono/metadata/icall.c    2007-01-12 16:17:43 UTC (rev 70928)
@@ -2562,6 +2562,7 @@
 static MonoReflectionMethod *
 ves_icall_MonoMethod_GetGenericMethodDefinition (MonoReflectionMethod *method)
 {
+       MonoGenericContext *context;
        MonoMethodInflated *imethod;
 
        MONO_ARCH_SAVE_REGS;
@@ -2574,8 +2575,11 @@
        }
 
        imethod = (MonoMethodInflated *) method->method;
-       if (imethod->context->gmethod && 
imethod->context->gmethod->reflection_info)
-               return imethod->context->gmethod->reflection_info;
+
+       /* FIXME: should reflection_info be part of imethod? */
+       context = mono_method_get_context (method->method);
+       if (context->gmethod && context->gmethod->reflection_info)
+               return context->gmethod->reflection_info;
        else
                return mono_method_get_object (
                        mono_object_domain (method), imethod->declaring, NULL);
@@ -2609,8 +2613,7 @@
        domain = mono_object_domain (method);
 
        if (method->method->is_inflated) {
-               MonoMethodInflated *imethod = (MonoMethodInflated *) 
method->method;
-               MonoGenericMethod *gmethod = imethod->context->gmethod;
+               MonoGenericMethod *gmethod = mono_method_get_context 
(method->method)->gmethod;
 
                if (gmethod) {
                        count = gmethod->inst->type_argc;

Modified: trunk/mono/mono/metadata/loader.c
===================================================================
--- trunk/mono/mono/metadata/loader.c   2007-01-12 16:16:48 UTC (rev 70927)
+++ trunk/mono/mono/metadata/loader.c   2007-01-12 16:17:43 UTC (rev 70928)
@@ -1452,7 +1452,7 @@
        if (method->is_inflated && sig->generic_param_count) {
                MonoMethodInflated *imethod = (MonoMethodInflated *) method;
                sig = mono_method_signature (imethod->declaring);
-               method_context = imethod->context;
+               method_context = mono_method_get_context (method);
        }
 
        if ((constrained_class != method->klass) && 
(method->klass->interface_id != 0))
@@ -1794,7 +1794,7 @@
                MonoMethodSignature *signature;
                /* the lock is recursive */
                signature = mono_method_signature (imethod->declaring);
-               m->signature = inflate_generic_signature 
(imethod->declaring->klass->image, signature, imethod->context);
+               m->signature = inflate_generic_signature 
(imethod->declaring->klass->image, signature, mono_method_get_context (m));
                mono_loader_unlock ();
                return m->signature;
        }
@@ -1935,7 +1935,7 @@
                MonoMethodHeader *header;
                /* the lock is recursive */
                header = mono_method_get_header (imethod->declaring);
-               mn->header = inflate_generic_header (header, imethod->context);
+               mn->header = inflate_generic_header (header, 
mono_method_get_context (method));
                mono_loader_unlock ();
                return mn->header;
        }

Modified: trunk/mono/mono/metadata/reflection.c
===================================================================
--- trunk/mono/mono/metadata/reflection.c       2007-01-12 16:16:48 UTC (rev 
70927)
+++ trunk/mono/mono/metadata/reflection.c       2007-01-12 16:17:43 UTC (rev 
70928)
@@ -2465,7 +2465,6 @@
        table = &assembly->tables [MONO_TABLE_METHODSPEC];
 
        g_assert (method->is_inflated);
-       method = mono_get_inflated_method (method);
        imethod = (MonoMethodInflated *) method;
        declaring = imethod->declaring;
 
@@ -2486,7 +2485,7 @@
                g_assert_not_reached ();
        }
 
-       sig = encode_generic_method_sig (assembly, imethod->context->gmethod);
+       sig = encode_generic_method_sig (assembly, mono_method_get_context 
(method)->gmethod);
 
        if (assembly->save) {
                alloc_table (table, table->rows + 1);

Modified: trunk/mono/mono/metadata/verify.c
===================================================================
--- trunk/mono/mono/metadata/verify.c   2007-01-12 16:16:48 UTC (rev 70927)
+++ trunk/mono/mono/metadata/verify.c   2007-01-12 16:17:43 UTC (rev 70928)
@@ -1178,7 +1178,7 @@
        }
 
        if (signature->is_inflated)
-               generic_context = ((MonoMethodInflated *) method)->context;
+               generic_context = mono_method_get_context (method);
 
        if (header->num_locals) {
                local_state = g_new (char, header->num_locals);

Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2007-01-12 16:16:48 UTC (rev 70927)
+++ trunk/mono/mono/mini/ChangeLog      2007-01-12 16:17:43 UTC (rev 70928)
@@ -1,4 +1,7 @@
+2007-01-12  Raja R Harinath  <[EMAIL PROTECTED]>
 
+       * mini.c (mono_method_to_ir): Use new MonoGenericContext accessor.
+
 Thu Jan 11 11:16:42 CET 2007 Paolo Molaro <[EMAIL PROTECTED]>
 
        * Makefile.am: distribute the mips sources.

Modified: trunk/mono/mono/mini/mini.c
===================================================================
--- trunk/mono/mono/mini/mini.c 2007-01-12 16:16:48 UTC (rev 70927)
+++ trunk/mono/mono/mini/mini.c 2007-01-12 16:17:43 UTC (rev 70928)
@@ -3831,7 +3831,7 @@
        mono_jit_stats.cil_code_size += header->code_size;
 
        if (sig->is_inflated)
-               generic_context = ((MonoMethodInflated *) method)->context;
+               generic_context = mono_method_get_context (method);
        else if (generic_container)
                generic_context = &generic_container->context;
 
@@ -4607,7 +4607,7 @@
 
                                NEW_TEMPLOAD (cfg, iargs [0], 
this_temp->inst_c0);
                                NEW_PCONST (cfg, iargs [1], cmethod);
-                               NEW_PCONST (cfg, iargs [2], 
((MonoMethodInflated *) cmethod)->context);
+                               NEW_PCONST (cfg, iargs [2], 
mono_method_get_context (cmethod));
                                NEW_TEMPLOADA (cfg, iargs [3], 
this_arg_temp->inst_c0);
                                temp = mono_emit_jit_icall (cfg, bblock, 
mono_helper_compile_generic_method, iargs, ip);
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to