2004-11-07 Ben Maurer <bmaurer@ximian.com>
authorBen Maurer <benm@mono-cvs.ximian.com>
Mon, 8 Nov 2004 02:06:50 +0000 (02:06 -0000)
committerBen Maurer <benm@mono-cvs.ximian.com>
Mon, 8 Nov 2004 02:06:50 +0000 (02:06 -0000)
* class-internals.h (MonoMethod): Move addr to MonoMethodPInvoke
since most only those methods use it. the code member of
MonoMethodPInvoke was dead, so that can be removed too. Also,
remove inline_count (again, not used), and move slot so that it
can share bits with some other flags. This saves 8 bytes in the
structure and gives us about 50 kb back for mcs helloworld.cs

* *.[ch]: Do naming changes for the above. 2004-11-07  Ben Maurer  <bmaurer@ximian.com>

* tramp-*.c: we no longer support icalls without wrappers, so
a bit of code can be removed here

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

12 files changed:
mono/interpreter/interp.c
mono/interpreter/transform.c
mono/metadata/ChangeLog
mono/metadata/class-internals.h
mono/metadata/loader.c
mono/metadata/marshal.c
mono/mini/ChangeLog
mono/mini/exceptions-s390x.c
mono/mini/mini.c
mono/mini/tramp-amd64.c
mono/mini/tramp-sparc.c
mono/mini/tramp-x86.c

index 6598f5539d6bb6652141e5a8f3c52c35d63ced2d..e6a67b615be3a32ae272c592d712f11534b1d56a 100644 (file)
@@ -1321,15 +1321,13 @@ mono_create_method_pointer (MonoMethod *method)
         * If it is a static P/Invoke method, we can just return the pointer
         * to the method implementation.
         */
-       if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL && method->addr) {
+       if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL && ((MonoMethodPInvoke*) method)->addr) {
                ji = g_new0 (MonoJitInfo, 1);
                ji->method = method;
                ji->code_size = 1;
-               ji->code_start = method->addr;
+               ji->code_start = addr = ((MonoMethodPInvoke*) method)->addr;
 
                mono_jit_info_table_add (mono_get_root_domain (), ji);
-               
-               addr = method->addr;
        }               
        else
                addr = mono_arch_create_method_pointer (method);
@@ -1860,7 +1858,7 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context)
                        MINT_IN_BREAK;
                }
                MINT_IN_CASE(MINT_CALLINT)
-                       ves_pinvoke_method (frame, frame->runtime_method->method->signature, frame->runtime_method->method->addr, 
+                       ves_pinvoke_method (frame, frame->runtime_method->method->signature, ((MonoMethodPInvoke*) frame->runtime_method->method)->addr, 
                                    frame->runtime_method->method->string_ctor, context);
                        if (frame->ex) {
                                rtm = NULL;
index a75b47e2ece04a5635020a4536dec6944c7295fb..34f8a89ac59ffcbb39583a0f42bdb72819543ce5 100644 (file)
@@ -2849,8 +2849,8 @@ mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *cont
                        (!method->signature->hasthis || method->klass->rank == 0)) {
                        runtime_method->code = g_malloc(sizeof(short));
                        runtime_method->code[0] = MINT_CALLINT;
-                       if (method->addr == NULL)
-                               method->addr = mono_lookup_internal_call (method);
+                       if (((MonoMethodPInvoke*) method)->addr == NULL)
+                               ((MonoMethodPInvoke*) method)->addr = mono_lookup_internal_call (method);
                        runtime_method->func = mono_arch_create_trampoline (method->signature, method->string_ctor);
                } else {
                        const char *name = method->name;
index 5be8a92a314b38a65a19fb5015058534848d8aea..996c8ff14ed79456519f55c80ff21e259157a416 100644 (file)
@@ -1,5 +1,14 @@
 2004-11-07  Ben Maurer  <bmaurer@ximian.com>
 
+       * class-internals.h (MonoMethod): Move addr to MonoMethodPInvoke
+       since most only those methods use it. the code member of
+       MonoMethodPInvoke was dead, so that can be removed too. Also,
+       remove inline_count (again, not used), and move slot so that it
+       can share bits with some other flags. This saves 8 bytes in the
+       structure and gives us about 50 kb back for mcs helloworld.cs
+
+       * *.[ch]: Do naming changes for the above.
+
        * loader.c (mono_method_get_header): Lazily init the header
        on first access.
        (mono_get_method_from_token): don't init the header here
index 38dd6c9adaa99bb3c31874a482c6ca87abe5c4d7..349edcf8058aacaffac4ab610967e85b8ef77d0c 100644 (file)
@@ -44,9 +44,7 @@ struct _MonoMethod {
        guint32 token;
        MonoClass *klass;
        MonoMethodSignature *signature;
-       gpointer addr;
        gpointer info; /* runtime info */
-       gint slot;
        /* name is useful mostly for debugging */
        const char *name;
        /* this is used by the inlining algorithm */
@@ -56,7 +54,7 @@ struct _MonoMethod {
        unsigned int string_ctor:1;
        unsigned int save_lmf:1;
        unsigned int dynamic:1; /* created & destroyed during runtime */
-       gint16 inline_count;
+       gint slot : 22;
 };
 
 struct _MonoMethodNormal {
@@ -78,7 +76,7 @@ struct _MonoMethodInflated {
 
 struct _MonoMethodPInvoke {
        MonoMethod method;
-       void  (*code) (void);
+       gpointer addr;
        /* add marshal info */
        guint16 piflags;  /* pinvoke flags */
        guint16 implmap_idx;  /* index into IMPLMAP */
index 8301f8400bcd5f3fd93346600ec3323fa37d95aa..cc525e773103759a0d43a78f0feceac347f7bcaa 100644 (file)
@@ -381,7 +381,6 @@ method_from_memberref (MonoImage *image, guint32 idx, MonoGenericContext *contex
 
                if (!strcmp (mname, ".ctor")) {
                        /* we special-case this in the runtime. */
-                       result->addr = NULL;
                        return result;
                }
                
@@ -389,7 +388,6 @@ method_from_memberref (MonoImage *image, guint32 idx, MonoGenericContext *contex
                        g_assert (sig->hasthis);
                        g_assert (type->data.array->rank + 1 == sig->param_count);
                        result->iflags |= METHOD_IMPL_ATTRIBUTE_RUNTIME;
-                       result->addr = NULL;
                        return result;
                }
 
@@ -397,7 +395,6 @@ method_from_memberref (MonoImage *image, guint32 idx, MonoGenericContext *contex
                        g_assert (sig->hasthis);
                        g_assert (type->data.array->rank == sig->param_count);
                        result->iflags |= METHOD_IMPL_ATTRIBUTE_RUNTIME;
-                       result->addr = NULL;
                        return result;
                }
 
@@ -405,7 +402,6 @@ method_from_memberref (MonoImage *image, guint32 idx, MonoGenericContext *contex
                        g_assert (sig->hasthis);
                        g_assert (type->data.array->rank == sig->param_count);
                        result->iflags |= METHOD_IMPL_ATTRIBUTE_RUNTIME;
-                       result->addr = NULL;
                        return result;
                }
 
@@ -600,8 +596,8 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char
 
        g_assert (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL);
 
-       if (method->addr)
-               return method->addr;
+       if (piinfo->addr)
+               return piinfo->addr;
 
        if (method->klass->image->dynamic) {
                MonoReflectionMethodAux *method_aux = 
@@ -718,58 +714,58 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char
        }
 
        if (piinfo->piflags & PINVOKE_ATTRIBUTE_NO_MANGLE) {
-               g_module_symbol (gmodule, import, &method->addr); 
+               g_module_symbol (gmodule, import, &piinfo->addr); 
        } else {
                char *mangled_name;
 
                switch (piinfo->piflags & PINVOKE_ATTRIBUTE_CHAR_SET_MASK) {
                case PINVOKE_ATTRIBUTE_CHAR_SET_UNICODE:
                        mangled_name = g_strconcat (import, "W", NULL);
-                       g_module_symbol (gmodule, mangled_name, &method->addr); 
+                       g_module_symbol (gmodule, mangled_name, &piinfo->addr); 
                        g_free (mangled_name);
 
-                       if (!method->addr)
-                               g_module_symbol (gmodule, import, &method->addr); 
+                       if (!piinfo->addr)
+                               g_module_symbol (gmodule, import, &piinfo->addr); 
                        break;
                case PINVOKE_ATTRIBUTE_CHAR_SET_AUTO:
-                       g_module_symbol (gmodule, import, &method->addr); 
+                       g_module_symbol (gmodule, import, &piinfo->addr); 
                        break;
                case PINVOKE_ATTRIBUTE_CHAR_SET_ANSI:
                default:
                        mangled_name = g_strconcat (import, "A", NULL);
-                       g_module_symbol (gmodule, mangled_name, &method->addr); 
+                       g_module_symbol (gmodule, mangled_name, &piinfo->addr); 
                        g_free (mangled_name);
 
-                       if (!method->addr)
-                               g_module_symbol (gmodule, import, &method->addr); 
+                       if (!piinfo->addr)
+                               g_module_symbol (gmodule, import, &piinfo->addr); 
                               
                        break;                                  
                }
 
 #ifdef PLATFORM_WIN32
                /* Try the stdcall mangled name */
-               if (!method->addr) {
+               if (!piinfo->addr) {
                        /* FIX: Compute this correctly */
                        mangled_name = g_strdup_printf ("%s@%d", import, method->signature->param_count * sizeof (gpointer));
-                       g_module_symbol (gmodule, mangled_name, &method->addr); 
+                       g_module_symbol (gmodule, mangled_name, &piinfo->addr); 
                        g_free (mangled_name);
                }
-               if (!method->addr) {
+               if (!piinfo->addr) {
                        mangled_name = g_strdup_printf ("_%s@%d", import, method->signature->param_count * sizeof (gpointer));
-                       g_module_symbol (gmodule, mangled_name, &method->addr); 
+                       g_module_symbol (gmodule, mangled_name, &piinfo->addr); 
                        g_free (mangled_name);
                }
 #endif
        }
 
-       if (!method->addr) {
+       if (!piinfo->addr) {
                if (exc_class) {
                        *exc_class = "EntryPointNotFoundException";
                        *exc_arg = import;
                }
                return NULL;
        }
-       return method->addr;
+       return piinfo->addr;
 }
 
 static MonoMethod *
@@ -976,10 +972,7 @@ void
 mono_free_method  (MonoMethod *method)
 {
        mono_metadata_free_method_signature (method->signature);
-       if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
-               MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)method;
-               g_free (piinfo->code);
-       } else if (!(method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) && ((MonoMethodNormal *)method)->header) {
+       if (!(method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) && ((MonoMethodNormal *)method)->header) {
                mono_metadata_free_mh (((MonoMethodNormal *)method)->header);
        }
 
index 7557fca01b1cda4d0d87a5e710775492d38416a2..3384a0cd0e1768fb8b2e2b8b98e8b68c76b407b6 100644 (file)
@@ -453,7 +453,6 @@ mono_mb_new (MonoClass *klass, const char *name, MonoWrapperType type)
        m->klass = klass;
        m->name = g_strdup (name);
        m->inline_info = 1;
-       m->inline_count = -1;
        m->wrapper_type = type;
 
        mb->code_size = 256;
@@ -4576,14 +4575,14 @@ emit_marshal (EmitMarshalContext *m, int argnum, MonoType *t,
  * @method: The MonoMethod to wrap.
  *
  * generates IL code for the pinvoke wrapper (the generated method
- * calls the unmanaged code in method->addr)
+ * calls the unmanaged code in piinfo->addr)
  */
 MonoMethod *
 mono_marshal_get_native_wrapper (MonoMethod *method)
 {
        EmitMarshalContext m;
        MonoMethodSignature *sig, *csig;
-       MonoMethodPInvoke *piinfo;
+       MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *) method;
        MonoMethodBuilder *mb;
        MonoMarshalSpec **mspecs;
        MonoMethod *res;
@@ -4608,20 +4607,18 @@ mono_marshal_get_native_wrapper (MonoMethod *method)
            (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
                pinvoke = TRUE;
 
-       if (!method->addr) {
+       if (!piinfo->addr) {
                if (pinvoke)
                        mono_lookup_pinvoke_call (method, &exc_class, &exc_arg);
                else
-                       method->addr = mono_lookup_internal_call (method);
+                       piinfo->addr = mono_lookup_internal_call (method);
        }
 
        mb = mono_mb_new (method->klass, method->name, MONO_WRAPPER_MANAGED_TO_NATIVE);
 
        mb->method->save_lmf = 1;
-
-       piinfo = (MonoMethodPInvoke *)method;
-
-       if (!method->addr) {
+       
+       if (!piinfo->addr) {
                mono_mb_emit_exception (mb, exc_class, exc_arg);
                csig = mono_metadata_signature_dup (sig);
                csig->pinvoke = 0;
@@ -4650,8 +4647,8 @@ mono_marshal_get_native_wrapper (MonoMethod *method)
                for (i = 0; i < sig->param_count; i++)
                        mono_mb_emit_ldarg (mb, i + sig->hasthis);
 
-               g_assert (method->addr);
-               mono_mb_emit_native_call (mb, csig, method->addr);
+               g_assert (piinfo->addr);
+               mono_mb_emit_native_call (mb, csig, piinfo->addr);
                emit_thread_interrupt_checkpoint (mb);
                mono_mb_emit_byte (mb, CEE_RET);
 
@@ -4776,7 +4773,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method)
        }                       
 
        /* call the native method */
-       mono_mb_emit_native_call (mb, csig, method->addr);
+       mono_mb_emit_native_call (mb, csig, piinfo->addr);
 
        /* Set LastError if needed */
        if (piinfo->piflags & PINVOKE_ATTRIBUTE_SUPPORTS_LAST_ERROR) {
index ea3d4aeb11d04e3d7cc449b304987dc52188a4d8..93c88f9c9e8d088634950879d59e61c6d8779b20 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-07  Ben Maurer  <bmaurer@ximian.com>
+
+       * tramp-*.c: we no longer support icalls without wrappers, so
+       a bit of code can be removed here
+
 2004-11-07  Zoltan Varga  <vargaz@freemail.hu>
 
        * exceptions-sparc.c (get_throw_exception): Fix more bugs in previous
index 5ddd5822aa445ed540447f897f33bfc01801a1fb..90ecb01b18644148a0621ba85da529ed914530b3 100644 (file)
@@ -215,36 +215,7 @@ init_frame_state_for (void)
 gboolean
 mono_arch_has_unwind_info (gconstpointer addr)
 {
-#if 0
-       struct frame_state state_in;
-       struct frame_state *res;
-
-       if (!inited) 
-               init_frame_state_for ();
-       
-       if (!frame_state_for)
-               return FALSE;
-
-       g_assert (method->addr);
-
-       memset (&state_in, 0, sizeof (state_in));
-
-       /* offset 10 is just a guess, but it works for all methods tested */
-       if ((res = frame_state_for ((char *)method->addr + 10, &state_in))) {
-
-               if (res->saved [X86_EBX] != 1 ||
-                   res->saved [X86_EDI] != 1 ||
-                   res->saved [X86_EBP] != 1 ||
-                   res->saved [X86_ESI] != 1) {
-                       return FALSE;
-               }
-               return TRUE;
-       } else {
-               return FALSE;
-       }
-#else
        return FALSE;
-#endif
 }
 
 /*========================= End of Function ========================*/
index 22e3a44f206128e746fc5e6d887c5b03e9aee08e..59b1b3f4e5747bed8c0844b44d4e2d9d0a9142fa 100644 (file)
@@ -7933,10 +7933,11 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain)
        if ((method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
            (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)) {
                MonoMethod *nm;
+               MonoMethodPInvoke* piinfo = (MonoMethodPInvoke *) method;
 
-               if (!method->addr) {
+               if (!piinfo->addr) {
                        if (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)
-                               method->addr = mono_lookup_internal_call (method);
+                               piinfo->addr = mono_lookup_internal_call (method);
                        else
                                if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
                                        mono_lookup_pinvoke_call (method, NULL, NULL);
index 07642802806a78b2c855f811a3a2d1ee3201c086..a1479325ac79c4e5c6ffe00424705bd3de3937f7 100644 (file)
@@ -113,8 +113,7 @@ amd64_magic_trampoline (long *regs, guint8 *code, MonoMethod *m, guint8* tramp)
                        MonoJitInfo *target_ji = 
                                mono_jit_info_table_find (mono_domain_get (), addr);
 
-                       /* The first part of the condition means an icall without a wrapper */
-                       if ((!target_ji && m->addr) || mono_method_same_domain (ji, target_ji)) {
+                       if (mono_method_same_domain (ji, target_ji)) {
                                InterlockedExchangePointer ((gpointer*)(code - 11), addr);
                        }
                }
index a68d48296603759a723fa677ec0fe53f61b16e61..33402621f00b39ace73ad8fa4eb3f33cf85031e5 100644 (file)
@@ -113,8 +113,7 @@ sparc_magic_trampoline (MonoMethod *m, guint32 *code, guint32 *fp)
                        MonoJitInfo *target_ji = 
                                mono_jit_info_table_find (mono_domain_get (), addr);
 
-                       /* The first part of the condition means an icall without a wrapper */
-                       if ((!target_ji && m->addr) || mono_method_same_domain (ji, target_ji)) {
+                       if (mono_method_same_domain (ji, target_ji)) {
                                sparc_call_simple (code, (guint8*)addr - (guint8*)code);
                        }
                }
index 0cf283432cf12a1b09f3d003448e57f5d5caa98f..26cf1ab31a01aaa818e545be18559a7dec76d22c 100644 (file)
@@ -122,8 +122,7 @@ x86_magic_trampoline (int eax, int ecx, int edx, int esi, int edi,
                        MonoJitInfo *target_ji = 
                                mono_jit_info_table_find (mono_domain_get (), addr);
 
-                       /* The first part of the condition means an icall without a wrapper */
-                       if ((!target_ji && m->addr) || mono_method_same_domain (ji, target_ji)) {
+                       if (mono_method_same_domain (ji, target_ji)) {
                                if (!mono_running_on_valgrind ()) {
                                        InterlockedExchange ((gint32*)(code + 2), (guint)addr - ((guint)code + 1) - 5);