diff options
-rw-r--r-- | compiler/GHC/Builtin/PrimOps.hs | 18 | ||||
-rw-r--r-- | compiler/GHC/Builtin/primops.txt.pp | 1128 | ||||
-rw-r--r-- | compiler/ghc.mk | 9 | ||||
-rw-r--r-- | distrib/hc-build | 3 | ||||
-rw-r--r-- | hadrian/src/Rules/Generate.hs | 5 | ||||
-rw-r--r-- | hadrian/src/Settings/Builders/GenPrimopCode.hs | 3 | ||||
-rw-r--r-- | utils/genprimopcode/Main.hs | 12 |
7 files changed, 590 insertions, 588 deletions
diff --git a/compiler/GHC/Builtin/PrimOps.hs b/compiler/GHC/Builtin/PrimOps.hs index 521a4035d9..b67dc092fd 100644 --- a/compiler/GHC/Builtin/PrimOps.hs +++ b/compiler/GHC/Builtin/PrimOps.hs @@ -328,9 +328,16 @@ primOpOutOfLine :: PrimOp -> Bool -- them. data PrimOpEffect = NoEffect + -- ^ Triggers no side-effects. | ThrowsImprecise + -- ^ May throw an /imprecise/ exception. + -- See Note [Precise vs imprecise exceptions] in GHC.Types.Demand. | WriteEffect + -- ^ May perform a write effect, such as writing out to a file or a mutable + -- ref cell. (Or any of the weaker effects.) | ThrowsPrecise + -- ^ May throw a /precise/ exception. (Or any of the weaker effects.) + -- See Note [Precise vs imprecise exceptions] in GHC.Types.Demand. deriving (Eq, Ord) -- | Can we discard a call to the primop, i.e. @case a `op` b of _ -> rhs@? @@ -513,11 +520,16 @@ Two main predicates on primpops test these flags: has_side_effects things (very very very) not-cheap! -} -primOpHasSideEffects :: PrimOp -> Bool -#include "primop-has-side-effects.hs-incl" +primOpEffect :: PrimOp -> PrimOpEffect +#include "primop-effect.hs-incl" + +primOpOkForSideEffects :: PrimOp -> Bool +-- This is exactly @isDupablePrimOpEffect (primOpEffect op)@ +primOpOkForSideEffects op = primOpEffect op < WriteEffect primOpCanFail :: PrimOp -> Bool -#include "primop-can-fail.hs-incl" +-- This is exactly @isSpeculatablePrimOpEffect (primOpEffect op)@ +primOpCanFail op = primOpEffect op < ThrowsImprecise primOpOkForSpeculation :: PrimOp -> Bool -- See Note [PrimOp can_fail and has_side_effects] diff --git a/compiler/GHC/Builtin/primops.txt.pp b/compiler/GHC/Builtin/primops.txt.pp index 1e3b9b8af5..7feb37c549 100644 --- a/compiler/GHC/Builtin/primops.txt.pp +++ b/compiler/GHC/Builtin/primops.txt.pp @@ -67,16 +67,15 @@ -- #). defaults - has_side_effects = False - out_of_line = False -- See Note [When do out-of-line primops go in primops.txt.pp] - can_fail = False -- See Note [PrimOp can_fail and has_side_effects] in PrimOp - commutable = False - code_size = { primOpCodeSizeDefault } - strictness = { \ arity -> mkClosedStrictSig (replicate arity topDmd) topDiv } - fixity = Nothing - llvm_only = False - vector = [] - deprecated_msg = {} -- A non-empty message indicates deprecation + effect = NoEffect -- See Note [Classification by PrimOpEffect] in PrimOp.hs + out_of_line = False -- See Note [When do out-of-line primops go in primops.txt.pp] + commutable = False + code_size = { primOpCodeSizeDefault } + strictness = { \ arity -> mkClosedStrictSig (replicate arity topDmd) topDiv } + fixity = Nothing + llvm_only = False + vector = [] + deprecated_msg = {} -- A non-empty message indicates deprecation -- Note [When do out-of-line primops go in primops.txt.pp] @@ -98,9 +97,9 @@ defaults -- first. Specifically, `foreign import prim` always requires: -- -- - No polymorphism in type --- - `strictness = <default>` --- - `can_fail = False` --- - `has_side_effects = True` +-- - `strictness = <default>` +-- - `can_fail = False` +-- - `effect = WriteEffect` -- -- https://gitlab.haskell.org/ghc/ghc/issues/16929 tracks this issue, -- and has a table of which external-only primops are blocked by which @@ -254,15 +253,15 @@ primop Int8MulOp "timesInt8#" Dyadic Int8# -> Int8# -> Int8# primop Int8QuotOp "quotInt8#" Dyadic Int8# -> Int8# -> Int8# with - can_fail = True + effect = ThrowsImprecise primop Int8RemOp "remInt8#" Dyadic Int8# -> Int8# -> Int8# with - can_fail = True + effect = ThrowsImprecise primop Int8QuotRemOp "quotRemInt8#" GenPrimOp Int8# -> Int8# -> (# Int8#, Int8# #) with - can_fail = True + effect = ThrowsImprecise primop Int8EqOp "eqInt8#" Compare Int8# -> Int8# -> Int# primop Int8GeOp "geInt8#" Compare Int8# -> Int8# -> Int# @@ -295,15 +294,15 @@ primop Word8MulOp "timesWord8#" Dyadic Word8# -> Word8# -> Word8# primop Word8QuotOp "quotWord8#" Dyadic Word8# -> Word8# -> Word8# with - can_fail = True + effect = ThrowsImprecise primop Word8RemOp "remWord8#" Dyadic Word8# -> Word8# -> Word8# with - can_fail = True + effect = ThrowsImprecise primop Word8QuotRemOp "quotRemWord8#" GenPrimOp Word8# -> Word8# -> (# Word8#, Word8# #) with - can_fail = True + effect = ThrowsImprecise primop Word8EqOp "eqWord8#" Compare Word8# -> Word8# -> Int# primop Word8GeOp "geWord8#" Compare Word8# -> Word8# -> Int# @@ -336,15 +335,15 @@ primop Int16MulOp "timesInt16#" Dyadic Int16# -> Int16# -> Int16# primop Int16QuotOp "quotInt16#" Dyadic Int16# -> Int16# -> Int16# with - can_fail = True + effect = ThrowsImprecise primop Int16RemOp "remInt16#" Dyadic Int16# -> Int16# -> Int16# with - can_fail = True + effect = ThrowsImprecise primop Int16QuotRemOp "quotRemInt16#" GenPrimOp Int16# -> Int16# -> (# Int16#, Int16# #) with - can_fail = True + effect = ThrowsImprecise primop Int16EqOp "eqInt16#" Compare Int16# -> Int16# -> Int# primop Int16GeOp "geInt16#" Compare Int16# -> Int16# -> Int# @@ -377,15 +376,15 @@ primop Word16MulOp "timesWord16#" Dyadic Word16# -> Word16# -> Word16# primop Word16QuotOp "quotWord16#" Dyadic Word16# -> Word16# -> Word16# with - can_fail = True + effect = ThrowsImprecise primop Word16RemOp "remWord16#" Dyadic Word16# -> Word16# -> Word16# with - can_fail = True + effect = ThrowsImprecise primop Word16QuotRemOp "quotRemWord16#" GenPrimOp Word16# -> Word16# -> (# Word16#, Word16# #) with - can_fail = True + effect = ThrowsImprecise primop Word16EqOp "eqWord16#" Compare Word16# -> Word16# -> Int# primop Word16GeOp "geWord16#" Compare Word16# -> Word16# -> Int# @@ -472,19 +471,19 @@ primop IntQuotOp "quotInt#" Dyadic {Rounds towards zero. The behavior is undefined if the second argument is zero. } - with can_fail = True + with effect = ThrowsImprecise primop IntRemOp "remInt#" Dyadic Int# -> Int# -> Int# {Satisfies \texttt{(quotInt\# x y) *\# y +\# (remInt\# x y) == x}. The behavior is undefined if the second argument is zero. } - with can_fail = True + with effect = ThrowsImprecise primop IntQuotRemOp "quotRemInt#" GenPrimOp Int# -> Int# -> (# Int#, Int# #) {Rounds towards zero.} - with can_fail = True + with effect = ThrowsImprecise primop AndIOp "andI#" Dyadic Int# -> Int# -> Int# {Bitwise "and".} @@ -609,20 +608,20 @@ primop WordMul2Op "timesWord2#" GenPrimOp with commutable = True primop WordQuotOp "quotWord#" Dyadic Word# -> Word# -> Word# - with can_fail = True + with effect = ThrowsImprecise primop WordRemOp "remWord#" Dyadic Word# -> Word# -> Word# - with can_fail = True + with effect = ThrowsImprecise primop WordQuotRemOp "quotRemWord#" GenPrimOp Word# -> Word# -> (# Word#, Word# #) - with can_fail = True + with effect = ThrowsImprecise primop WordQuotRem2Op "quotRemWord2#" GenPrimOp Word# -> Word# -> Word# -> (# Word#, Word# #) { Takes high word of dividend, then low word of dividend, then divisor. Requires that high word < divisor.} - with can_fail = True + with effect = ThrowsImprecise primop AndOp "and#" Dyadic Word# -> Word# -> Word# with commutable = True @@ -783,7 +782,7 @@ primop DoubleMulOp "*##" Dyadic primop DoubleDivOp "/##" Dyadic Double# -> Double# -> Double# - with can_fail = True + with effect = ThrowsImprecise fixity = infixl 7 primop DoubleNegOp "negateDouble#" Monadic Double# -> Double# @@ -811,13 +810,13 @@ primop DoubleLogOp "logDouble#" Monadic Double# -> Double# with code_size = { primOpCodeSizeForeignCall } - can_fail = True + effect = ThrowsImprecise primop DoubleLog1POp "log1pDouble#" Monadic Double# -> Double# with code_size = { primOpCodeSizeForeignCall } - can_fail = True + effect = ThrowsImprecise primop DoubleSqrtOp "sqrtDouble#" Monadic Double# -> Double# @@ -843,13 +842,13 @@ primop DoubleAsinOp "asinDouble#" Monadic Double# -> Double# with code_size = { primOpCodeSizeForeignCall } - can_fail = True + effect = ThrowsImprecise primop DoubleAcosOp "acosDouble#" Monadic Double# -> Double# with code_size = { primOpCodeSizeForeignCall } - can_fail = True + effect = ThrowsImprecise primop DoubleAtanOp "atanDouble#" Monadic Double# -> Double# @@ -938,7 +937,7 @@ primop FloatMulOp "timesFloat#" Dyadic primop FloatDivOp "divideFloat#" Dyadic Float# -> Float# -> Float# - with can_fail = True + with effect = ThrowsImprecise primop FloatNegOp "negateFloat#" Monadic Float# -> Float# @@ -963,13 +962,13 @@ primop FloatLogOp "logFloat#" Monadic Float# -> Float# with code_size = { primOpCodeSizeForeignCall } - can_fail = True + effect = ThrowsImprecise primop FloatLog1POp "log1pFloat#" Monadic Float# -> Float# with code_size = { primOpCodeSizeForeignCall } - can_fail = True + effect = ThrowsImprecise primop FloatSqrtOp "sqrtFloat#" Monadic Float# -> Float# @@ -995,13 +994,13 @@ primop FloatAsinOp "asinFloat#" Monadic Float# -> Float# with code_size = { primOpCodeSizeForeignCall } - can_fail = True + effect = ThrowsImprecise primop FloatAcosOp "acosFloat#" Monadic Float# -> Float# with code_size = { primOpCodeSizeForeignCall } - can_fail = True + effect = ThrowsImprecise primop FloatAtanOp "atanFloat#" Monadic Float# -> Float# @@ -1067,7 +1066,8 @@ primop NewArrayOp "newArray#" GenPrimOp with each element containing the specified initial value.} with out_of_line = True - has_side_effects = True + -- effect = NoEffect -- #3207 + effect = WriteEffect primop SameMutableArrayOp "sameMutableArray#" GenPrimOp MutableArray# s a -> MutableArray# s a -> Int# @@ -1076,16 +1076,15 @@ primop ReadArrayOp "readArray#" GenPrimOp MutableArray# s a -> Int# -> State# s -> (# State# s, a #) {Read from specified index of mutable array. Result is not yet evaluated.} with - has_side_effects = True - can_fail = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteArrayOp "writeArray#" GenPrimOp MutableArray# s a -> Int# -> a -> State# s -> State# s {Write to specified index of mutable array.} with - has_side_effects = True - can_fail = True - code_size = 2 -- card update too + effect = WriteEffect + code_size = 2 -- card update too primop SizeofArrayOp "sizeofArray#" GenPrimOp Array# a -> Int# @@ -1105,20 +1104,20 @@ primop IndexArrayOp "indexArray#" GenPrimOp heap. Avoiding these thunks, in turn, reduces references to the argument array, allowing it to be garbage collected more promptly.} with - can_fail = True + effect = ThrowsImprecise primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp MutableArray# s a -> State# s -> (# State# s, Array# a #) {Make a mutable array immutable, without copying.} with - has_side_effects = True + effect = WriteEffect primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp Array# a -> State# s -> (# State# s, MutableArray# s a #) {Make an immutable array mutable, without copying.} with out_of_line = True - has_side_effects = True + effect = WriteEffect primop CopyArrayOp "copyArray#" GenPrimOp Array# a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s @@ -1130,9 +1129,8 @@ primop CopyArrayOp "copyArray#" GenPrimOp be the same array in different states, but this is not checked either.} with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + effect = WriteEffect primop CopyMutableArrayOp "copyMutableArray#" GenPrimOp MutableArray# s a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s @@ -1144,9 +1142,8 @@ primop CopyMutableArrayOp "copyMutableArray#" GenPrimOp the source and destination are the same array the source and destination regions may overlap.} with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + effect = WriteEffect primop CloneArrayOp "cloneArray#" GenPrimOp Array# a -> Int# -> Int# -> Array# a @@ -1155,9 +1152,8 @@ primop CloneArrayOp "cloneArray#" GenPrimOp source array. The provided array must fully contain the specified range, but this is not checked.} with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + effect = WriteEffect primop CloneMutableArrayOp "cloneMutableArray#" GenPrimOp MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #) @@ -1166,9 +1162,8 @@ primop CloneMutableArrayOp "cloneMutableArray#" GenPrimOp source array. The provided array must fully contain the specified range, but this is not checked.} with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + effect = WriteEffect primop FreezeArrayOp "freezeArray#" GenPrimOp MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, Array# a #) @@ -1177,9 +1172,9 @@ primop FreezeArrayOp "freezeArray#" GenPrimOp source array. The provided array must fully contain the specified range, but this is not checked.} with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ThawArrayOp "thawArray#" GenPrimOp Array# a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #) @@ -1188,9 +1183,9 @@ primop ThawArrayOp "thawArray#" GenPrimOp source array. The provided array must fully contain the specified range, but this is not checked.} with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop CasArrayOp "casArray#" GenPrimOp MutableArray# s a -> Int# -> a -> a -> State# s -> (# State# s, Int#, a #) @@ -1208,7 +1203,7 @@ primop CasArrayOp "casArray#" GenPrimOp } with out_of_line = True - has_side_effects = True + effect = WriteEffect ------------------------------------------------------------------------ @@ -1245,7 +1240,8 @@ primop NewSmallArrayOp "newSmallArray#" GenPrimOp with each element containing the specified initial value.} with out_of_line = True - has_side_effects = True + -- effect = NoEffect -- #3207 + effect = WriteEffect primop SameSmallMutableArrayOp "sameSmallMutableArray#" GenPrimOp SmallMutableArray# s a -> SmallMutableArray# s a -> Int# @@ -1256,21 +1252,20 @@ primop ShrinkSmallMutableArrayOp_Char "shrinkSmallMutableArray#" GenPrimOp the specified state thread. The new size argument must be less than or equal to the current size as reported by {\tt getSizeofSmallMutableArray\#}.} with out_of_line = True - has_side_effects = True + effect = WriteEffect primop ReadSmallArrayOp "readSmallArray#" GenPrimOp SmallMutableArray# s a -> Int# -> State# s -> (# State# s, a #) {Read from specified index of mutable array. Result is not yet evaluated.} with - has_side_effects = True - can_fail = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteSmallArrayOp "writeSmallArray#" GenPrimOp SmallMutableArray# s a -> Int# -> a -> State# s -> State# s {Write to specified index of mutable array.} with - has_side_effects = True - can_fail = True + effect = WriteEffect primop SizeofSmallArrayOp "sizeofSmallArray#" GenPrimOp SmallArray# a -> Int# @@ -1292,20 +1287,20 @@ primop IndexSmallArrayOp "indexSmallArray#" GenPrimOp {Read from specified index of immutable array. Result is packaged into an unboxed singleton; the result itself is not yet evaluated.} with - can_fail = True + effect = ThrowsImprecise primop UnsafeFreezeSmallArrayOp "unsafeFreezeSmallArray#" GenPrimOp SmallMutableArray# s a -> State# s -> (# State# s, SmallArray# a #) {Make a mutable array immutable, without copying.} with - has_side_effects = True + effect = WriteEffect primop UnsafeThawSmallArrayOp "unsafeThawSmallArray#" GenPrimOp SmallArray# a -> State# s -> (# State# s, SmallMutableArray# s a #) {Make an immutable array mutable, without copying.} with out_of_line = True - has_side_effects = True + effect = WriteEffect -- The code_size is only correct for the case when the copy family of -- primops aren't inlined. It would be nice to keep track of both. @@ -1320,9 +1315,8 @@ primop CopySmallArrayOp "copySmallArray#" GenPrimOp be the same array in different states, but this is not checked either.} with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + effect = WriteEffect primop CopySmallMutableArrayOp "copySmallMutableArray#" GenPrimOp SmallMutableArray# s a -> Int# -> SmallMutableArray# s a -> Int# -> Int# -> State# s -> State# s @@ -1335,9 +1329,8 @@ primop CopySmallMutableArrayOp "copySmallMutableArray#" GenPrimOp The regions are allowed to overlap, although this is only possible when the same array is provided as both the source and the destination. } with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + effect = WriteEffect primop CloneSmallArrayOp "cloneSmallArray#" GenPrimOp SmallArray# a -> Int# -> Int# -> SmallArray# a @@ -1346,9 +1339,8 @@ primop CloneSmallArrayOp "cloneSmallArray#" GenPrimOp source array. The provided array must fully contain the specified range, but this is not checked.} with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + effect = ThrowsImprecise primop CloneSmallMutableArrayOp "cloneSmallMutableArray#" GenPrimOp SmallMutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, SmallMutableArray# s a #) @@ -1357,9 +1349,9 @@ primop CloneSmallMutableArrayOp "cloneSmallMutableArray#" GenPrimOp source array. The provided array must fully contain the specified range, but this is not checked.} with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop FreezeSmallArrayOp "freezeSmallArray#" GenPrimOp SmallMutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, SmallArray# a #) @@ -1368,9 +1360,9 @@ primop FreezeSmallArrayOp "freezeSmallArray#" GenPrimOp source array. The provided array must fully contain the specified range, but this is not checked.} with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ThawSmallArrayOp "thawSmallArray#" GenPrimOp SmallArray# a -> Int# -> Int# -> State# s -> (# State# s, SmallMutableArray# s a #) @@ -1379,9 +1371,9 @@ primop ThawSmallArrayOp "thawSmallArray#" GenPrimOp source array. The provided array must fully contain the specified range, but this is not checked.} with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop CasSmallArrayOp "casSmallArray#" GenPrimOp SmallMutableArray# s a -> Int# -> a -> a -> State# s -> (# State# s, Int#, a #) @@ -1389,7 +1381,7 @@ primop CasSmallArrayOp "casSmallArray#" GenPrimOp See the documentation of {\tt casArray\#}.} with out_of_line = True - has_side_effects = True + effect = WriteEffect ------------------------------------------------------------------------ section "Byte Arrays" @@ -1415,19 +1407,22 @@ primop NewByteArrayOp_Char "newByteArray#" GenPrimOp {Create a new mutable byte array of specified size (in bytes), in the specified state thread.} with out_of_line = True - has_side_effects = True + -- effect = NoEffec --#3207 + effect = WriteEffect primop NewPinnedByteArrayOp_Char "newPinnedByteArray#" GenPrimOp Int# -> State# s -> (# State# s, MutableByteArray# s #) {Create a mutable byte array that the GC guarantees not to move.} with out_of_line = True - has_side_effects = True + -- effect = NoEffec --#3207 + effect = WriteEffect primop NewAlignedPinnedByteArrayOp_Char "newAlignedPinnedByteArray#" GenPrimOp Int# -> Int# -> State# s -> (# State# s, MutableByteArray# s #) {Create a mutable byte array, aligned by the specified amount, that the GC guarantees not to move.} with out_of_line = True - has_side_effects = True + -- effect = NoEffec --#3207 + effect = WriteEffect primop MutableByteArrayIsPinnedOp "isMutableByteArrayPinned#" GenPrimOp MutableByteArray# s -> Int# @@ -1453,7 +1448,7 @@ primop ShrinkMutableByteArrayOp_Char "shrinkMutableByteArray#" GenPrimOp the specified state thread. The new size argument must be less than or equal to the current size as reported by {\tt getSizeofMutableByteArray\#}.} with out_of_line = True - has_side_effects = True + effect = WriteEffect primop ResizeMutableByteArrayOp_Char "resizeMutableByteArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s,MutableByteArray# s #) @@ -1469,13 +1464,13 @@ primop ResizeMutableByteArrayOp_Char "resizeMutableByteArray#" GenPrimOp to allow garbage collection of the original {\tt MutableByteArray\#} in case a new {\tt MutableByteArray\#} had to be allocated.} with out_of_line = True - has_side_effects = True + effect = WriteEffect primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp MutableByteArray# s -> State# s -> (# State# s, ByteArray# #) {Make a mutable byte array immutable, without copying.} with - has_side_effects = True + effect = WriteEffect primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp ByteArray# -> Int# @@ -1495,452 +1490,452 @@ primop GetSizeofMutableByteArrayOp "getSizeofMutableByteArray#" GenPrimOp primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp ByteArray# -> Int# -> Char# {Read 8-bit character; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp ByteArray# -> Int# -> Char# {Read 31-bit character; offset in 4-byte words.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp ByteArray# -> Int# -> Int# - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp ByteArray# -> Int# -> Word# - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp ByteArray# -> Int# -> Addr# - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp ByteArray# -> Int# -> Float# - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp ByteArray# -> Int# -> Double# - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp ByteArray# -> Int# -> StablePtr# a - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp ByteArray# -> Int# -> Int# {Read 8-bit integer; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp ByteArray# -> Int# -> Int# {Read 16-bit integer; offset in 16-bit words.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp ByteArray# -> Int# -> INT32 {Read 32-bit integer; offset in 32-bit words.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp ByteArray# -> Int# -> INT64 {Read 64-bit integer; offset in 64-bit words.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp ByteArray# -> Int# -> Word# {Read 8-bit word; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp ByteArray# -> Int# -> Word# {Read 16-bit word; offset in 16-bit words.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp ByteArray# -> Int# -> WORD32 {Read 32-bit word; offset in 32-bit words.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp ByteArray# -> Int# -> WORD64 {Read 64-bit word; offset in 64-bit words.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsChar "indexWord8ArrayAsChar#" GenPrimOp ByteArray# -> Int# -> Char# {Read 8-bit character; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsWideChar "indexWord8ArrayAsWideChar#" GenPrimOp ByteArray# -> Int# -> Char# {Read 31-bit character; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsAddr "indexWord8ArrayAsAddr#" GenPrimOp ByteArray# -> Int# -> Addr# {Read address; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsFloat "indexWord8ArrayAsFloat#" GenPrimOp ByteArray# -> Int# -> Float# {Read float; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsDouble "indexWord8ArrayAsDouble#" GenPrimOp ByteArray# -> Int# -> Double# {Read double; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsStablePtr "indexWord8ArrayAsStablePtr#" GenPrimOp ByteArray# -> Int# -> StablePtr# a {Read stable pointer; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsInt16 "indexWord8ArrayAsInt16#" GenPrimOp ByteArray# -> Int# -> Int# {Read 16-bit int; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsInt32 "indexWord8ArrayAsInt32#" GenPrimOp ByteArray# -> Int# -> INT32 {Read 32-bit int; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsInt64 "indexWord8ArrayAsInt64#" GenPrimOp ByteArray# -> Int# -> INT64 {Read 64-bit int; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsInt "indexWord8ArrayAsInt#" GenPrimOp ByteArray# -> Int# -> Int# {Read int; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsWord16 "indexWord8ArrayAsWord16#" GenPrimOp ByteArray# -> Int# -> Word# {Read 16-bit word; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsWord32 "indexWord8ArrayAsWord32#" GenPrimOp ByteArray# -> Int# -> WORD32 {Read 32-bit word; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsWord64 "indexWord8ArrayAsWord64#" GenPrimOp ByteArray# -> Int# -> WORD64 {Read 64-bit word; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexByteArrayOp_Word8AsWord "indexWord8ArrayAsWord#" GenPrimOp ByteArray# -> Int# -> Word# {Read word; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) {Read 8-bit character; offset in bytes.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) {Read 31-bit character; offset in 4-byte words.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) {Read integer; offset in machine words.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) {Read word; offset in machine words.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsChar "readWord8ArrayAsChar#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsWideChar "readWord8ArrayAsWideChar#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsAddr "readWord8ArrayAsAddr#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsFloat "readWord8ArrayAsFloat#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsDouble "readWord8ArrayAsDouble#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsStablePtr "readWord8ArrayAsStablePtr#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsInt16 "readWord8ArrayAsInt16#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsInt32 "readWord8ArrayAsInt32#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsInt64 "readWord8ArrayAsInt64#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsInt "readWord8ArrayAsInt#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsWord16 "readWord8ArrayAsWord16#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsWord32 "readWord8ArrayAsWord32#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsWord64 "readWord8ArrayAsWord64#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadByteArrayOp_Word8AsWord "readWord8ArrayAsWord#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp MutableByteArray# s -> Int# -> Char# -> State# s -> State# s {Write 8-bit character; offset in bytes.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp MutableByteArray# s -> Int# -> Char# -> State# s -> State# s {Write 31-bit character; offset in 4-byte words.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp MutableByteArray# s -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp MutableByteArray# s -> Int# -> Float# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp MutableByteArray# s -> Int# -> Double# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s - with can_fail = True - has_side_effects = True + with effect = ThrowsImprecise + effect = WriteEffect primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp MutableByteArray# s -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp MutableByteArray# s -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsChar "writeWord8ArrayAsChar#" GenPrimOp MutableByteArray# s -> Int# -> Char# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsWideChar "writeWord8ArrayAsWideChar#" GenPrimOp MutableByteArray# s -> Int# -> Char# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsAddr "writeWord8ArrayAsAddr#" GenPrimOp MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsFloat "writeWord8ArrayAsFloat#" GenPrimOp MutableByteArray# s -> Int# -> Float# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsDouble "writeWord8ArrayAsDouble#" GenPrimOp MutableByteArray# s -> Int# -> Double# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsStablePtr "writeWord8ArrayAsStablePtr#" GenPrimOp MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsInt16 "writeWord8ArrayAsInt16#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsInt32 "writeWord8ArrayAsInt32#" GenPrimOp MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsInt64 "writeWord8ArrayAsInt64#" GenPrimOp MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsInt "writeWord8ArrayAsInt#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsWord16 "writeWord8ArrayAsWord16#" GenPrimOp MutableByteArray# s -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsWord32 "writeWord8ArrayAsWord32#" GenPrimOp MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsWord64 "writeWord8ArrayAsWord64#" GenPrimOp MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteByteArrayOp_Word8AsWord "writeWord8ArrayAsWord#" GenPrimOp MutableByteArray# s -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop CompareByteArraysOp "compareByteArrays#" GenPrimOp ByteArray# -> Int# -> ByteArray# -> Int# -> Int# -> Int# @@ -1954,7 +1949,7 @@ primop CompareByteArraysOp "compareByteArrays#" GenPrimOp respectively, to be byte-wise lexicographically less than, to match, or be greater than the second range.} with - can_fail = True + effect = ThrowsImprecise primop CopyByteArrayOp "copyByteArray#" GenPrimOp ByteArray# -> Int# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s @@ -1966,9 +1961,9 @@ primop CopyByteArrayOp "copyByteArray#" GenPrimOp not be the same array in different states, but this is not checked either.} with - has_side_effects = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect code_size = { primOpCodeSizeForeignCall + 4} - can_fail = True primop CopyMutableByteArrayOp "copyMutableByteArray#" GenPrimOp MutableByteArray# s -> Int# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s @@ -1977,9 +1972,9 @@ primop CopyMutableByteArrayOp "copyMutableByteArray#" GenPrimOp allowed to overlap, although this is only possible when the same array is provided as both the source and the destination.} with - has_side_effects = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect code_size = { primOpCodeSizeForeignCall + 4 } - can_fail = True primop CopyByteArrayToAddrOp "copyByteArrayToAddr#" GenPrimOp ByteArray# -> Int# -> Addr# -> Int# -> State# s -> State# s @@ -1989,9 +1984,9 @@ primop CopyByteArrayToAddrOp "copyByteArrayToAddr#" GenPrimOp ByteArray\# (e.g. if the ByteArray\# were pinned), but this is not checked either.} with - has_side_effects = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect code_size = { primOpCodeSizeForeignCall + 4} - can_fail = True primop CopyMutableByteArrayToAddrOp "copyMutableByteArrayToAddr#" GenPrimOp MutableByteArray# s -> Int# -> Addr# -> Int# -> State# s -> State# s @@ -2001,9 +1996,9 @@ primop CopyMutableByteArrayToAddrOp "copyMutableByteArrayToAddr#" GenPrimOp point into the MutableByteArray\# (e.g. if the MutableByteArray\# were pinned), but this is not checked either.} with - has_side_effects = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect code_size = { primOpCodeSizeForeignCall + 4} - can_fail = True primop CopyAddrToByteArrayOp "copyAddrToByteArray#" GenPrimOp Addr# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s @@ -2013,18 +2008,18 @@ primop CopyAddrToByteArrayOp "copyAddrToByteArray#" GenPrimOp point into the MutableByteArray\# (e.g. if the MutableByteArray\# were pinned), but this is not checked either.} with - has_side_effects = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect code_size = { primOpCodeSizeForeignCall + 4} - can_fail = True primop SetByteArrayOp "setByteArray#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> State# s {{\tt setByteArray# ba off len c} sets the byte range {\tt [off, off+len]} of the {\tt MutableByteArray#} to the byte {\tt c}.} with - has_side_effects = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect code_size = { primOpCodeSizeForeignCall + 4 } - can_fail = True -- Atomic operations @@ -2032,15 +2027,15 @@ primop AtomicReadByteArrayOp_Int "atomicReadIntArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #) {Given an array and an offset in machine words, read an element. The index is assumed to be in bounds. Implies a full memory barrier.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop AtomicWriteByteArrayOp_Int "atomicWriteIntArray#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> State# s {Given an array and an offset in machine words, write an element. The index is assumed to be in bounds. Implies a full memory barrier.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop CasByteArrayOp_Int "casIntArray#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> (# State# s, Int# #) @@ -2049,56 +2044,56 @@ primop CasByteArrayOp_Int "casIntArray#" GenPrimOp value if the current value matches the provided old value. Returns the value of the element before the operation. Implies a full memory barrier.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop FetchAddByteArrayOp_Int "fetchAddIntArray#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #) {Given an array, and offset in machine words, and a value to add, atomically add the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop FetchSubByteArrayOp_Int "fetchSubIntArray#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #) {Given an array, and offset in machine words, and a value to subtract, atomically subtract the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop FetchAndByteArrayOp_Int "fetchAndIntArray#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #) {Given an array, and offset in machine words, and a value to AND, atomically AND the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop FetchNandByteArrayOp_Int "fetchNandIntArray#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #) {Given an array, and offset in machine words, and a value to NAND, atomically NAND the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop FetchOrByteArrayOp_Int "fetchOrIntArray#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #) {Given an array, and offset in machine words, and a value to OR, atomically OR the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop FetchXorByteArrayOp_Int "fetchXorIntArray#" GenPrimOp MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #) {Given an array, and offset in machine words, and a value to XOR, atomically XOR the value to the element. Returns the value of the element before the operation. Implies a full memory barrier.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect ------------------------------------------------------------------------ @@ -2121,7 +2116,8 @@ primop NewArrayArrayOp "newArrayArray#" GenPrimOp newly created array.} with out_of_line = True - has_side_effects = True + -- effect = NoEffect -- #3207 + effect = WriteEffect primop SameMutableArrayArrayOp "sameMutableArrayArray#" GenPrimOp MutableArrayArray# s -> MutableArrayArray# s -> Int# @@ -2130,7 +2126,7 @@ primop UnsafeFreezeArrayArrayOp "unsafeFreezeArrayArray#" GenPrimOp MutableArrayArray# s -> State# s -> (# State# s, ArrayArray# #) {Make a mutable array of arrays immutable, without copying.} with - has_side_effects = True + effect = WriteEffect primop SizeofArrayArrayOp "sizeofArrayArray#" GenPrimOp ArrayArray# -> Int# @@ -2142,51 +2138,51 @@ primop SizeofMutableArrayArrayOp "sizeofMutableArrayArray#" GenPrimOp primop IndexArrayArrayOp_ByteArray "indexByteArrayArray#" GenPrimOp ArrayArray# -> Int# -> ByteArray# - with can_fail = True + with effect = ThrowsImprecise primop IndexArrayArrayOp_ArrayArray "indexArrayArrayArray#" GenPrimOp ArrayArray# -> Int# -> ArrayArray# - with can_fail = True + with effect = ThrowsImprecise primop ReadArrayArrayOp_ByteArray "readByteArrayArray#" GenPrimOp MutableArrayArray# s -> Int# -> State# s -> (# State# s, ByteArray# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadArrayArrayOp_MutableByteArray "readMutableByteArrayArray#" GenPrimOp MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableByteArray# s #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadArrayArrayOp_ArrayArray "readArrayArrayArray#" GenPrimOp MutableArrayArray# s -> Int# -> State# s -> (# State# s, ArrayArray# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadArrayArrayOp_MutableArrayArray "readMutableArrayArrayArray#" GenPrimOp MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableArrayArray# s #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteArrayArrayOp_ByteArray "writeByteArrayArray#" GenPrimOp MutableArrayArray# s -> Int# -> ByteArray# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteArrayArrayOp_MutableByteArray "writeMutableByteArrayArray#" GenPrimOp MutableArrayArray# s -> Int# -> MutableByteArray# s -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteArrayArrayOp_ArrayArray "writeArrayArrayArray#" GenPrimOp MutableArrayArray# s -> Int# -> ArrayArray# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteArrayArrayOp_MutableArrayArray "writeMutableArrayArrayArray#" GenPrimOp MutableArrayArray# s -> Int# -> MutableArrayArray# s -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop CopyArrayArrayOp "copyArrayArray#" GenPrimOp ArrayArray# -> Int# -> MutableArrayArray# s -> Int# -> Int# -> State# s -> State# s @@ -2194,9 +2190,9 @@ primop CopyArrayArrayOp "copyArrayArray#" GenPrimOp Both arrays must fully contain the specified ranges, but this is not checked. The two arrays must not be the same array in different states, but this is not checked either.} with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop CopyMutableArrayArrayOp "copyMutableArrayArray#" GenPrimOp MutableArrayArray# s -> Int# -> MutableArrayArray# s -> Int# -> Int# -> State# s -> State# s @@ -2207,9 +2203,9 @@ primop CopyMutableArrayArrayOp "copyMutableArrayArray#" GenPrimOp array is provided as both the source and the destination. } with - out_of_line = True - has_side_effects = True - can_fail = True + out_of_line = True + -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect ------------------------------------------------------------------------ section "Addr#" @@ -2248,230 +2244,230 @@ primop AddrLeOp "leAddr#" Compare Addr# -> Addr# -> Int# primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp Addr# -> Int# -> Char# {Reads 8-bit character; offset in bytes.} - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_WideChar "indexWideCharOffAddr#" GenPrimOp Addr# -> Int# -> Char# {Reads 31-bit character; offset in 4-byte words.} - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp Addr# -> Int# -> Int# - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp Addr# -> Int# -> Word# - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp Addr# -> Int# -> Addr# - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp Addr# -> Int# -> Float# - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp Addr# -> Int# -> Double# - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp Addr# -> Int# -> StablePtr# a - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp Addr# -> Int# -> Int# - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp Addr# -> Int# -> Int# - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp Addr# -> Int# -> INT32 - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp Addr# -> Int# -> INT64 - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp Addr# -> Int# -> Word# - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp Addr# -> Int# -> Word# - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp Addr# -> Int# -> WORD32 - with can_fail = True + with effect = ThrowsImprecise primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp Addr# -> Int# -> WORD64 - with can_fail = True + with effect = ThrowsImprecise primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, Char# #) {Reads 8-bit character; offset in bytes.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, Char# #) {Reads 31-bit character; offset in 4-byte words.} - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, Int# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, Word# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, Addr# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, Float# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, Double# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, Int# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, Int# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, INT32 #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, INT64 #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, Word# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, Word# #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, WORD32 #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, WORD64 #) - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp Addr# -> Int# -> Char# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_WideChar "writeWideCharOffAddr#" GenPrimOp Addr# -> Int# -> Char# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp Addr# -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp Addr# -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp Addr# -> Int# -> Addr# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp Addr# -> Int# -> Float# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp Addr# -> Int# -> Double# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp Addr# -> Int# -> StablePtr# a -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp Addr# -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp Addr# -> Int# -> Int# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp Addr# -> Int# -> INT32 -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp Addr# -> Int# -> INT64 -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp Addr# -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp Addr# -> Int# -> Word# -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp Addr# -> Int# -> WORD32 -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp Addr# -> Int# -> WORD64 -> State# s -> State# s - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect ------------------------------------------------------------------------ section "Mutable variables" @@ -2486,35 +2482,21 @@ primop NewMutVarOp "newMutVar#" GenPrimOp {Create {\tt MutVar\#} with specified initial value in specified state thread.} with out_of_line = True - has_side_effects = True - --- Note [Why MutVar# ops can't fail] --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- --- We don't label readMutVar# or writeMutVar# as can_fail. --- This may seem a bit peculiar, because they surely *could* --- fail spectacularly if passed a pointer to unallocated memory. --- But MutVar#s are always correct by construction; we never --- test if a pointer is valid before using it with these operations. --- So we never have to worry about floating the pointer reference --- outside a validity test. At the moment, has_side_effects blocks --- up the relevant optimizations anyway, but we hope to draw finer --- distinctions soon, which should improve matters for readMutVar# --- at least. + -- effect = NoEffect -- #3207 + effect = WriteEffect primop ReadMutVarOp "readMutVar#" GenPrimOp MutVar# s a -> State# s -> (# State# s, a #) {Read contents of {\tt MutVar\#}. Result is not yet evaluated.} with - -- See Note [Why MutVar# ops can't fail] - has_side_effects = True + -- effect = NoEffect -- #3207 + effect = WriteEffect primop WriteMutVarOp "writeMutVar#" GenPrimOp MutVar# s a -> a -> State# s -> State# s {Write contents of {\tt MutVar\#}.} with - -- See Note [Why MutVar# ops can't fail] - has_side_effects = True + effect = WriteEffect code_size = { primOpCodeSizeForeignCall } -- for the write barrier primop SameMutVarOp "sameMutVar#" GenPrimOp @@ -2543,8 +2525,7 @@ primop AtomicModifyMutVar2Op "atomicModifyMutVar2#" GenPrimOp but we don't know about pairs here. } with out_of_line = True - has_side_effects = True - can_fail = True + effect = WriteEffect primop AtomicModifyMutVar_Op "atomicModifyMutVar_#" GenPrimOp MutVar# s a -> (a -> a) -> State# s -> (# State# s, a, a #) @@ -2553,14 +2534,13 @@ primop AtomicModifyMutVar_Op "atomicModifyMutVar_#" GenPrimOp previous contents. } with out_of_line = True - has_side_effects = True - can_fail = True + effect = WriteEffect primop CasMutVarOp "casMutVar#" GenPrimOp MutVar# s a -> a -> a -> State# s -> (# State# s, Int#, a #) with out_of_line = True - has_side_effects = True + effect = WriteEffect ------------------------------------------------------------------------ section "Exceptions" @@ -2590,7 +2570,7 @@ primop CatchOp "catch#" GenPrimOp , topDmd] topDiv } -- See Note [Strictness for mask/unmask/catch] out_of_line = True - has_side_effects = True + effect = WriteEffect primop RaiseOp "raise#" GenPrimOp b -> o @@ -2605,7 +2585,7 @@ primop RaiseOp "raise#" GenPrimOp -- See Note [PrimOp can_fail and has_side_effects] in PrimOp.hs. strictness = { \ _arity -> mkClosedStrictSig [topDmd] botDiv } out_of_line = True - can_fail = True + effect = ThrowsImprecise -- Note [Arithmetic exception primops] -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2628,7 +2608,7 @@ primop RaiseDivZeroOp "raiseDivZero#" GenPrimOp with strictness = { \ _arity -> mkClosedStrictSig [topDmd] botDiv } out_of_line = True - has_side_effects = True + effect = ThrowsImprecise primop RaiseUnderflowOp "raiseUnderflow#" GenPrimOp Void# -> o @@ -2638,7 +2618,7 @@ primop RaiseUnderflowOp "raiseUnderflow#" GenPrimOp with strictness = { \ _arity -> mkClosedStrictSig [topDmd] botDiv } out_of_line = True - has_side_effects = True + effect = ThrowsImprecise primop RaiseOverflowOp "raiseOverflow#" GenPrimOp Void# -> o @@ -2648,8 +2628,11 @@ primop RaiseOverflowOp "raiseOverflow#" GenPrimOp with strictness = { \ _arity -> mkClosedStrictSig [topDmd] botDiv } out_of_line = True - has_side_effects = True + effect = ThrowsImprecise +-- See Note [Precise vs. imprecise exceptions] in GHC.Types.Demand. +-- This is the only way to throw a precise exception, hence a primop separate +-- from raise# with a ThrowsPrecise effect. primop RaiseIOOp "raiseIO#" GenPrimOp a -> State# RealWorld -> (# State# RealWorld, b #) with @@ -2657,7 +2640,7 @@ primop RaiseIOOp "raiseIO#" GenPrimOp -- for why this is the *only* primop that has 'exnDiv' strictness = { \ _arity -> mkClosedStrictSig [topDmd, topDmd] exnDiv } out_of_line = True - has_side_effects = True + effect = ThrowsPrecise primop MaskAsyncExceptionsOp "maskAsyncExceptions#" GenPrimOp (State# RealWorld -> (# State# RealWorld, a #)) @@ -2666,7 +2649,7 @@ primop MaskAsyncExceptionsOp "maskAsyncExceptions#" GenPrimOp strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topDiv } -- See Note [Strictness for mask/unmask/catch] out_of_line = True - has_side_effects = True + effect = WriteEffect primop MaskUninterruptibleOp "maskUninterruptible#" GenPrimOp (State# RealWorld -> (# State# RealWorld, a #)) @@ -2674,7 +2657,7 @@ primop MaskUninterruptibleOp "maskUninterruptible#" GenPrimOp with strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topDiv } out_of_line = True - has_side_effects = True + effect = WriteEffect primop UnmaskAsyncExceptionsOp "unmaskAsyncExceptions#" GenPrimOp (State# RealWorld -> (# State# RealWorld, a #)) @@ -2683,13 +2666,13 @@ primop UnmaskAsyncExceptionsOp "unmaskAsyncExceptions#" GenPrimOp strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topDiv } -- See Note [Strictness for mask/unmask/catch] out_of_line = True - has_side_effects = True + effect = WriteEffect primop MaskStatus "getMaskingState#" GenPrimOp State# RealWorld -> (# State# RealWorld, Int# #) with out_of_line = True - has_side_effects = True + effect = WriteEffect ------------------------------------------------------------------------ section "STM-accessible Mutable Variables" @@ -2704,7 +2687,7 @@ primop AtomicallyOp "atomically#" GenPrimOp strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topDiv } -- See Note [Strictness for mask/unmask/catch] out_of_line = True - has_side_effects = True + effect = WriteEffect -- NB: retry#'s strictness information specifies it to diverge. -- This lets the compiler perform some extra simplifications, since retry# @@ -2721,7 +2704,7 @@ primop RetryOp "retry#" GenPrimOp with strictness = { \ _arity -> mkClosedStrictSig [topDmd] botDiv } out_of_line = True - has_side_effects = True + effect = WriteEffect primop CatchRetryOp "catchRetry#" GenPrimOp (State# RealWorld -> (# State# RealWorld, a #) ) @@ -2733,7 +2716,7 @@ primop CatchRetryOp "catchRetry#" GenPrimOp , topDmd ] topDiv } -- See Note [Strictness for mask/unmask/catch] out_of_line = True - has_side_effects = True + effect = WriteEffect primop CatchSTMOp "catchSTM#" GenPrimOp (State# RealWorld -> (# State# RealWorld, a #) ) @@ -2745,31 +2728,34 @@ primop CatchSTMOp "catchSTM#" GenPrimOp , topDmd ] topDiv } -- See Note [Strictness for mask/unmask/catch] out_of_line = True - has_side_effects = True + effect = WriteEffect primop NewTVarOp "newTVar#" GenPrimOp a -> State# s -> (# State# s, TVar# s a #) {Create a new {\tt TVar\#} holding a specified initial value.} with - out_of_line = True - has_side_effects = True + out_of_line = True + -- effect = NoEffect -- #3207 + effect = WriteEffect primop ReadTVarOp "readTVar#" GenPrimOp TVar# s a -> State# s -> (# State# s, a #) {Read contents of {\tt TVar\#}. Result is not yet evaluated.} with - out_of_line = True - has_side_effects = True + out_of_line = True + -- effect = NoEffect -- #3207 + effect = WriteEffect primop ReadTVarIOOp "readTVarIO#" GenPrimOp TVar# s a -> State# s -> (# State# s, a #) {Read contents of {\tt TVar\#} outside an STM transaction} with - out_of_line = True - has_side_effects = True + out_of_line = True + -- effect = NoEffect -- #3207 + effect = WriteEffect primop WriteTVarOp "writeTVar#" GenPrimOp TVar# s a @@ -2778,7 +2764,7 @@ primop WriteTVarOp "writeTVar#" GenPrimOp {Write contents of {\tt TVar\#}.} with out_of_line = True - has_side_effects = True + effect = WriteEffect primop SameTVarOp "sameTVar#" GenPrimOp TVar# s a -> TVar# s a -> Int# @@ -2799,39 +2785,40 @@ primop NewMVarOp "newMVar#" GenPrimOp {Create new {\tt MVar\#}; initially empty.} with out_of_line = True - has_side_effects = True + -- effect = NoEffect -- #3207 + effect = WriteEffect primop TakeMVarOp "takeMVar#" GenPrimOp MVar# s a -> State# s -> (# State# s, a #) {If {\tt MVar\#} is empty, block until it becomes full. Then remove and return its contents, and set it empty.} with - out_of_line = True - has_side_effects = True + out_of_line = True + effect = WriteEffect -- because it may block! primop TryTakeMVarOp "tryTakeMVar#" GenPrimOp MVar# s a -> State# s -> (# State# s, Int#, a #) {If {\tt MVar\#} is empty, immediately return with integer 0 and value undefined. Otherwise, return with integer 1 and contents of {\tt MVar\#}, and set {\tt MVar\#} empty.} with - out_of_line = True - has_side_effects = True + out_of_line = True + effect = WriteEffect primop PutMVarOp "putMVar#" GenPrimOp MVar# s a -> a -> State# s -> State# s {If {\tt MVar\#} is full, block until it becomes empty. Then store value arg as its new contents.} with - out_of_line = True - has_side_effects = True + out_of_line = True + effect = WriteEffect primop TryPutMVarOp "tryPutMVar#" GenPrimOp MVar# s a -> a -> State# s -> (# State# s, Int# #) {If {\tt MVar\#} is full, immediately return with integer 0. Otherwise, store value arg as {\tt MVar\#}'s new contents, and return with integer 1.} with - out_of_line = True - has_side_effects = True + out_of_line = True + effect = WriteEffect primop ReadMVarOp "readMVar#" GenPrimOp MVar# s a -> State# s -> (# State# s, a #) @@ -2839,8 +2826,8 @@ primop ReadMVarOp "readMVar#" GenPrimOp Then read its contents without modifying the MVar, without possibility of intervention from other threads.} with - out_of_line = True - has_side_effects = True + out_of_line = True + effect = WriteEffect -- because it may block! primop TryReadMVarOp "tryReadMVar#" GenPrimOp MVar# s a -> State# s -> (# State# s, Int#, a #) @@ -2848,7 +2835,7 @@ primop TryReadMVarOp "tryReadMVar#" GenPrimOp Otherwise, return with integer 1 and contents of {\tt MVar\#}.} with out_of_line = True - has_side_effects = True + effect = WriteEffect primop SameMVarOp "sameMVar#" GenPrimOp MVar# s a -> MVar# s a -> Int# @@ -2858,7 +2845,8 @@ primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp {Return 1 if {\tt MVar\#} is empty; 0 otherwise.} with out_of_line = True - has_side_effects = True + -- effect = NoEffect -- #3207 + effect = WriteEffect ------------------------------------------------------------------------ section "Delay/wait operations" @@ -2868,22 +2856,22 @@ primop DelayOp "delay#" GenPrimOp Int# -> State# s -> State# s {Sleep specified number of microseconds.} with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop WaitReadOp "waitRead#" GenPrimOp Int# -> State# s -> State# s {Block until input is available on specified file descriptor.} with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop WaitWriteOp "waitWrite#" GenPrimOp Int# -> State# s -> State# s {Block until output is possible on specified file descriptor.} with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True ------------------------------------------------------------------------ section "Concurrency primitives" @@ -2909,55 +2897,58 @@ primtype ThreadId# primop ForkOp "fork#" GenPrimOp a -> State# RealWorld -> (# State# RealWorld, ThreadId# #) with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop ForkOnOp "forkOn#" GenPrimOp Int# -> a -> State# RealWorld -> (# State# RealWorld, ThreadId# #) with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop KillThreadOp "killThread#" GenPrimOp ThreadId# -> a -> State# RealWorld -> State# RealWorld with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop YieldOp "yield#" GenPrimOp State# RealWorld -> State# RealWorld with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop MyThreadIdOp "myThreadId#" GenPrimOp State# RealWorld -> (# State# RealWorld, ThreadId# #) with - has_side_effects = True + -- effect = NoEffect -- #3207 + effect = WriteEffect primop LabelThreadOp "labelThread#" GenPrimOp ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop IsCurrentThreadBoundOp "isCurrentThreadBound#" GenPrimOp State# RealWorld -> (# State# RealWorld, Int# #) with out_of_line = True - has_side_effects = True + -- effect = NoEffect -- #3207 + effect = WriteEffect primop NoDuplicateOp "noDuplicate#" GenPrimOp State# s -> State# s with out_of_line = True - has_side_effects = True + effect = WriteEffect -- See Note [Classification by PrimOpEffect] in PrimOp primop ThreadStatusOp "threadStatus#" GenPrimOp ThreadId# -> State# RealWorld -> (# State# RealWorld, Int#, Int#, Int# #) with out_of_line = True - has_side_effects = True + -- effect = NoEffect -- #3207 + effect = WriteEffect ------------------------------------------------------------------------ section "Weak pointers" @@ -2976,14 +2967,14 @@ primop MkWeakOp "mkWeak#" GenPrimOp the type of {\tt k} must be represented by a pointer (i.e. of kind {\tt TYPE 'LiftedRep} or {\tt TYPE 'UnliftedRep}). } with - has_side_effects = True - out_of_line = True + effect = WriteEffect -- better be safe + out_of_line = True primop MkWeakNoFinalizerOp "mkWeakNoFinalizer#" GenPrimOp o -> b -> State# RealWorld -> (# State# RealWorld, Weak# b #) with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop AddCFinalizerToWeakOp "addCFinalizerToWeak#" GenPrimOp Addr# -> Addr# -> Int# -> Addr# -> Weak# b @@ -2995,14 +2986,14 @@ primop AddCFinalizerToWeakOp "addCFinalizerToWeak#" GenPrimOp {\tt eptr} and {\tt ptr}. {\tt addCFinalizerToWeak#} returns 1 on success, or 0 if {\tt w} is already dead. } with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop DeRefWeakOp "deRefWeak#" GenPrimOp Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #) with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop FinalizeWeakOp "finalizeWeak#" GenPrimOp Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, @@ -3013,14 +3004,14 @@ primop FinalizeWeakOp "finalizeWeak#" GenPrimOp action. An {\tt Int#} of {\tt 1} indicates that the finalizer is valid. The return value {\tt b} from the finalizer should be ignored. } with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop TouchOp "touch#" GenPrimOp o -> State# RealWorld -> State# RealWorld with code_size = { 0 } - has_side_effects = True + effect = WriteEffect ------------------------------------------------------------------------ section "Stable pointers and names" @@ -3033,25 +3024,25 @@ primtype StableName# a primop MakeStablePtrOp "makeStablePtr#" GenPrimOp a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #) with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #) with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop EqStablePtrOp "eqStablePtr#" GenPrimOp StablePtr# a -> StablePtr# a -> Int# with - has_side_effects = True + effect = WriteEffect primop MakeStableNameOp "makeStableName#" GenPrimOp a -> State# RealWorld -> (# State# RealWorld, StableName# a #) with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop EqStableNameOp "eqStableName#" GenPrimOp StableName# a -> StableName# b -> Int# @@ -3085,8 +3076,9 @@ primop CompactNewOp "compactNew#" GenPrimOp The capacity is rounded up to a multiple of the allocator block size and is capped to one mega block. } with - has_side_effects = True - out_of_line = True + -- effect = NoEffect -- #3207 + effect = WriteEffect + out_of_line = True primop CompactResizeOp "compactResize#" GenPrimOp Compact# -> Word# -> State# RealWorld -> @@ -3095,27 +3087,33 @@ primop CompactResizeOp "compactResize#" GenPrimOp determines the capacity of each compact block in the CNF. It does not retroactively affect existing compact blocks in the CNF. } with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop CompactContainsOp "compactContains#" GenPrimOp Compact# -> a -> State# RealWorld -> (# State# RealWorld, Int# #) { Returns 1\# if the object is contained in the CNF, 0\# otherwise. } with - out_of_line = True + -- effect = NoEffect -- #3207 + effect = WriteEffect + out_of_line = True primop CompactContainsAnyOp "compactContainsAny#" GenPrimOp a -> State# RealWorld -> (# State# RealWorld, Int# #) { Returns 1\# if the object is in any CNF at all, 0\# otherwise. } with - out_of_line = True + -- effect = NoEffect -- #3207 + effect = WriteEffect + out_of_line = True primop CompactGetFirstBlockOp "compactGetFirstBlock#" GenPrimOp Compact# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #) { Returns the address and the utilized size (in bytes) of the first compact block of a CNF.} with - out_of_line = True + -- effect = NoEffect -- #3207 + effect = WriteEffect + out_of_line = True primop CompactGetNextBlockOp "compactGetNextBlock#" GenPrimOp Compact# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #) @@ -3123,7 +3121,9 @@ primop CompactGetNextBlockOp "compactGetNextBlock#" GenPrimOp next compact block and its utilized size, or {\tt nullAddr\#} if the argument was the last compact block in the CNF. } with - out_of_line = True + -- effect = NoEffect -- #3207 + effect = WriteEffect + out_of_line = True primop CompactAllocateBlockOp "compactAllocateBlock#" GenPrimOp Word# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr# #) @@ -3137,8 +3137,8 @@ primop CompactAllocateBlockOp "compactAllocateBlock#" GenPrimOp so that the address does not escape or memory will be leaked. } with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop CompactFixupPointersOp "compactFixupPointers#" GenPrimOp Addr# -> Addr# -> State# RealWorld -> (# State# RealWorld, Compact#, Addr# #) @@ -3150,8 +3150,8 @@ primop CompactFixupPointersOp "compactFixupPointers#" GenPrimOp a serialized CNF. It returns the new CNF and the new adjusted root address. } with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop CompactAdd "compactAdd#" GenPrimOp Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #) @@ -3163,24 +3163,25 @@ primop CompactAdd "compactAdd#" GenPrimOp enforce any mutual exclusion; the caller is expected to arrange this. } with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop CompactAddWithSharing "compactAddWithSharing#" GenPrimOp Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #) { Like {\texttt compactAdd\#}, but retains sharing and cycles during compaction. } with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop CompactSize "compactSize#" GenPrimOp Compact# -> State# RealWorld -> (# State# RealWorld, Word# #) { Return the total capacity (in bytes) of all the compact blocks in the CNF. } with - has_side_effects = True - out_of_line = True + -- effect = NoEffect -- #3207 + effect = WriteEffect + out_of_line = True ------------------------------------------------------------------------ section "Unsafe pointer equality" @@ -3191,7 +3192,7 @@ primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp a -> a -> Int# { Returns {\texttt 1\#} if the given pointers are equal and {\texttt 0\#} otherwise. } with - can_fail = True -- See Note [reallyUnsafePtrEquality#] + effect = ThrowsImprecise -- See Note [reallyUnsafePtrEquality#] -- Note [reallyUnsafePtrEquality#] @@ -3232,13 +3233,14 @@ primop ParOp "par#" GenPrimOp with -- Note that Par is lazy to avoid that the sparked thing -- gets evaluated strictly, which it should *not* be - has_side_effects = True + effect = WriteEffect code_size = { primOpCodeSizeForeignCall } deprecated_msg = { Use 'spark#' instead } primop SparkOp "spark#" GenPrimOp a -> State# s -> (# State# s, a #) - with has_side_effects = True + with + effect = WriteEffect code_size = { primOpCodeSizeForeignCall } primop SeqOp "seq#" GenPrimOp @@ -3248,14 +3250,16 @@ primop SeqOp "seq#" GenPrimOp primop GetSparkOp "getSpark#" GenPrimOp State# s -> (# State# s, Int#, a #) with - has_side_effects = True + -- effect = NoEffect -- #3207 + effect = WriteEffect out_of_line = True primop NumSparks "numSparks#" GenPrimOp State# s -> (# State# s, Int# #) { Returns the number of sparks in the local spark pool. } with - has_side_effects = True + -- effect = NoEffect -- #3207 + effect = WriteEffect out_of_line = True ------------------------------------------------------------------------ @@ -3320,8 +3324,8 @@ primop NewBCOOp "newBCO#" GenPrimOp encoded in {\tt instrs}, and a static reference table usage bitmap given by {\tt bitmap}. } with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop UnpackClosureOp "unpackClosure#" GenPrimOp a -> (# Addr#, ByteArray#, Array# b #) @@ -3437,7 +3441,7 @@ pseudoop "unsafeCoerce#" to, use {\tt Any}, which is not an algebraic data type. } - with can_fail = True + with effect = ThrowsImprecise -- NB. It is tempting to think that casting a value to a type that it doesn't have is safe -- as long as you don't "do anything" with the value in its cast form, such as seq on it. This @@ -3454,8 +3458,8 @@ primop TraceEventOp "traceEvent#" GenPrimOp argument. The event will be emitted either to the {\tt .eventlog} file, or to stderr, depending on the runtime RTS flags. } with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop TraceEventBinaryOp "traceBinaryEvent#" GenPrimOp Addr# -> Int# -> State# s -> State# s @@ -3464,8 +3468,8 @@ primop TraceEventBinaryOp "traceBinaryEvent#" GenPrimOp the the given length passed as the second argument. The event will be emitted to the {\tt .eventlog} file. } with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop TraceMarkerOp "traceMarker#" GenPrimOp Addr# -> State# s -> State# s @@ -3474,15 +3478,15 @@ primop TraceMarkerOp "traceMarker#" GenPrimOp argument. The event will be emitted either to the {\tt .eventlog} file, or to stderr, depending on the runtime RTS flags. } with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True primop SetThreadAllocationCounter "setThreadAllocationCounter#" GenPrimOp INT64 -> State# RealWorld -> State# RealWorld { Sets the allocation counter for the current thread to the given value. } with - has_side_effects = True - out_of_line = True + effect = WriteEffect + out_of_line = True ------------------------------------------------------------------------ section "Safe coercions" @@ -3565,7 +3569,7 @@ primop VecUnpackOp "unpack#" GenPrimOp primop VecInsertOp "insert#" GenPrimOp VECTOR -> SCALAR -> Int# -> VECTOR { Insert a scalar at the given position in a vector. } - with can_fail = True + with effect = ThrowsImprecise llvm_only = True vector = ALL_VECTOR_TYPES @@ -3592,21 +3596,21 @@ primop VecMulOp "times#" Dyadic primop VecDivOp "divide#" Dyadic VECTOR -> VECTOR -> VECTOR { Divide two vectors element-wise. } - with can_fail = True + with effect = ThrowsImprecise llvm_only = True vector = FLOAT_VECTOR_TYPES primop VecQuotOp "quot#" Dyadic VECTOR -> VECTOR -> VECTOR { Rounds towards zero element-wise. } - with can_fail = True + with effect = ThrowsImprecise llvm_only = True vector = INT_VECTOR_TYPES primop VecRemOp "rem#" Dyadic VECTOR -> VECTOR -> VECTOR { Satisfies \texttt{(quot\# x y) times\# y plus\# (rem\# x y) == x}. } - with can_fail = True + with effect = ThrowsImprecise llvm_only = True vector = INT_VECTOR_TYPES @@ -3619,46 +3623,44 @@ primop VecNegOp "negate#" Monadic primop VecIndexByteArrayOp "indexArray#" GenPrimOp ByteArray# -> Int# -> VECTOR { Read a vector from specified index of immutable array. } - with can_fail = True + with effect = ThrowsImprecise llvm_only = True vector = ALL_VECTOR_TYPES primop VecReadByteArrayOp "readArray#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, VECTOR #) { Read a vector from specified index of mutable array. } - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect llvm_only = True vector = ALL_VECTOR_TYPES primop VecWriteByteArrayOp "writeArray#" GenPrimOp MutableByteArray# s -> Int# -> VECTOR -> State# s -> State# s { Write a vector to specified index of mutable array. } - with has_side_effects = True - can_fail = True + with effect = WriteEffect llvm_only = True vector = ALL_VECTOR_TYPES primop VecIndexOffAddrOp "indexOffAddr#" GenPrimOp Addr# -> Int# -> VECTOR { Reads vector; offset in bytes. } - with can_fail = True + with effect = ThrowsImprecise llvm_only = True vector = ALL_VECTOR_TYPES primop VecReadOffAddrOp "readOffAddr#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, VECTOR #) { Reads vector; offset in bytes. } - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect llvm_only = True vector = ALL_VECTOR_TYPES primop VecWriteOffAddrOp "writeOffAddr#" GenPrimOp Addr# -> Int# -> VECTOR -> State# s -> State# s { Write vector; offset in bytes. } - with has_side_effects = True - can_fail = True + with effect = WriteEffect llvm_only = True vector = ALL_VECTOR_TYPES @@ -3666,46 +3668,44 @@ primop VecWriteOffAddrOp "writeOffAddr#" GenPrimOp primop VecIndexScalarByteArrayOp "indexArrayAs#" GenPrimOp ByteArray# -> Int# -> VECTOR { Read a vector from specified index of immutable array of scalars; offset is in scalar elements. } - with can_fail = True + with effect = ThrowsImprecise llvm_only = True vector = ALL_VECTOR_TYPES primop VecReadScalarByteArrayOp "readArrayAs#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> (# State# s, VECTOR #) { Read a vector from specified index of mutable array of scalars; offset is in scalar elements. } - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect llvm_only = True vector = ALL_VECTOR_TYPES primop VecWriteScalarByteArrayOp "writeArrayAs#" GenPrimOp MutableByteArray# s -> Int# -> VECTOR -> State# s -> State# s { Write a vector to specified index of mutable array of scalars; offset is in scalar elements. } - with has_side_effects = True - can_fail = True + with effect = WriteEffect llvm_only = True vector = ALL_VECTOR_TYPES primop VecIndexScalarOffAddrOp "indexOffAddrAs#" GenPrimOp Addr# -> Int# -> VECTOR { Reads vector; offset in scalar elements. } - with can_fail = True + with effect = ThrowsImprecise llvm_only = True vector = ALL_VECTOR_TYPES primop VecReadScalarOffAddrOp "readOffAddrAs#" GenPrimOp Addr# -> Int# -> State# s -> (# State# s, VECTOR #) { Reads vector; offset in scalar elements. } - with has_side_effects = True - can_fail = True + with -- effect = ThrowsImprecise -- #3207 + effect = WriteEffect llvm_only = True vector = ALL_VECTOR_TYPES primop VecWriteScalarOffAddrOp "writeOffAddrAs#" GenPrimOp Addr# -> Int# -> VECTOR -> State# s -> State# s { Write vector; offset in scalar elements. } - with has_side_effects = True - can_fail = True + with effect = WriteEffect llvm_only = True vector = ALL_VECTOR_TYPES @@ -3754,7 +3754,7 @@ section "Prefetch" It is important to note that while the prefetch operations will never change the answer to a pure computation, They CAN change the memory locations resident in a CPU cache and that may change the performance and timing characteristics - of an application. The prefetch operations are marked has_side_effects=True + of an application. The prefetch operations are marked effect = WriteEffect to reflect that these operations have side effects with respect to the runtime performance characteristics of the resulting code. Additionally, if the prefetchValue operations did not have this attribute, GHC does a float out transformation that @@ -3771,74 +3771,74 @@ section "Prefetch" --- primop PrefetchByteArrayOp3 "prefetchByteArray3#" GenPrimOp ByteArray# -> Int# -> State# s -> State# s - with has_side_effects = True + with effect = WriteEffect primop PrefetchMutableByteArrayOp3 "prefetchMutableByteArray3#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> State# s - with has_side_effects = True + with effect = WriteEffect primop PrefetchAddrOp3 "prefetchAddr3#" GenPrimOp Addr# -> Int# -> State# s -> State# s - with has_side_effects = True + with effect = WriteEffect primop PrefetchValueOp3 "prefetchValue3#" GenPrimOp a -> State# s -> State# s with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topDiv } - has_side_effects = True + effect = WriteEffect ---- primop PrefetchByteArrayOp2 "prefetchByteArray2#" GenPrimOp ByteArray# -> Int# -> State# s -> State# s - with has_side_effects = True + with effect = WriteEffect primop PrefetchMutableByteArrayOp2 "prefetchMutableByteArray2#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> State# s - with has_side_effects = True + with effect = WriteEffect primop PrefetchAddrOp2 "prefetchAddr2#" GenPrimOp Addr# -> Int# -> State# s -> State# s - with has_side_effects = True + with effect = WriteEffect primop PrefetchValueOp2 "prefetchValue2#" GenPrimOp a -> State# s -> State# s with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topDiv } - has_side_effects = True + effect = WriteEffect ---- primop PrefetchByteArrayOp1 "prefetchByteArray1#" GenPrimOp ByteArray# -> Int# -> State# s -> State# s - with has_side_effects = True + with effect = WriteEffect primop PrefetchMutableByteArrayOp1 "prefetchMutableByteArray1#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> State# s - with has_side_effects = True + with effect = WriteEffect primop PrefetchAddrOp1 "prefetchAddr1#" GenPrimOp Addr# -> Int# -> State# s -> State# s - with has_side_effects = True + with effect = WriteEffect primop PrefetchValueOp1 "prefetchValue1#" GenPrimOp a -> State# s -> State# s - with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topDiv } - has_side_effects = True + with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topDiv } + effect = WriteEffect ---- primop PrefetchByteArrayOp0 "prefetchByteArray0#" GenPrimOp ByteArray# -> Int# -> State# s -> State# s - with has_side_effects = True + with effect = WriteEffect primop PrefetchMutableByteArrayOp0 "prefetchMutableByteArray0#" GenPrimOp MutableByteArray# s -> Int# -> State# s -> State# s - with has_side_effects = True + with effect = WriteEffect primop PrefetchAddrOp0 "prefetchAddr0#" GenPrimOp Addr# -> Int# -> State# s -> State# s - with has_side_effects = True + with effect = WriteEffect primop PrefetchValueOp0 "prefetchValue0#" GenPrimOp a -> State# s -> State# s - with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topDiv } - has_side_effects = True + with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topDiv } + effect = WriteEffect ------------------------------------------------------------------------ --- --- diff --git a/compiler/ghc.mk b/compiler/ghc.mk index 6a2dadc820..ce75aee0c9 100644 --- a/compiler/ghc.mk +++ b/compiler/ghc.mk @@ -108,11 +108,10 @@ $(eval $(call compilerConfig,2)) PRIMOP_BITS_NAMES = primop-data-decl.hs-incl \ primop-tag.hs-incl \ primop-list.hs-incl \ - primop-has-side-effects.hs-incl \ + primop-effect.hs-incl \ primop-out-of-line.hs-incl \ primop-commutable.hs-incl \ primop-code-size.hs-incl \ - primop-can-fail.hs-incl \ primop-strictness.hs-incl \ primop-fixity.hs-incl \ primop-primop-info.hs-incl \ @@ -143,16 +142,14 @@ compiler/stage$1/build/primop-tag.hs-incl: compiler/stage$1/build/primops.txt $$ "$$(genprimopcode_INPLACE)" --primop-tag < $$< > $$@ compiler/stage$1/build/primop-list.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE) "$$(genprimopcode_INPLACE)" --primop-list < $$< > $$@ -compiler/stage$1/build/primop-has-side-effects.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE) - "$$(genprimopcode_INPLACE)" --has-side-effects < $$< > $$@ +compiler/stage$1/build/primop-effect.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE) + "$$(genprimopcode_INPLACE)" --effect < $$< > $$@ compiler/stage$1/build/primop-out-of-line.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE) "$$(genprimopcode_INPLACE)" --out-of-line < $$< > $$@ compiler/stage$1/build/primop-commutable.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE) "$$(genprimopcode_INPLACE)" --commutable < $$< > $$@ compiler/stage$1/build/primop-code-size.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE) "$$(genprimopcode_INPLACE)" --code-size < $$< > $$@ -compiler/stage$1/build/primop-can-fail.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE) - "$$(genprimopcode_INPLACE)" --can-fail < $$< > $$@ compiler/stage$1/build/primop-strictness.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE) "$$(genprimopcode_INPLACE)" --strictness < $$< > $$@ compiler/stage$1/build/primop-fixity.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE) diff --git a/distrib/hc-build b/distrib/hc-build index 13afaa7adb..ba1d3bdc0a 100644 --- a/distrib/hc-build +++ b/distrib/hc-build @@ -73,11 +73,10 @@ HappyCmd="$PWD/distrib/fake-happy" ./configure --with-ghc="$PWD/compiler/ghc-inp PRIMOP_BITS="primop-data-decl.hs-incl \ primop-tag.hs-incl \ primop-list.hs-incl \ - primop-has-side-effects.hs-incl \ + primop-effect.hs-incl \ primop-out-of-line.hs-incl \ primop-commutable.hs-incl \ primop-needs-wrapper.hs-incl \ - primop-can-fail.hs-incl \ primop-strictness.hs-incl \ primop-usage.hs-incl \ primop-primop-info.hs-incl" diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs index 689e0fdd3f..0841530b48 100644 --- a/hadrian/src/Rules/Generate.hs +++ b/hadrian/src/Rules/Generate.hs @@ -59,12 +59,11 @@ compilerDependencies = do , notStage0 ? isGmp ? return [gmpPath -/- "include/ghc-gmp.h"] , notStage0 ? return ((rtsPath -/-) <$> libffiHeaderFiles) , return $ fmap (ghcPath -/-) - [ "primop-can-fail.hs-incl" - , "primop-code-size.hs-incl" + [ "primop-code-size.hs-incl" , "primop-commutable.hs-incl" , "primop-data-decl.hs-incl" + , "primop-effect.hs-incl" , "primop-fixity.hs-incl" - , "primop-has-side-effects.hs-incl" , "primop-list.hs-incl" , "primop-out-of-line.hs-incl" , "primop-primop-info.hs-incl" diff --git a/hadrian/src/Settings/Builders/GenPrimopCode.hs b/hadrian/src/Settings/Builders/GenPrimopCode.hs index 2640ee14c7..e1b5130bc8 100644 --- a/hadrian/src/Settings/Builders/GenPrimopCode.hs +++ b/hadrian/src/Settings/Builders/GenPrimopCode.hs @@ -9,11 +9,10 @@ genPrimopCodeBuilderArgs = builder GenPrimopCode ? mconcat , output "//primop-data-decl.hs-incl" ? arg "--data-decl" , output "//primop-tag.hs-incl" ? arg "--primop-tag" , output "//primop-list.hs-incl" ? arg "--primop-list" - , output "//primop-has-side-effects.hs-incl" ? arg "--has-side-effects" + , output "//primop-effect.hs-incl" ? arg "--effect" , output "//primop-out-of-line.hs-incl" ? arg "--out-of-line" , output "//primop-commutable.hs-incl" ? arg "--commutable" , output "//primop-code-size.hs-incl" ? arg "--code-size" - , output "//primop-can-fail.hs-incl" ? arg "--can-fail" , output "//primop-strictness.hs-incl" ? arg "--strictness" , output "//primop-fixity.hs-incl" ? arg "--fixity" , output "//primop-primop-info.hs-incl" ? arg "--primop-primop-info" diff --git a/utils/genprimopcode/Main.hs b/utils/genprimopcode/Main.hs index 1bfddaaf1d..c3d213c1e4 100644 --- a/utils/genprimopcode/Main.hs +++ b/utils/genprimopcode/Main.hs @@ -124,10 +124,10 @@ main = getArgs >>= \args -> "--data-decl" -> putStr (gen_data_decl p_o_specs) - "--has-side-effects" + "--effect" -> putStr (gen_switch_from_attribs - "has_side_effects" - "primOpHasSideEffects" p_o_specs) + "effect" + "primOpEffect" p_o_specs) "--out-of-line" -> putStr (gen_switch_from_attribs @@ -144,11 +144,6 @@ main = getArgs >>= \args -> "code_size" "primOpCodeSize" p_o_specs) - "--can-fail" - -> putStr (gen_switch_from_attribs - "can_fail" - "primOpCanFail" p_o_specs) - "--strictness" -> putStr (gen_switch_from_attribs "strictness" @@ -779,6 +774,7 @@ gen_switch_from_attribs attrib_name fn_name (Info defaults entries) getAltRhs (OptionString _ s) = s getAltRhs (OptionVector _) = "True" getAltRhs (OptionFixity mf) = show mf + getAltRhs (OptionEffect eff) = show eff mkAlt po = case lookup_attrib attrib_name (opts po) of |