2009-02-03 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / jit-icalls.c
index 84c4630a0f8a6c80d4bcae8612c4271c34c90d69..49aaa866546e29966d06cc80286967a322341545 100644 (file)
@@ -7,9 +7,12 @@
  *
  * (C) 2002 Ximian, Inc.
  */
-
+#include <config.h>
 #include <math.h>
 #include <limits.h>
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
 
 #include "jit-icalls.h"
 
@@ -49,11 +52,8 @@ ldvirtfn_internal (MonoObject *obj, MonoMethod *method, gboolean gshared)
                res = mono_class_inflate_generic_method (res, &context);
        }
 
-       /* FIXME: only do this for methods which can be shared! */
-       if (res->is_inflated && mono_method_get_context (res)->method_inst &&
-                       mono_class_generic_sharing_enabled (res->klass)) {
+       if (mono_method_needs_static_rgctx_invoke (res, FALSE))
                res = mono_marshal_get_static_rgctx_invoke (res);
-       }
 
        return mono_ldftn (res);
 }
@@ -288,7 +288,7 @@ mono_irem_un (guint32 a, guint32 b)
 
 #endif
 
-#ifdef MONO_ARCH_EMULATE_MUL_DIV
+#if defined(MONO_ARCH_EMULATE_MUL_DIV) || defined(MONO_ARCH_EMULATE_MUL_OVF)
 
 gint32
 mono_imul (gint32 a, gint32 b)
@@ -307,7 +307,7 @@ mono_imul_ovf (gint32 a, gint32 b)
 
        res = (gint64)a * (gint64)b;
 
-       if ((res > 0x7fffffffL) || (res < -2147483648))
+       if ((res > 0x7fffffffL) || (res < -2147483648LL))
                mono_raise_exception (mono_get_exception_overflow ());
 
        return res;
@@ -600,6 +600,17 @@ mono_fclt_un (double a, double b)
        return isunordered (a, b) || a < b;
 }
 
+gboolean
+mono_isfinite (double a)
+{
+#ifdef HAVE_ISFINITE
+       return isfinite (a);
+#else
+       g_assert_not_reached ();
+       return TRUE;
+#endif
+}
+
 double
 mono_fload_r4 (float *ptr)
 {
@@ -909,12 +920,8 @@ mono_helper_compile_generic_method (MonoObject *obj, MonoMethod *method, gpointe
        g_assert (!vmethod->klass->generic_class || !vmethod->klass->generic_class->context.class_inst->is_open);
        g_assert (!context->method_inst || !context->method_inst->is_open);
        inflated = mono_class_inflate_generic_method (vmethod, context);
-       if (mono_class_generic_sharing_enabled (inflated->klass) &&
-                       mono_method_is_generic_sharable_impl (method, FALSE)) {
-               /* The method is shared generic code, so it needs a
-                  MRGCTX. */
+       if (mono_method_needs_static_rgctx_invoke (inflated, FALSE))
                inflated = mono_marshal_get_static_rgctx_invoke (inflated);
-       }
        addr = mono_compile_method (inflated);
 
        /* Since this is a virtual call, have to unbox vtypes */