2008-08-20 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Wed, 20 Aug 2008 16:15:04 +0000 (16:15 -0000)
committerZoltan Varga <vargaz@gmail.com>
Wed, 20 Aug 2008 16:15:04 +0000 (16:15 -0000)
* mini.h (MONO_AOT_FILE_VERSION): Bump aot file format version.

* aot-runtime.c aot-compiler.c patch-info.h mini.c: Get rid of
MONO_PATCH_INFO_WRAPPER, encode/decode wrapper methods like the others in
encode/decode_method_ref ().

svn path=/trunk/mono/; revision=111156

mono/mini/ChangeLog
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/mini.c
mono/mini/mini.h
mono/mini/patch-info.h

index a1c78fa0a134ab5436ace7761425790f66c0d6a3..0c9abcce8d4866f29e967791882b098041f2f41f 100644 (file)
@@ -1,5 +1,11 @@
 2008-08-20  Zoltan Varga  <vargaz@gmail.com>
 
+       * mini.h (MONO_AOT_FILE_VERSION): Bump aot file format version.
+
+       * aot-runtime.c aot-compiler.c patch-info.h mini.c: Get rid of
+       MONO_PATCH_INFO_WRAPPER, encode/decode wrapper methods like the others in
+       encode/decode_method_ref ().
+
        * aot-compiler.c (encode_patch): Handle STATIC_RGCTX_INVOKE wrappers.
 
        * aot-runtime.c (decode_patch): Ditto.  
index 378082fa711738d48cf3cbd7d075428a12fd0534..bc0df2db660997a0d5e12a0aab658060e3bee0d1 100644 (file)
@@ -1789,7 +1789,55 @@ encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8
 
        g_assert (image_index < MAX_IMAGE_INDEX);
 
-       if (mono_method_signature (method)->is_inflated) {
+       if (method->wrapper_type) {
+               /* Marker */
+               encode_value ((253 << 24), p, &p);
+
+               encode_value (method->wrapper_type, p, &p);
+
+               switch (method->wrapper_type) {
+               case MONO_WRAPPER_REMOTING_INVOKE:
+               case MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK:
+               case MONO_WRAPPER_XDOMAIN_INVOKE: {
+                       MonoMethod *m;
+
+                       m = mono_marshal_method_from_wrapper (method);
+                       g_assert (m);
+                       encode_method_ref (acfg, m, p, &p);
+                       break;
+               }
+               case MONO_WRAPPER_PROXY_ISINST:
+               case MONO_WRAPPER_LDFLD:
+               case MONO_WRAPPER_LDFLDA:
+               case MONO_WRAPPER_STFLD:
+               case MONO_WRAPPER_ISINST: {
+                       MonoClass *proxy_class = (MonoClass*)mono_marshal_method_from_wrapper (method);
+                       encode_klass_ref (acfg, proxy_class, p, &p);
+                       break;
+               }
+               case MONO_WRAPPER_LDFLD_REMOTE:
+               case MONO_WRAPPER_STFLD_REMOTE:
+                       break;
+               case MONO_WRAPPER_ALLOC: {
+                       int alloc_type = mono_gc_get_managed_allocator_type (method);
+                       g_assert (alloc_type != -1);
+                       encode_value (alloc_type, p, &p);
+                       break;
+               }
+               case MONO_WRAPPER_STELEMREF:
+                       break;
+               case MONO_WRAPPER_STATIC_RGCTX_INVOKE: {
+                       MonoMethod *m;
+
+                       m = mono_marshal_method_from_wrapper (method);
+                       g_assert (m);
+                       encode_method_ref (acfg, m, p, &p);
+                       break;
+               }
+               default:
+                       g_assert_not_reached ();
+               }
+       } else if (mono_method_signature (method)->is_inflated) {
                /* 
                 * This is a generic method, find the original token which referenced it and
                 * encode that.
@@ -1897,7 +1945,6 @@ is_plt_patch (MonoJumpInfo *patch_info)
 {
        switch (patch_info->type) {
        case MONO_PATCH_INFO_METHOD:
-       case MONO_PATCH_INFO_WRAPPER:
        case MONO_PATCH_INFO_INTERNAL_METHOD:
        case MONO_PATCH_INFO_JIT_ICALL_ADDR:
        case MONO_PATCH_INFO_CLASS_INIT:
@@ -2443,58 +2490,6 @@ encode_patch (MonoAotCompile *acfg, MonoJumpInfo *patch_info, guint8 *buf, guint
                break;
        case MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG:
                break;
-       case MONO_PATCH_INFO_WRAPPER:
-               encode_value (patch_info->data.method->wrapper_type, p, &p);
-
-               switch (patch_info->data.method->wrapper_type) {
-               case MONO_WRAPPER_REMOTING_INVOKE:
-               case MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK:
-               case MONO_WRAPPER_XDOMAIN_INVOKE: {
-                       MonoMethod *m;
-                       guint32 image_index;
-                       guint32 token;
-
-                       m = mono_marshal_method_from_wrapper (patch_info->data.method);
-                       image_index = get_image_index (acfg, m->klass->image);
-                       token = m->token;
-                       g_assert (image_index < 256);
-                       g_assert (mono_metadata_token_table (token) == MONO_TABLE_METHOD);
-
-                       encode_value ((image_index << 24) + (mono_metadata_token_index (token)), p, &p);
-                       break;
-               }
-               case MONO_WRAPPER_PROXY_ISINST:
-               case MONO_WRAPPER_LDFLD:
-               case MONO_WRAPPER_LDFLDA:
-               case MONO_WRAPPER_STFLD:
-               case MONO_WRAPPER_ISINST: {
-                       MonoClass *proxy_class = (MonoClass*)mono_marshal_method_from_wrapper (patch_info->data.method);
-                       encode_klass_ref (acfg, proxy_class, p, &p);
-                       break;
-               }
-               case MONO_WRAPPER_LDFLD_REMOTE:
-               case MONO_WRAPPER_STFLD_REMOTE:
-                       break;
-               case MONO_WRAPPER_ALLOC: {
-                       int alloc_type = mono_gc_get_managed_allocator_type (patch_info->data.method);
-                       g_assert (alloc_type != -1);
-                       encode_value (alloc_type, p, &p);
-                       break;
-               }
-               case MONO_WRAPPER_STELEMREF:
-                       break;
-               case MONO_WRAPPER_STATIC_RGCTX_INVOKE: {
-                       MonoMethod *m;
-
-                       m = mono_marshal_method_from_wrapper (patch_info->data.method);
-                       g_assert (m);
-                       encode_method_ref (acfg, m, p, &p);
-                       break;
-               }
-               default:
-                       g_assert_not_reached ();
-               }
-               break;
        case MONO_PATCH_INFO_RGCTX_FETCH: {
                MonoJumpInfoRgctxEntry *entry = patch_info->data.rgctx_entry;
 
@@ -3384,6 +3379,9 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
        /* Collect method->token associations from the cfg */
        g_hash_table_foreach (cfg->token_info_hash, add_token_info_hash, acfg);
 
+       /*
+        * Check for absolute addresses.
+        */
        skip = FALSE;
        for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
                switch (patch_info->type) {
@@ -3403,13 +3401,14 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
                return;
        }
 
-       /* Convert method patches referring to wrapper methods to MONO_PATCH_INFO_WRAPPER */
+       /*
+        * Check for wrapper methods we can't encode.
+        */
        skip = FALSE;
        for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
                if ((patch_info->type == MONO_PATCH_INFO_METHODCONST) || (patch_info->type == MONO_PATCH_INFO_METHOD)) {
                        switch (patch_info->data.method->wrapper_type) {
                        case MONO_WRAPPER_NONE:
-                               break;
                        case MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK:
                        case MONO_WRAPPER_XDOMAIN_INVOKE:
                        case MONO_WRAPPER_STFLD:
@@ -3423,7 +3422,6 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
                        case MONO_WRAPPER_ALLOC:
                        case MONO_WRAPPER_REMOTING_INVOKE:
                        case MONO_WRAPPER_STATIC_RGCTX_INVOKE:
-                               patch_info->type = MONO_PATCH_INFO_WRAPPER;
                                break;
                        default:
                                /* unable to handle this */
@@ -3434,8 +3432,15 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
                } else if (patch_info->type == MONO_PATCH_INFO_RGCTX_FETCH) {
                        MonoJumpInfo *child = patch_info->data.rgctx_entry->data;
 
-                       if (child->type == MONO_PATCH_INFO_METHODCONST && child->data.method->wrapper_type == MONO_WRAPPER_STATIC_RGCTX_INVOKE)
-                               child->type = MONO_PATCH_INFO_WRAPPER;
+                       if (child->type == MONO_PATCH_INFO_METHODCONST) {
+                               switch (child->data.method->wrapper_type) {
+                               case MONO_WRAPPER_NONE:
+                               case MONO_WRAPPER_STATIC_RGCTX_INVOKE:
+                                       break;
+                               default:
+                                       skip = TRUE;
+                               }
+                       }
                }
        }
 
@@ -3445,11 +3450,16 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
                return;
        }
 
+       /*
+        * Check for methods/klasses we can't encode.
+        */
        skip = FALSE;
        for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
                switch (patch_info->type) {
                case MONO_PATCH_INFO_METHOD:
                case MONO_PATCH_INFO_METHODCONST:
+                       if (patch_info->data.method->wrapper_type)
+                               break;
                        if (!patch_info->data.method->token) {
                                /* The method is part of a constructed type like Int[,].Set (). */
                                if (!g_hash_table_lookup (acfg->token_info_hash, patch_info->data.method))
index 476cee59aeadd646ce8f71efdec3020e766077d7..983d0d713627d59dc86ea89d7d3783fd3846c372 100644 (file)
@@ -416,7 +416,78 @@ decode_method_ref (MonoAotModule *module, guint32 *token, MonoMethod **method, g
        value = decode_value (p, &p);
        image_index = value >> 24;
 
-       if (image_index == 255) {
+       if (image_index == 253) {
+               /* Wrapper */
+               guint32 wrapper_type;
+
+               wrapper_type = decode_value (p, &p);
+
+               /* Doesn't matter */
+               image = mono_defaults.corlib;
+
+               switch (wrapper_type) {
+               case MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK: {
+                       MonoMethod *m = decode_method_ref_2 (module, p, &p);
+
+                       if (!m)
+                               return NULL;
+                       mono_class_init (m->klass);
+                       *method = mono_marshal_get_remoting_invoke_with_check (m);
+                       break;
+               }
+               case MONO_WRAPPER_PROXY_ISINST: {
+                       MonoClass *klass = decode_klass_ref (module, p, &p);
+                       if (!klass)
+                               return NULL;
+                       *method = mono_marshal_get_proxy_cancast (klass);
+                       break;
+               }
+               case MONO_WRAPPER_LDFLD:
+               case MONO_WRAPPER_LDFLDA:
+               case MONO_WRAPPER_STFLD:
+               case MONO_WRAPPER_ISINST: {
+                       MonoClass *klass = decode_klass_ref (module, p, &p);
+                       if (!klass)
+                               return NULL;
+                       if (wrapper_type == MONO_WRAPPER_LDFLD)
+                               *method = mono_marshal_get_ldfld_wrapper (&klass->byval_arg);
+                       else if (wrapper_type == MONO_WRAPPER_LDFLDA)
+                               *method = mono_marshal_get_ldflda_wrapper (&klass->byval_arg);
+                       else if (wrapper_type == MONO_WRAPPER_STFLD)
+                               *method = mono_marshal_get_stfld_wrapper (&klass->byval_arg);
+                       else if (wrapper_type == MONO_WRAPPER_ISINST)
+                               *method = mono_marshal_get_isinst (klass);
+                       else
+                               g_assert_not_reached ();
+                       break;
+               }
+               case MONO_WRAPPER_LDFLD_REMOTE:
+                       *method = mono_marshal_get_ldfld_remote_wrapper (NULL);
+                       break;
+               case MONO_WRAPPER_STFLD_REMOTE:
+                       *method = mono_marshal_get_stfld_remote_wrapper (NULL);
+                       break;
+               case MONO_WRAPPER_ALLOC: {
+                       int atype = decode_value (p, &p);
+
+                       *method = mono_gc_get_managed_allocator_by_type (atype);
+                       break;
+               }
+               case MONO_WRAPPER_STELEMREF:
+                       *method = mono_marshal_get_stelemref ();
+                       break;
+               case MONO_WRAPPER_STATIC_RGCTX_INVOKE: {
+                       MonoMethod *m = decode_method_ref_2 (module, p, &p);
+
+                       if (!m)
+                               return NULL;
+                       *method = mono_marshal_get_static_rgctx_invoke (m);
+                       break;
+               }
+               default:
+                       g_assert_not_reached ();
+               }
+       } else if (image_index == 255) {
                /* Methodspec */
                image_index = decode_value (p, &p);
                *token = decode_value (p, &p);
@@ -1489,85 +1560,6 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
 
                break;
        }
-       case MONO_PATCH_INFO_WRAPPER: {
-               guint32 wrapper_type;
-
-               wrapper_type = decode_value (p, &p);
-
-               ji->type = MONO_PATCH_INFO_METHOD;
-
-               switch (wrapper_type) {
-               case MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK: {
-                       guint32 image_index, token, value;
-
-                       value = decode_value (p, &p);
-                       image_index = value >> 24;
-                       token = MONO_TOKEN_METHOD_DEF | (value & 0xffffff);
-
-                       image = load_image (aot_module, image_index);
-                       if (!image)
-                               goto cleanup;
-                       ji->data.method = mono_get_method (image, token, NULL);
-                       g_assert (ji->data.method);
-                       mono_class_init (ji->data.method->klass);
-
-                       ji->data.method = mono_marshal_get_remoting_invoke_with_check (ji->data.method);
-                       break;
-               }
-               case MONO_WRAPPER_PROXY_ISINST: {
-                       MonoClass *klass = decode_klass_ref (aot_module, p, &p);
-                       if (!klass)
-                               goto cleanup;
-                       ji->data.method = mono_marshal_get_proxy_cancast (klass);
-                       break;
-               }
-               case MONO_WRAPPER_LDFLD:
-               case MONO_WRAPPER_LDFLDA:
-               case MONO_WRAPPER_STFLD:
-               case MONO_WRAPPER_ISINST: {
-                       MonoClass *klass = decode_klass_ref (aot_module, p, &p);
-                       if (!klass)
-                               goto cleanup;
-                       if (wrapper_type == MONO_WRAPPER_LDFLD)
-                               ji->data.method = mono_marshal_get_ldfld_wrapper (&klass->byval_arg);
-                       else if (wrapper_type == MONO_WRAPPER_LDFLDA)
-                               ji->data.method = mono_marshal_get_ldflda_wrapper (&klass->byval_arg);
-                       else if (wrapper_type == MONO_WRAPPER_STFLD)
-                               ji->data.method = mono_marshal_get_stfld_wrapper (&klass->byval_arg);
-                       else if (wrapper_type == MONO_WRAPPER_ISINST)
-                               ji->data.method = mono_marshal_get_isinst (klass);
-                       else
-                               g_assert_not_reached ();
-                       break;
-               }
-               case MONO_WRAPPER_LDFLD_REMOTE:
-                       ji->data.method = mono_marshal_get_ldfld_remote_wrapper (NULL);
-                       break;
-               case MONO_WRAPPER_STFLD_REMOTE:
-                       ji->data.method = mono_marshal_get_stfld_remote_wrapper (NULL);
-                       break;
-               case MONO_WRAPPER_ALLOC: {
-                       int atype = decode_value (p, &p);
-
-                       ji->data.method = mono_gc_get_managed_allocator_by_type (atype);
-                       break;
-               }
-               case MONO_WRAPPER_STELEMREF:
-                       ji->data.method = mono_marshal_get_stelemref ();
-                       break;
-               case MONO_WRAPPER_STATIC_RGCTX_INVOKE: {
-                       MonoMethod *m = decode_method_ref_2 (aot_module, p, &p);
-
-                       if (!m)
-                               goto cleanup;
-                       ji->data.method = mono_marshal_get_static_rgctx_invoke (m);
-                       break;
-               }
-               default:
-                       g_assert_not_reached ();
-               }
-               break;
-       }
        case MONO_PATCH_INFO_INTERNAL_METHOD:
        case MONO_PATCH_INFO_JIT_ICALL_ADDR: {
                guint32 len = decode_value (p, &p);
index 5eb0d08294ac259dbb913a7a97d25e3459ae0593..0545b9769555ad1e75d66ae663eba52dddd0aecf 100644 (file)
@@ -11293,7 +11293,6 @@ mono_patch_info_hash (gconstpointer data)
        case MONO_PATCH_INFO_IMAGE:
        case MONO_PATCH_INFO_INTERNAL_METHOD:
        case MONO_PATCH_INFO_JIT_ICALL_ADDR:
-       case MONO_PATCH_INFO_WRAPPER:
        case MONO_PATCH_INFO_FIELD:
        case MONO_PATCH_INFO_SFLDA:
                return (ji->type << 8) | (gssize)ji->data.target;
index 2099e0db65da41218cf63d3b944996e47619b01e..50edfba4b8b81a8aa26d1885a1b0c200e9c52116 100644 (file)
@@ -66,7 +66,7 @@
 #define MONO_FAKE_VTABLE_METHOD ((MonoMethod*)GINT_TO_POINTER(-2))
 
 /* Version number of the AOT file format */
-#define MONO_AOT_FILE_VERSION "37"
+#define MONO_AOT_FILE_VERSION "38"
  
 /* Per-domain information maintained by the JIT */
 typedef struct
index 7938ea3ae2339e7b720ae680f5b5c8f4fa32860f..0c9633650d34daa29ea79c428fce3f3b5a201f47 100644 (file)
@@ -25,7 +25,6 @@ PATCH_INFO(IID, "iid")
 PATCH_INFO(ADJUSTED_IID, "adjusted_iid")
 PATCH_INFO(BB_OVF, "bb_ovf")
 PATCH_INFO(EXC_OVF, "exc_ovf")
-PATCH_INFO(WRAPPER, "wrapper")
 PATCH_INFO(GOT_OFFSET, "got_offset")
 PATCH_INFO(DECLSEC, "declsec")
 PATCH_INFO(RVA, "rva")