Skip to content

Commit

Permalink
⅄ trunk → share-3waydiff
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellwrosen committed Dec 3, 2024
2 parents 036793e + d0b3720 commit 0e76d93
Show file tree
Hide file tree
Showing 15 changed files with 581 additions and 329 deletions.
6 changes: 5 additions & 1 deletion unison-runtime/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ flags:
stackchecks:
manual: true
default: false
dumpcore:
manual: true
default: false

when:
- condition: flag(arraychecks)
cpp-options: -DARRAY_CHECK
- condition: flag(stackchecks)
cpp-options: -DSTACK_CHECK

- condition: flag(dumpcore)
ghc-options: -ddump-simpl -ddump-stg-final -ddump-to-file -dsuppress-coercions -dsuppress-idinfo -dsuppress-module-prefixes # -dsuppress-type-applications -dsuppress-type-signatures

library:
source-dirs: src
Expand Down
37 changes: 32 additions & 5 deletions unison-runtime/src/Unison/Runtime/ANF.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Unison.Runtime.ANF
pattern TApv,
pattern TCom,
pattern TCon,
pattern UFalse,
pattern UTrue,
pattern TKon,
pattern TReq,
pattern TPrm,
Expand Down Expand Up @@ -1290,10 +1292,14 @@ data POp
| INCI -- inc
| DECI -- dec
| LEQI -- <=
| LESI -- <
| EQLI -- ==
| NEQI -- !=
| TRNC -- truncate0
-- Nat
| ADDN -- +
| SUBN -- -
| DRPN -- drop
| MULN
| DIVN -- /
| MODN -- mod
Expand All @@ -1310,7 +1316,9 @@ data POp
| INCN -- inc
| DECN -- dec
| LEQN -- <=
| LESN -- <
| EQLN -- ==
| NEQN -- !=
-- Float
| ADDF -- +
| SUBF -- -
Expand All @@ -1319,7 +1327,9 @@ data POp
| MINF -- min
| MAXF -- max
| LEQF -- <=
| LESF -- <
| EQLF -- ==
| NEQF -- !=
| POWF -- pow
| EXPF -- exp
| SQRT -- sqrt
Expand Down Expand Up @@ -1394,6 +1404,8 @@ data POp
| -- Universal operations
EQLU -- ==
| CMPU -- compare
| LEQU -- <=
| LESU -- <
| EROR -- error
| -- Code
MISS -- isMissing
Expand All @@ -1414,6 +1426,17 @@ data POp
| TFRC -- try force
| SDBL -- sandbox link list
| SDBV -- sandbox check for Values
-- Refs
| REFN -- Ref.new
| REFR -- Ref.read
| REFW -- Ref.write
| RCAS -- Ref.cas
| RRFC -- Ref.readForCas
| TIKR -- Ref.Ticket.read
-- Bools
| NOTB -- not
| ANDB -- and
| IORB -- or
deriving (Show, Eq, Ord, Enum, Bounded)

type ANormal = ABTN.Term ANormalF
Expand Down Expand Up @@ -1733,9 +1756,13 @@ anfHandled body =
cc = case l of T {} -> BX; LM {} -> BX; LY {} -> BX; _ -> UN
p -> pure p

fls, tru :: (Var v) => ANormal v
fls = TCon Ty.booleanRef 0 []
tru = TCon Ty.booleanRef 1 []
pattern UFalse <- TCon ((== Ty.booleanRef) -> True) 0 []
where
UFalse = TCon Ty.booleanRef 0 []

pattern UTrue <- TCon ((== Ty.booleanRef) -> True) 1 []
where
UTrue = TCon Ty.booleanRef 1 []

-- Helper function for renaming a variable arising from a
-- let v = u
Expand Down Expand Up @@ -1873,7 +1900,7 @@ anfBlock (And' l r) = do
let tree =
TMatch vl . MatchDataCover Ty.booleanRef $
mapFromList
[ (0, ([], fls)),
[ (0, ([], UFalse)),
(1, ([], tmr))
]
pure (lctx, (Indirect () <> d, tree))
Expand All @@ -1883,7 +1910,7 @@ anfBlock (Or' l r) = do
let tree =
TMatch vl . MatchDataCover Ty.booleanRef $
mapFromList
[ (1, ([], tru)),
[ (1, ([], UTrue)),
(0, ([], tmr))
]
pure (lctx, (Indirect () <> d, tree))
Expand Down
19 changes: 19 additions & 0 deletions unison-runtime/src/Unison/Runtime/ANF/Serialize.hs
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,25 @@ pOpCode op = case op of
IORI -> 126
XORI -> 127
COMI -> 128
DRPN -> 129
TRNC -> 130
REFN -> 131
REFR -> 132
REFW -> 133
RCAS -> 134
RRFC -> 135
TIKR -> 136
LESI -> 137
NEQI -> 138
LESN -> 139
NEQN -> 140
LESF -> 141
NEQF -> 142
LEQU -> 143
LESU -> 144
NOTB -> 145
ANDB -> 146
IORB -> 147

pOpAssoc :: [(POp, Word16)]
pOpAssoc = map (\op -> (op, pOpCode op)) [minBound .. maxBound]
Expand Down
Loading

0 comments on commit 0e76d93

Please sign in to comment.