Skip to content

Commit

Permalink
Hide inspection testing behind build flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Nov 27, 2024
1 parent 7c0bbfe commit 73c1b9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions unison-runtime/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ when:
cpp-options: -DARRAY_CHECK
- condition: flag(stackchecks)
cpp-options: -DSTACK_CHECK
# Run optimization assertion tests, make sure this runs with O2
- condition: flag(optchecks)
ghc-options: -O2 -DOPT_CHECK
- condition: flag(dumpcore)
ghc-options: -ddump-simpl -ddump-stg-final -ddump-to-file -dsuppress-coercions -dsuppress-idinfo -dsuppress-module-prefixes -ddump-str-signatures -ddump-simpl-stats # -dsuppress-type-applications -dsuppress-type-signatures

Expand Down
10 changes: 9 additions & 1 deletion unison-runtime/src/Unison/Runtime/Machine.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import Data.Traversable
import GHC.Base (IO (..))
import GHC.Conc as STM (unsafeIOToSTM)
import GHC.Stack
import Test.Inspection qualified as TI
import Unison.Builtin.Decls (exceptionRef, ioFailureRef)
import Unison.Builtin.Decls qualified as Rf
import Unison.ConstructorReference qualified as CR
Expand Down Expand Up @@ -95,6 +94,10 @@ import UnliftIO.Concurrent qualified as UnliftIO
import Unison.Debug qualified as Debug
import System.IO.Unsafe (unsafePerformIO)
#endif

#ifdef OPT_CHECK
import Test.Inspection qualified as TI
#endif
{- ORMOLU_ENABLE -}

data RuntimeExn
Expand Down Expand Up @@ -2560,6 +2563,8 @@ die s = do
pure $ error "unreachable"
{-# INLINE die #-}

{- ORMOLU_DISABLE -}
#ifdef OPT_CHECK
-- Assert that we don't allocate any 'Stack' objects in 'eval', since we expect GHC to always
-- trigger the worker/wrapper optimization and unbox it fully, and if it fails to do so, we want to
-- know about it.
Expand All @@ -2573,6 +2578,7 @@ die s = do
--
-- If this test starts failing, here are some things you can check.
--
-- 1. Did you manually
-- 1. Are 'Stack's being passed to dynamic functions? If so, try changing those functions to take an 'XStack' instead,
-- and manually unpack/pack the 'Stack' where necessary.
-- 2. Are there calls to 'die' or 'throwIO' or something similar in which a fully polymorphic type variable is being
Expand All @@ -2581,3 +2587,5 @@ die s = do
--
-- Best of luck!
TI.inspect $ 'eval0 `TI.hasNoType` ''Stack
#endif
{- ORMOLU_ENABLE -}

0 comments on commit 73c1b9d

Please sign in to comment.