2007-07-09 Mark Probst <mark.probst@gmail.com>
[mono.git] / mono / mini / jit-icalls.c
index 03ed1328978b0d9b949ec60c4519834917c7319b..d4dc21b1563773e964a00e3c64070951c91f6cd2 100644 (file)
@@ -310,7 +310,9 @@ mono_imul_ovf_un (guint32 a, guint32 b)
 
        return res;
 }
+#endif
 
+#if defined(MONO_ARCH_EMULATE_MUL_DIV) || defined(MONO_ARCH_SOFT_FLOAT)
 double
 mono_fdiv (double a, double b)
 {
@@ -417,51 +419,192 @@ mono_lshr (gint64 a, gint32 shamt)
 
 #endif
 
-/**
- * ves_array_element_address:
- * @this: a pointer to the array object
- *
- * Returns: the address of an array element.
- */
-gpointer 
-ves_array_element_address (MonoArray *this, ...)
+#ifdef MONO_ARCH_SOFT_FLOAT
+
+double
+mono_fsub (double a, double b)
 {
-       MonoClass *class;
-       va_list ap;
-       int i, ind, esize, realidx;
-       gpointer ea;
+       return a - b;
+}
 
-       MONO_ARCH_SAVE_REGS;
+double
+mono_fadd (double a, double b)
+{
+       return a + b;
+}
+
+double
+mono_fmul (double a, double b)
+{
+       return a * b;
+}
+
+double
+mono_fneg (double a)
+{
+       return -a;
+}
+
+double
+mono_fconv_r4 (double a)
+{
+       return (float)a;
+}
+
+double
+mono_conv_to_r8 (int a)
+{
+       return (double)a;
+}
 
-       g_assert (this != NULL);
+double
+mono_conv_to_r4 (int a)
+{
+       return (double)(float)a;
+}
 
-       va_start(ap, this);
+gint8
+mono_fconv_i1 (double a)
+{
+       return (gint8)a;
+}
+
+gint16
+mono_fconv_i2 (double a)
+{
+       return (gint16)a;
+}
 
-       class = this->obj.vtable->klass;
+gint32
+mono_fconv_i4 (double a)
+{
+       return (gint32)a;
+}
 
-       g_assert (this->bounds != NULL);
+guint8
+mono_fconv_u1 (double a)
+{
+       return (guint8)a;
+}
 
-       esize = mono_array_element_size (class);
-       ind = va_arg(ap, int);
-       ind -= (int)this->bounds [0].lower_bound;
-       if ((guint32)ind >= (guint32)this->bounds [0].length)
-               mono_raise_exception (mono_get_exception_index_out_of_range ());
-       for (i = 1; i < class->rank; i++) {
-               realidx = va_arg(ap, int) - (int)this->bounds [i].lower_bound;
-               if ((guint32)realidx >= (guint32)this->bounds [i].length)
-                       mono_raise_exception (mono_get_exception_index_out_of_range ());
-               ind *= this->bounds [i].length;
-               ind += realidx;
-       }
-       esize *= ind;
+guint16
+mono_fconv_u2 (double a)
+{
+       return (guint16)a;
+}
 
-       ea = (gpointer*)(gpointer)((char*)this->vector + esize);
+gboolean
+mono_fcmp_eq (double a, double b)
+{
+       return a == b;
+}
 
-       va_end(ap);
+gboolean
+mono_fcmp_ge (double a, double b)
+{
+       return a >= b;
+}
 
-       return ea;
+gboolean
+mono_fcmp_gt (double a, double b)
+{
+       return a > b;
 }
 
+gboolean
+mono_fcmp_le (double a, double b)
+{
+       return a <= b;
+}
+
+gboolean
+mono_fcmp_lt (double a, double b)
+{
+       return a < b;
+}
+
+gboolean
+mono_fcmp_ne_un (double a, double b)
+{
+       return isunordered (a, b) || a != b;
+}
+
+gboolean
+mono_fcmp_ge_un (double a, double b)
+{
+       return isunordered (a, b) || a >= b;
+}
+
+gboolean
+mono_fcmp_gt_un (double a, double b)
+{
+       return isunordered (a, b) || a > b;
+}
+
+gboolean
+mono_fcmp_le_un (double a, double b)
+{
+       return isunordered (a, b) || a <= b;
+}
+
+gboolean
+mono_fcmp_lt_un (double a, double b)
+{
+       return isunordered (a, b) || a < b;
+}
+
+gboolean
+mono_fceq (double a, double b)
+{
+       return a == b;
+}
+
+gboolean
+mono_fcgt (double a, double b)
+{
+       return a > b;
+}
+
+gboolean
+mono_fcgt_un (double a, double b)
+{
+       return a > b;
+}
+
+gboolean
+mono_fclt (double a, double b)
+{
+       return a < b;
+}
+
+gboolean
+mono_fclt_un (double a, double b)
+{
+       return a < b;
+}
+
+double
+mono_fload_r4 (float *ptr)
+{
+       return *ptr;
+}
+
+void
+mono_fstore_r4 (double val, float *ptr)
+{
+       *ptr = (float)val;
+}
+
+/* returns the integer bitpattern that is passed in the regs or stack */
+guint32
+mono_fload_r4_arg (double val)
+{
+       float v = (float)val;
+       return *(guint32*)&v;
+}
+
+#endif
+
 MonoArray *
 mono_array_new_va (MonoMethod *cm, ...)
 {
@@ -643,6 +786,8 @@ mono_helper_compile_generic_method (MonoObject *obj, MonoMethod *method, MonoGen
        MonoMethod *vmethod, *inflated;
        gpointer addr;
 
+       mono_jit_stats.generic_virtual_invocations++;
+
        if (obj == NULL)
                mono_raise_exception (mono_get_exception_null_reference ());
        vmethod = mono_object_get_virtual_method (obj, method);
@@ -654,8 +799,8 @@ mono_helper_compile_generic_method (MonoObject *obj, MonoMethod *method, MonoGen
           the same context.
        */
        g_assert (!vmethod->klass->generic_container);
-       g_assert (!vmethod->klass->generic_class || !vmethod->klass->generic_class->inst->is_open);
-       g_assert (!context->gmethod || !context->gmethod->inst->is_open);
+       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);
        inflated = mono_get_inflated_method (inflated);
        addr = mono_compile_method (inflated);