decimal-ms.c:
authorNeale Ferguson <neale@sinenomine.net>
Tue, 7 Apr 2015 16:15:43 +0000 (12:15 -0400)
committerNeale Ferguson <neale@sinenomine.net>
Tue, 7 Apr 2015 16:15:43 +0000 (12:15 -0400)
- Fix handling of lo64 on big endian systems (fixes 28672)

mono-endian.h:
- Add optimization for s390x read64/read32/read16 operations

exceptions-s390x.c:
- Add profiling support for exception handler

mono/metadata/decimal-ms.c
mono/metadata/mono-endian.h
mono/mini/exceptions-s390x.c

index 47a4ed06ca805dbd598e47cb196a27f210192d64..9330f0fb57b5bb2d6f3d7212a1850ef948fb3333 100644 (file)
@@ -55,8 +55,13 @@ static const uint32_t ten_to_ten_div_4 = 2500000000U;
 #define DECIMAL_LO32(dec)        ((dec).v.v.Lo32)
 #define DECIMAL_MID32(dec)       ((dec).v.v.Mid32)
 #define DECIMAL_HI32(dec)        ((dec).Hi32)
-#define DECIMAL_LO64_GET(dec)    ((dec).v.Lo64)
-#define DECIMAL_LO64_SET(dec,value)   {(dec).v.Lo64 = value; }
+#if G_BYTE_ORDER != G_LITTLE_ENDIAN
+# define DECIMAL_LO64_GET(dec)   (((uint64_t)((dec).v.v.Mid32) << 32) | (dec).v.v.Lo32)
+# define DECIMAL_LO64_SET(dec,value)   {(dec).v.v.Lo32 = (value); (dec).v.v.Mid32 = ((value) >> 32); }
+#else
+# define DECIMAL_LO64_GET(dec)    ((dec).v.Lo64)
+# define DECIMAL_LO64_SET(dec,value)   {(dec).v.Lo64 = value; }
+#endif
 
 #define DECIMAL_SETZERO(dec) {DECIMAL_LO32(dec) = 0; DECIMAL_MID32(dec) = 0; DECIMAL_HI32(dec) = 0; DECIMAL_SIGNSCALE(dec) = 0;}
 #define COPYDEC(dest, src) {DECIMAL_SIGNSCALE(dest) = DECIMAL_SIGNSCALE(src); DECIMAL_HI32(dest) = DECIMAL_HI32(src); \
@@ -2215,6 +2220,8 @@ mono_decimal_compare (MonoDecimal *left, MonoDecimal *right)
        uint32_t   right_sign;
        MonoDecimal result;
 
+       result.Hi32 = 0;        // Just to shut up the compiler
+
        // First check signs and whether either are zero.  If both are
        // non-zero and of the same sign, just use subtraction to compare.
        //
index 343b97194a2144e4bb4104c6cc07f03014af20ab..acc2590193fc74fac651b5f5a2237834460584be 100644 (file)
@@ -14,7 +14,49 @@ typedef union {
        unsigned char cval [8];
 } mono_rdouble;
 
-#if NO_UNALIGNED_ACCESS
+#if defined(__s390x__)
+
+#define read16(x)      s390x_read16(*(guint16 *)(x))
+#define read32(x)      s390x_read32(*(guint32 *)(x))
+#define read64(x)      s390x_read64(*(guint64 *)(x))
+
+static __inline__ guint16
+s390x_read16(guint16 x)
+{
+       guint16 ret;
+
+       __asm__ ("      lrvr    %0,%1\n"
+                "      sra     %0,16\n"
+                : "=r" (ret) : "r" (x));
+
+       return(ret);
+}
+
+static __inline__ guint32
+s390x_read32(guint32 x)
+{
+       guint32 ret;
+
+       __asm__ ("      lrvr    %0,%1\n"
+                : "=r" (ret) : "r" (x));
+
+       return(ret);
+}
+
+static __inline__ guint64
+s390x_read64(guint64 x)
+{
+       guint64 ret;
+
+       __asm__ ("      lrvgr   %0,%1\n"
+                : "=r" (ret) : "r" (x));
+
+       return(ret);
+}
+
+#else
+
+# if NO_UNALIGNED_ACCESS
 
 guint16 mono_read16 (const unsigned char *x);
 guint32 mono_read32 (const unsigned char *x);
@@ -24,12 +66,14 @@ guint64 mono_read64 (const unsigned char *x);
 #define read32(x) (mono_read32 ((const unsigned char *)(x)))
 #define read64(x) (mono_read64 ((const unsigned char *)(x)))
 
-#else
+# else
 
 #define read16(x) GUINT16_FROM_LE (*((const guint16 *) (x)))
 #define read32(x) GUINT32_FROM_LE (*((const guint32 *) (x)))
 #define read64(x) GUINT64_FROM_LE (*((const guint64 *) (x)))
 
+# endif
+
 #endif
 
 #define readr4(x,dest) \
index 9c2cfc932d53a468890e4d7ef0dda901adf41dcd..78fd645c7859aebac069ccb3616e3ab256880b55 100644 (file)
@@ -210,6 +210,9 @@ mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot)
 
        g_assert ((code - start) < SZ_THROW); 
 
+       mono_arch_flush_icache(start, code - start);
+       mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
+
        if (info)
                *info = mono_tramp_info_create ("call_filter",
                                                start, code - start, ji,
@@ -357,6 +360,9 @@ mono_arch_get_throw_exception_generic (int size, MonoTrampInfo **info,
        s390_break (code);
        g_assert ((code - start) < size);
 
+       mono_arch_flush_icache (start, code - start);
+       mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
+
        if (info)
                *info = mono_tramp_info_create (corlib ? "throw_corlib_exception" 
                                                       : (rethrow ? "rethrow_exception"