2006-07-26 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Wed, 26 Jul 2006 18:06:43 +0000 (18:06 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 26 Jul 2006 18:06:43 +0000 (18:06 -0000)
        * domain.c: Documentation updates.

        * loader.c (mono_free_method): Do not release the method
        information if we are being profiled, as profilers will use this
        information at shut down to present some data to the user.

        This is needed so that the profiler does not crash, as the
        profiler tends to keep MonoMethods around, and they might become
        invalid if we free these.

        (mono_get_method_constrained): Return the original CIL stream
        method as well, so verification can be performed against it.

2006-07-13  Miguel de Icaza  <miguel@novell.com>

        * mini.c (mono_method_to_ir): Obtain the original method in the
        CIL stream and use this to perform validation.

        Fixed: #78816

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

mono/metadata/ChangeLog
mono/metadata/domain.c
mono/metadata/loader.c
mono/metadata/loader.h
mono/mini/ChangeLog
mono/mini/mini.c

index d9258bb5df05e1ee663c955b173eafc96db2852b..f9c6435440dc954bdfca6388813a5598f50149e9 100644 (file)
@@ -1,3 +1,18 @@
+2006-07-26  Miguel de Icaza  <miguel@novell.com>
+
+       * domain.c: Documentation updates.
+
+       * loader.c (mono_free_method): Do not release the method
+       information if we are being profiled, as profilers will use this
+       information at shut down to present some data to the user.
+
+       This is needed so that the profiler does not crash, as the
+       profiler tends to keep MonoMethods around, and they might become
+       invalid if we free these.
+
+       (mono_get_method_constrained): Return the original CIL stream
+       method as well, so verification can be performed against it.
+
 2006-07-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * filewatcher.[ch]: support for inotify file system watcher.
index 59098db4706daabf1952e0f5685c4ac0aa6ebe9c..39dbab170b2053b98ab5589d9c4ad587013b20ab 100644 (file)
@@ -890,7 +890,12 @@ mono_cleanup (void)
 /**
  * mono_get_root_domain:
  *
- * Returns: the root appdomain.
+ * The root AppDomain is the initial domain created by the runtime when it is
+ * initialized.  Programs execute on this AppDomain, but can create new ones
+ * later.   Currently there is no unmanaged API to create new AppDomains, this
+ * must be done from managed code.
+ *
+ * Returns: the root appdomain, to obtain the current domain, use mono_domain_get ()
  */
 MonoDomain*
 mono_get_root_domain (void)
@@ -901,7 +906,8 @@ mono_get_root_domain (void)
 /**
  * mono_domain_get:
  *
- * Returns: the current domain.
+ * Returns: the current domain, to obtain the root domain use
+ * mono_get_root_domain().
  */
 MonoDomain *
 mono_domain_get ()
index 1fe54a207fdad96daab4e25142ed9a7edcbe0bde..7380b5f17253f630da36a539f31bdb6cb21640d1 100644 (file)
@@ -33,6 +33,7 @@
 #include <mono/metadata/class-internals.h>
 #include <mono/metadata/debug-helpers.h>
 #include <mono/metadata/reflection.h>
+#include <mono/metadata/profiler.h>
 #include <mono/utils/mono-logger.h>
 #include <mono/metadata/exception.h>
 
@@ -1408,10 +1409,14 @@ mono_get_method_full (MonoImage *image, guint32 token, MonoClass *klass,
  * mono_get_method_constrained:
  *
  * This is used when JITing the `constrained.' opcode.
+ *
+ * This returns two values: the contrained method, which has been inflated
+ * as the function return value;   And the original CIL-stream method as
+ * declared in cil_method.  The later is used for verification.
  */
 MonoMethod *
 mono_get_method_constrained (MonoImage *image, guint32 token, MonoClass *constrained_class,
-                            MonoGenericContext *context)
+                            MonoGenericContext *context, MonoMethod **cil_method)
 {
        MonoMethod *method, *result;
        MonoClass *ic = NULL;
@@ -1420,14 +1425,14 @@ mono_get_method_constrained (MonoImage *image, guint32 token, MonoClass *constra
 
        mono_loader_lock ();
 
-       method = mono_get_method_from_token (image, token, NULL, context);
-       if (!method) {
+       *cil_method = mono_get_method_from_token (image, token, NULL, context);
+       if (!cil_method) {
                mono_loader_unlock ();
                return NULL;
        }
 
        mono_class_init (constrained_class);
-       method = mono_get_inflated_method (method);
+       method = mono_get_inflated_method (*cil_method);
        sig = mono_method_signature (method);
 
        if (method->is_inflated && sig->generic_param_count) {
@@ -1462,6 +1467,9 @@ mono_get_method_constrained (MonoImage *image, guint32 token, MonoClass *constra
 void
 mono_free_method  (MonoMethod *method)
 {
+       if (mono_profiler_get_events () != MONO_PROFILE_NONE)
+               return;
+       
        if (method->signature) {
                /* 
                 * FIXME: This causes crashes because the types inside signatures and
index b925d66b06df023445695d88b54f79c48bb8299b..517f8e06cf5c40c6372f3c852b4b418b35d61e42 100644 (file)
@@ -9,19 +9,22 @@ G_BEGIN_DECLS
 typedef gboolean (*MonoStackWalk)     (MonoMethod *method, gint32 native_offset, gint32 il_offset, gboolean managed, gpointer data);
 
 MonoMethod *
-mono_get_method            (MonoImage *image, guint32 token, MonoClass *klass);
+mono_get_method             (MonoImage *image, guint32 token, MonoClass *klass);
 
 MonoMethod *
-mono_get_method_full       (MonoImage *image, guint32 token, MonoClass *klass, MonoGenericContext *context);
+mono_get_method_full        (MonoImage *image, guint32 token, MonoClass *klass,
+                            MonoGenericContext *context);
 
 MonoMethod *
-mono_get_method_constrained (MonoImage *image, guint32 token, MonoClass *constrained_class, MonoGenericContext *context);
+mono_get_method_constrained (MonoImage *image, guint32 token, MonoClass *constrained_class,
+                            MonoGenericContext *context, MonoMethod **cil_method);
 
 void               
 mono_free_method           (MonoMethod *method);
 
 MonoMethodSignature*
-mono_method_get_signature_full (MonoMethod *method, MonoImage *image, guint32 token, MonoGenericContext *context);
+mono_method_get_signature_full (MonoMethod *method, MonoImage *image, guint32 token,
+                               MonoGenericContext *context);
 
 MonoMethodSignature* 
 mono_method_get_signature  (MonoMethod *method, MonoImage *image, guint32 token);
index 540a96f42b0e6663d4a7636c94056602ff4dd690..b8cc88a88de6a555734b78e956bad0443dc51558 100644 (file)
@@ -1,3 +1,10 @@
+2006-07-13  Miguel de Icaza  <miguel@novell.com>
+
+       * mini.c (mono_method_to_ir): Obtain the original method in the
+       CIL stream and use this to perform validation.
+
+       Fixed: #78816
+
 2006-07-19  Zoltan Varga  <vargaz@gmail.com>
 
        * mini-x86.c (mono_arch_get_argument_info): Fix a warning.
index 10f42e6e2bbca395e8a9b2de8e1e629813256313..f18ad4f184785ecc4571815e6a817ce3e96935c6 100644 (file)
@@ -4377,18 +4377,22 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
 
                                n = fsig->param_count + fsig->hasthis;
                        } else {
+                               MonoMethod *cil_method;
+                               
                                if (method->wrapper_type != MONO_WRAPPER_NONE) {
                                        cmethod =  (MonoMethod *)mono_method_get_wrapper_data (method, token);
+                                       cil_method = cmethod;
                                } else if (constrained_call) {
-                                       cmethod = mono_get_method_constrained (image, token, constrained_call, generic_context);
+                                       cmethod = mono_get_method_constrained (image, token, constrained_call, generic_context, &cil_method);
                                        cmethod = mono_get_inflated_method (cmethod);
                                } else {
                                        cmethod = mini_get_method (method, token, NULL, generic_context);
+                                       cil_method = cmethod;
                                }
 
                                if (!cmethod)
                                        goto load_error;
-                               if (!dont_verify && !can_access_method (method, cmethod))
+                               if (!dont_verify && !can_access_method (method, cil_method))
                                        UNVERIFIED;
 
                                if (!virtual && (cmethod->flags & METHOD_ATTRIBUTE_ABSTRACT))