tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

arm-fixes.patch (8109B)


      1 diff --git a/gfx/skia/include/core/SkMath.h b/gfx/skia/include/core/SkMath.h
      2 --- a/gfx/skia/include/core/SkMath.h
      3 +++ b/gfx/skia/include/core/SkMath.h
      4 @@ -148,20 +148,17 @@ static inline bool SkIsPow2(int value) {
      5 }
      6 
      7 ///////////////////////////////////////////////////////////////////////////////
      8 
      9 /** SkMulS16(a, b) multiplies a * b, but requires that a and b are both int16_t.
     10     With this requirement, we can generate faster instructions on some
     11     architectures.
     12 */
     13 -#if defined(__arm__) \
     14 -  && !defined(__thumb__) \
     15 -  && !defined(__ARM_ARCH_4T__) \
     16 -  && !defined(__ARM_ARCH_5T__)
     17 +#ifdef SK_ARM_HAS_EDSP
     18     static inline int32_t SkMulS16(S16CPU x, S16CPU y) {
     19         SkASSERT((int16_t)x == x);
     20         SkASSERT((int16_t)y == y);
     21         int32_t product;
     22         asm("smulbb %0, %1, %2 \n"
     23             : "=r"(product)
     24             : "r"(x), "r"(y)
     25             );
     26 diff --git a/gfx/skia/include/core/SkPostConfig.h b/gfx/skia/include/core/SkPostConfig.h
     27 --- a/gfx/skia/include/core/SkPostConfig.h
     28 +++ b/gfx/skia/include/core/SkPostConfig.h
     29 @@ -300,8 +300,53 @@
     30 #endif
     31 #endif
     32 
     33 //////////////////////////////////////////////////////////////////////
     34 
     35 #ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
     36 #define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1
     37 #endif
     38 +
     39 +//////////////////////////////////////////////////////////////////////
     40 +// ARM defines
     41 +
     42 +#if defined(__GNUC__) && defined(__arm__)
     43 +
     44 +#  define SK_ARM_ARCH 3
     45 +
     46 +#  if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) \
     47 +   || defined(_ARM_ARCH_4)
     48 +#    undef SK_ARM_ARCH
     49 +#    define SK_ARM_ARCH 4
     50 +#  endif
     51 +
     52 +#  if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \
     53 +   || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \
     54 +   || defined(__ARM_ARCH_5TEJ__) || defined(_ARM_ARCH_5)
     55 +#    undef SK_ARM_ARCH
     56 +#    define SK_ARM_ARCH 5
     57 +#  endif
     58 + 
     59 +#  if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
     60 +   || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \
     61 +   || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \
     62 +   || defined(__ARM_ARCH_6M__) || defined(_ARM_ARCH_6)
     63 +#    undef SK_ARM_ARCH
     64 +#    define SK_ARM_ARCH 6
     65 +#  endif
     66 +
     67 +#  if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
     68 +   || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
     69 +   || defined(__ARM_ARCH_7EM__) || defined(_ARM_ARCH_7)
     70 +#    undef SK_ARM_ARCH
     71 +#    define SK_ARM_ARCH 7
     72 +#  endif
     73 +
     74 +#  undef SK_ARM_HAS_EDSP
     75 +#  if defined(__thumb2__) && (SK_ARM_ARCH >= 6) \
     76 +   || !defined(__thumb__) \
     77 +   && ((SK_ARM_ARCH > 5) || defined(__ARM_ARCH_5E__) \
     78 +       || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__))
     79 +#    define SK_ARM_HAS_EDSP 1
     80 +#  endif
     81 +
     82 +#endif
     83 diff --git a/gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp b/gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp
     84 --- a/gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp
     85 +++ b/gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp
     86 @@ -6,17 +6,17 @@
     87  * found in the LICENSE file.
     88  */
     89 
     90 
     91 #include "SkBitmapProcState.h"
     92 #include "SkColorPriv.h"
     93 #include "SkUtils.h"
     94 
     95 -#if __ARM_ARCH__ >= 6 && !defined(SK_CPU_BENDIAN)
     96 +#if SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)
     97 void SI8_D16_nofilter_DX_arm(
     98     const SkBitmapProcState& s,
     99     const uint32_t* SK_RESTRICT xy,
    100     int count,
    101     uint16_t* SK_RESTRICT colors) __attribute__((optimize("O1")));
    102 
    103 void SI8_D16_nofilter_DX_arm(const SkBitmapProcState& s,
    104                              const uint32_t* SK_RESTRICT xy,
    105 @@ -177,17 +177,17 @@ void SI8_opaque_D32_nofilter_DX_arm(cons
    106                       : [xx] "+r" (xx), [count] "+r" (count), [colors] "+r" (colors)
    107                       : [table] "r" (table), [srcAddr] "r" (srcAddr)
    108                       : "memory", "cc", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11"
    109                       );
    110     }
    111 
    112     s.fBitmap->getColorTable()->unlockColors(false);
    113 }
    114 -#endif //__ARM_ARCH__ >= 6 && !defined(SK_CPU_BENDIAN)
    115 +#endif // SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)
    116 
    117 ///////////////////////////////////////////////////////////////////////////////
    118 
    119 /*  If we replace a sampleproc, then we null-out the associated shaderproc,
    120     otherwise the shader won't even look at the matrix/sampler
    121  */
    122 void SkBitmapProcState::platformProcs() {
    123     bool doFilter = fDoFilter;
    124 @@ -195,17 +195,17 @@ void SkBitmapProcState::platformProcs() 
    125     bool justDx = false;
    126 
    127     if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
    128         justDx = true;
    129     }
    130 
    131     switch (fBitmap->config()) {
    132         case SkBitmap::kIndex8_Config:
    133 -#if __ARM_ARCH__ >= 6 && !defined(SK_CPU_BENDIAN)
    134 +#if SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)
    135             if (justDx && !doFilter) {
    136 #if 0   /* crashing on android device */
    137                 fSampleProc16 = SI8_D16_nofilter_DX_arm;
    138                 fShaderProc16 = NULL;
    139 #endif
    140                 if (isOpaque) {
    141                     // this one is only very slighty faster than the C version
    142                     fSampleProc32 = SI8_opaque_D32_nofilter_DX_arm;
    143 diff --git a/gfx/skia/src/opts/SkBlitRow_opts_arm.cpp b/gfx/skia/src/opts/SkBlitRow_opts_arm.cpp
    144 --- a/gfx/skia/src/opts/SkBlitRow_opts_arm.cpp
    145 +++ b/gfx/skia/src/opts/SkBlitRow_opts_arm.cpp
    146 @@ -669,18 +669,23 @@ static void __attribute((noinline,optimi
    147                   /* Double Loop */
    148                   "1:                                \n\t" /* <double loop> */
    149                   "ldm    %[src]!, {r5, r6}          \n\t" /* loading src pointers into r5 and r6 */
    150                   "ldm    %[dst], {r7, r8}           \n\t" /* loading dst pointers into r7 and r8 */
    151 
    152                   /* dst1_scale and dst2_scale*/
    153                   "lsr    r9, r5, #24                \n\t" /* src >> 24 */
    154                   "lsr    r10, r6, #24               \n\t" /* src >> 24 */
    155 +#ifdef SK_ARM_HAS_EDSP
    156                   "smulbb r9, r9, %[alpha]           \n\t" /* r9 = SkMulS16 r9 with src_scale */
    157                   "smulbb r10, r10, %[alpha]         \n\t" /* r10 = SkMulS16 r10 with src_scale */
    158 +#else
    159 +                  "mul    r9, r9, %[alpha]           \n\t" /* r9 = SkMulS16 r9 with src_scale */
    160 +                  "mul    r10, r10, %[alpha]         \n\t" /* r10 = SkMulS16 r10 with src_scale */
    161 +#endif
    162                   "lsr    r9, r9, #8                 \n\t" /* r9 >> 8 */
    163                   "lsr    r10, r10, #8               \n\t" /* r10 >> 8 */
    164                   "rsb    r9, r9, #256               \n\t" /* dst1_scale = r9 = 255 - r9 + 1 */
    165                   "rsb    r10, r10, #256             \n\t" /* dst2_scale = r10 = 255 - r10 + 1 */
    166 
    167                   /* ---------------------- */
    168 
    169                   /* src1, src1_scale */
    170 @@ -739,17 +744,21 @@ static void __attribute((noinline,optimi
    171                                                            /* else get into the single loop */
    172                   /* Single Loop */
    173                   "2:                                \n\t" /* <single loop> */
    174                   "ldr    r5, [%[src]], #4           \n\t" /* loading src pointer into r5: r5=src */
    175                   "ldr    r7, [%[dst]]               \n\t" /* loading dst pointer into r7: r7=dst */
    176 
    177                   "lsr    r6, r5, #24                \n\t" /* src >> 24 */
    178                   "and    r8, r12, r5, lsr #8        \n\t" /* ag = r8 = r5 masked by r12 lsr by #8 */
    179 +#ifdef SK_ARM_HAS_EDSP
    180                   "smulbb r6, r6, %[alpha]           \n\t" /* r6 = SkMulS16 with src_scale */
    181 +#else
    182 +                  "mul    r6, r6, %[alpha]           \n\t" /* r6 = SkMulS16 with src_scale */
    183 +#endif
    184                   "and    r9, r12, r5                \n\t" /* rb = r9 = r5 masked by r12 */
    185                   "lsr    r6, r6, #8                 \n\t" /* r6 >> 8 */
    186                   "mul    r8, r8, %[alpha]           \n\t" /* ag = r8 times scale */
    187                   "rsb    r6, r6, #256               \n\t" /* r6 = 255 - r6 + 1 */
    188 
    189                   /* src, src_scale */
    190                   "mul    r9, r9, %[alpha]           \n\t" /* rb = r9 times scale */
    191                   "and    r8, r8, r12, lsl #8        \n\t" /* ag masked by reverse mask (r12) */