Skip to content

Commit f36eac4

Browse files
authored
Prevent inlining for GHCJS (awakesecurity#74)
There's a bug with GHCJS, boxed tuples, and inlining, but it's hard to pin down, so I just disabled inlining in the two places it was being used for that compiler.
1 parent e05316b commit f36eac4

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Proto3/Wire/Reverse/Internal.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ instance Semigroup BuildR
134134
instance Monoid BuildR
135135
where
136136
mempty = BuildR (\v u s -> (# v, u, s #))
137+
#ifdef ghcjs_HOST_OS
138+
{-# NOINLINE mempty #-}
139+
#else
137140
{-# INLINE mempty #-}
141+
#endif
138142

139143
mappend = (<>)
140144
{-# INLINE mappend #-}

src/Proto3/Wire/Reverse/Prim.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ import Proto3.Wire.Reverse.Width ( AssocPlusNat(..),
135135

136136
#include <MachDeps.h> /* for WORDS_BIGENDIAN and WORD_SIZE_IN_BITS */
137137

138+
#ifdef ghcjs_HOST_OS
139+
import GHC.Exts (Word#)
140+
#endif
141+
138142
-- "ghc-prim" v0.6.1 defines `GHC.Prim.Ext.WORD64`, but we do not wish
139143
-- to require that version of "ghc-prim". Therefore we define it locally.
140144
#if WORD_SIZE_IN_BITS < 64
@@ -214,7 +218,11 @@ instance CommPlusNat BoundedPrim u v
214218
instance PMEmpty BoundedPrim 0
215219
where
216220
pmempty = BoundedPrim mempty
221+
#ifdef ghcjs_HOST_OS
222+
{-# NOINLINE pmempty #-}
223+
#else
217224
{-# INLINE CONLIKE pmempty #-}
225+
#endif
218226

219227
instance Max u v ~ w =>
220228
PChoose BoundedPrim u v w

0 commit comments

Comments
 (0)