unison-runtime-0.0.0
Safe HaskellNone
LanguageHaskell2010

Unison.Runtime.Stack

Synopsis

Documentation

data K Source #

Instances

Instances details
Show K Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

showsPrec :: Int -> K -> ShowS #

show :: K -> String #

showList :: [K] -> ShowS #

Eq K Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

(==) :: K -> K -> Bool #

(/=) :: K -> K -> Bool #

data GClosure comb Source #

Constructors

GList !(Deque Val) 
GText !Text 
GEnum !PackedTag 
GData1 !PackedTag !Val 
GData2 !PackedTag !Val !Val 
GData5 !PackedTag !Val !Val !Val !Val !Val 
GData3 !PackedTag !Val !Val !Val 
GData4 !PackedTag !Val !Val !Val !Val 
GData6 !PackedTag !Val !Val !Val !Val !Val !Val 
GDataG !PackedTag !USeg !BSeg

seven or more fields

GBytes !Bytes 
GPAp 

Fields

GCaptured 

Fields

GRecord !RecordShape !RecordVals 
GForeign !Foreign 
GUnboxedTypeTag !UnboxedTypeTag

The type tag for the value in the corresponding unboxed stack slot.

We should consider adding separate constructors for common builtin type tags. GHC will optimize nullary constructors into singletons.

GAffine 

Fields

GBlackHole 

Instances

Instances details
Functor GClosure Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

fmap :: (a -> b) -> GClosure a -> GClosure b #

(<$) :: a -> GClosure b -> GClosure a #

Foldable GClosure Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

fold :: Monoid m => GClosure m -> m #

foldMap :: Monoid m => (a -> m) -> GClosure a -> m #

foldMap' :: Monoid m => (a -> m) -> GClosure a -> m #

foldr :: (a -> b -> b) -> b -> GClosure a -> b #

foldr' :: (a -> b -> b) -> b -> GClosure a -> b #

foldl :: (b -> a -> b) -> b -> GClosure a -> b #

foldl' :: (b -> a -> b) -> b -> GClosure a -> b #

foldr1 :: (a -> a -> a) -> GClosure a -> a #

foldl1 :: (a -> a -> a) -> GClosure a -> a #

toList :: GClosure a -> [a] #

null :: GClosure a -> Bool #

length :: GClosure a -> Int #

elem :: Eq a => a -> GClosure a -> Bool #

maximum :: Ord a => GClosure a -> a #

minimum :: Ord a => GClosure a -> a #

sum :: Num a => GClosure a -> a #

product :: Num a => GClosure a -> a #

Traversable GClosure Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

traverse :: Applicative f => (a -> f b) -> GClosure a -> f (GClosure b) #

sequenceA :: Applicative f => GClosure (f a) -> f (GClosure a) #

mapM :: Monad m => (a -> m b) -> GClosure a -> m (GClosure b) #

sequence :: Monad m => GClosure (m a) -> m (GClosure a) #

Show comb => Show (GClosure comb) Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

showsPrec :: Int -> GClosure comb -> ShowS #

show :: GClosure comb -> String #

showList :: [GClosure comb] -> ShowS #

newtype Closure Source #

Constructors

Closure 

Bundled Patterns

pattern DataC :: PackedTag -> SegList -> Closure 
pattern RecordC :: RecordShape -> RecordVals -> Closure 
pattern PApV :: CombIx -> RCombInfo Val -> SegList -> Closure 
pattern CapV :: K -> Int -> SegList -> Closure 
pattern PAp :: CombIx -> GCombInfo (RComb Val) -> Seg -> Closure 
pattern Enum :: PackedTag -> Closure 
pattern Data1 :: PackedTag -> Val -> Closure 
pattern Data2 :: PackedTag -> Val -> Val -> Closure 
pattern Data3 :: PackedTag -> Val -> Val -> Val -> Closure 
pattern Data4 :: PackedTag -> Val -> Val -> Val -> Val -> Closure 
pattern Data5 :: PackedTag -> Val -> Val -> Val -> Val -> Val -> Closure 
pattern Data6 :: PackedTag -> Val -> Val -> Val -> Val -> Val -> Val -> Closure 
pattern DataG :: PackedTag -> Seg -> Closure

A constructor with seven or more fields (fewer go to the fixed-arity constructors; formData and formDataSeg choose).

pattern RecordG :: RecordShape -> RecordVals -> Closure 
pattern Captured :: K -> Int -> Seg -> Closure 
pattern TextC :: Text -> Closure

A text: the runtime's one representation of a Text value.

pattern ListC :: Deque Val -> Closure

A list: the runtime's one representation of a List value.

pattern BytesC :: Bytes -> Closure

A bytes value: the runtime's one representation of a Bytes value.

pattern Foreign :: Foreign -> Closure 
pattern Affine :: EnumSet Word64 -> AEnv -> AffineRef -> Closure 
pattern BlackHole :: Closure 
pattern UnboxedTypeTag :: UnboxedTypeTag -> Closure 

Instances

Instances details
Show Closure Source # 
Instance details

Defined in Unison.Runtime.Stack

Eq Closure Source #

Constructors compare field by field in place: no list of the fields is built (this runs for every key of a replaced Map).

Instance details

Defined in Unison.Runtime.Stack

Methods

(==) :: Closure -> Closure -> Bool #

(/=) :: Closure -> Closure -> Bool #

ForeignConvention Closure Source # 
Instance details

Defined in Unison.Runtime.Foreign.Function

data Failure a Source #

Constructors

Failure Reference Text a 

Instances

Instances details
ForeignConvention a => ForeignConvention (Failure a) Source # 
Instance details

Defined in Unison.Runtime.Foreign.Function

data Foreign Source #

Instances

Instances details
Show Foreign Source # 
Instance details

Defined in Unison.Runtime.Stack

Eq Foreign Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

(==) :: Foreign -> Foreign -> Bool #

(/=) :: Foreign -> Foreign -> Bool #

Ord Foreign Source # 
Instance details

Defined in Unison.Runtime.Stack

ForeignConvention Foreign Source # 
Instance details

Defined in Unison.Runtime.Foreign.Function

class BuiltinForeign f where Source #

The closure holding a Haskell value: Foreign (Wrap... x) for most, a TextC or ListC for a text or a list.

Instances

Instances details
BuiltinForeign ByteArray Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign TimeSpec Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign SignedCertificate Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign PrivKey Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign ThreadId Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign Handle Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign Socket Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign ClientSockAddr Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign ListenSocket Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign UDPSocket Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign ProcessHandle Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign ClientParams Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign ServerParams Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign Reference Source #

Note: References are assumed to be type links

Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign Referent Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign DLL Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign CDynFunc Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign FFSpec Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign FFType Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign Signal Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign Subscription Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign HashAlgorithm Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign Tls Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign Text Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign CPattern Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign CharPattern Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign Bytes Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign Integer Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign Natural Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Ticket Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (MutableByteArray RealWorld) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (TVar Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (ForeignPtr a) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (IORef Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (MVar Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Ptr a) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Array Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Referenced Code) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Referenced Value) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Promise Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Deque Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Map Val Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (MutableArray RealWorld Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

newtype AffineRef Source #

Constructors

ARef (IORef Closure) 

Instances

Instances details
Show AffineRef Source # 
Instance details

Defined in Unison.Runtime.Stack

Eq AffineRef Source # 
Instance details

Defined in Unison.Runtime.Stack

data HEnv Source #

Constructors

HEnv 

Fields

Instances

Instances details
Monoid HEnv Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

mempty :: HEnv #

mappend :: HEnv -> HEnv -> HEnv #

mconcat :: [HEnv] -> HEnv #

Semigroup HEnv Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

(<>) :: HEnv -> HEnv -> HEnv #

sconcat :: NonEmpty HEnv -> HEnv #

stimes :: Integral b => b -> HEnv -> HEnv #

dataTag :: Closure -> Maybe PackedTag Source #

The packed tag of a data constructor closure, or Nothing for any other closure.

mapFamily :: ReplacementUse Source #

The tag of base's Map type and of the functions on Map, Set and Multimap, which take and return it (see JIT.Config.ReplacementUse): native code wins on maps below a few thousand keys, the common case, the Haskell map above (JITbenchmarks2026-10-11-replacements.md), so the family is left to the JIT.

mapReplaced :: Bool Source #

Whether the Map type is replaced by the Haskell WrapMap under the current settings.

data UnboxedTypeTag Source #

Constructors

CharTag 
FloatTag 
IntTag 
NatTag 
WitnessTag !Int

The value slot of a wide variable holding an unboxed constructor of this many fields (Unison.Runtime.Wide): the slot's word is the constructor's packed tag and the fields are in the slots below.

witnessTag :: Int -> Closure Source #

The witness closures of unboxed constructors (WitnessTag), one per field count, so that writing one allocates nothing.

newtype Callback Source #

Constructors

Hook (XStack -> IO ()) 

Instances

Instances details
Eq Callback Source # 
Instance details

Defined in Unison.Runtime.Stack

Ord Callback Source # 
Instance details

Defined in Unison.Runtime.Stack

data Augment Source #

Constructors

I 
K 
C 

data Dump Source #

Constructors

A 
F Int Int 
S 

data Stack Source #

Constructors

Stack 

Fields

Instances

Instances details
Show Stack Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

showsPrec :: Int -> Stack -> ShowS #

show :: Stack -> String #

showList :: [Stack] -> ShowS #

type Off = Int Source #

type SZ = Int Source #

type FP = Int Source #

type Seg = (USeg, BSeg) Source #

type SegList = [Val] Source #

type RecordVals = Vector Val Source #

A record's field values, in ascending field-name order. Slot i holds the value of field i of the accompanying RecordShape.

recordVals :: Seg -> RecordVals Source #

A record's values from a segment: slot i holds the segment's i-th value (the segments are stored backwards). Every element is an evaluated Val, since native code reads the vector's elements as closures.

segToList :: Seg -> SegList Source #

Converts from the efficient stack form of a segment to the list representation. Segments are stored backwards, so this reverses the contents

data Val Source #

A runtime value, which is either a boxed or unboxed value, but we may not know which.

When it represents a boxed value, getUnboxedVal is meaningless, but when it represents an unboxed value, getBoxedVal tells us its type.

Constructors

Val 

Fields

Bundled Patterns

pattern CharVal :: Char -> Val 
pattern NatVal :: Word64 -> Val 
pattern DoubleVal :: Double -> Val 
pattern IntVal :: Int -> Val 
pattern BoolVal :: Bool -> Val 
pattern UnboxedVal :: Int -> UnboxedTypeTag -> Val 
pattern BoxedVal :: Closure -> Val

Matches a Val which is known to be boxed, and returns the closure portion.

Instances

Instances details
Show Val Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

showsPrec :: Int -> Val -> ShowS #

show :: Val -> String #

showList :: [Val] -> ShowS #

Eq Val Source #

The Eq instance for Val can’t be derived because you need to take into account the fact that if a Val is boxed, the unboxed side is garbage and should not be compared.

Instance details

Defined in Unison.Runtime.Stack

Methods

(==) :: Val -> Val -> Bool #

(/=) :: Val -> Val -> Bool #

Ord Val Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

compare :: Val -> Val -> Ordering #

(<) :: Val -> Val -> Bool #

(<=) :: Val -> Val -> Bool #

(>) :: Val -> Val -> Bool #

(>=) :: Val -> Val -> Bool #

max :: Val -> Val -> Val #

min :: Val -> Val -> Val #

ForeignConvention Val Source # 
Instance details

Defined in Unison.Runtime.Foreign.Function

BuiltinForeign (Ticket Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (TVar Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (IORef Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (MVar Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Array Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Promise Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Deque Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Map Val Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (MutableArray RealWorld Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

emptyVal :: Val Source #

A nulled out value you can use when filling empty arrays, etc.

boxedVal :: BVal -> Val Source #

Lift a boxed val into an Val

type USeq = Deque Val Source #

Implementation for Unison sequences. | The runtime's lists. A strict deque: no thunks inside, so its structure can be read without evaluating anything.

poke :: DebugCallStack => Stack -> Val -> IO () Source #

pokeD :: Stack -> Double -> IO () Source #

pokeOffD :: Stack -> Int -> Double -> IO () Source #

pokeC :: Stack -> Char -> IO () Source #

pokeOffC :: Stack -> Int -> Char -> IO () Source #

pokeBool :: DebugCallStack => Stack -> Bool -> IO () Source #

pokeTag :: DebugCallStack => Stack -> Int -> IO () Source #

Store an unboxed tag to later match on. Often used to indicate the constructor of a data type that's been unpacked onto the stack, or some tag we're about to branch on.

peekTag :: DebugCallStack => Stack -> IO Int Source #

peekTagOff :: DebugCallStack => Stack -> Off -> IO Int Source #

peekI :: DebugCallStack => Stack -> IO Int Source #

peekOffI :: DebugCallStack => Stack -> Off -> IO Int Source #

pokeN :: Stack -> Word64 -> IO () Source #

pokeOffN :: Stack -> Int -> Word64 -> IO () Source #

pokeI :: Stack -> Int -> IO () Source #

Note: This is for poking an unboxed value that has the UNISON type int, not just any unboxed data.

pokeOffI :: Stack -> Int -> Int -> IO () Source #

pokeBi :: BuiltinForeign b => Stack -> b -> IO () Source #

pokeOffBi :: BuiltinForeign b => Stack -> Int -> b -> IO () Source #

pokeS :: Stack -> USeq -> IO () Source #

pokeOffS :: Stack -> Int -> USeq -> IO () Source #

dumpAP :: Int -> Int -> Int -> Dump -> Int Source #

dumpFP :: Int -> Int -> Dump -> Int Source #

defaultStackSlots :: Int Source #

The slots a fresh stack has. The JIT's ustack stress mode starts with a tiny stack instead, so that growing it is exercised constantly.

type MCombs = RCombs Val Source #

The code the interpreter runs: MCode over resolved combinators and these values. (Defined here, below the JIT modules, so that the JIT handle can be a field of the code cache without an import cycle.)

nativeOutWords :: Int Source #

Words past the last slot of the unboxed stack that native code's entry point writes its results to: ap, fp, sp, a count of frame records, and up to eight records of three words. Must match UNISON_JIT_OUT_WORDS in jit_rt.h.

nativeOutPtrs :: Int Source #

Pointers past the last slot of the boxed stack, where native code hands heap pointers back so that the collector sees them: the handler environment it was running with when it returned, then one environment per Local frame record it wrote (see pushRecord in Machine.hs). Must match UNISON_JIT_OUT_PTRS in jit_rt.h.

bstkSlots :: MutableArray RealWorld Closure -> Int Source #

The slots of a boxed stack: its size less the out-area.

peek :: DebugCallStack => Stack -> IO Val Source #

upeek :: DebugCallStack => Stack -> IO UVal Source #

bpeek :: DebugCallStack => Stack -> IO BVal Source #

peekOff :: DebugCallStack => Stack -> Off -> IO Val Source #

upeekOff :: DebugCallStack => Stack -> Off -> IO UVal Source #

bpeekOff :: DebugCallStack => Stack -> Off -> IO BVal Source #

bpoke :: DebugCallStack => Stack -> BVal -> IO () Source #

Store a boxed value. We don't bother nulling out the unboxed stack, it's extra work and there's nothing to garbage collect.

bpokeOff :: DebugCallStack => Stack -> Off -> BVal -> IO () Source #

pokeOff :: DebugCallStack => Stack -> Off -> Val -> IO () Source #

upokeT :: DebugCallStack => Stack -> UVal -> BVal -> IO () Source #

upokeOffT :: DebugCallStack => Stack -> Off -> UVal -> BVal -> IO () Source #

unsafePokeIasN :: DebugCallStack => Stack -> Int -> IO () Source #

Sometimes we get back an int from a foreign call which we want to use as a Nat. If we know it's positive and smaller than 2^63 then we can safely store the Int directly as a Nat without checks.

grabSeg :: Stack -> SZ -> IO (Seg, Stack) Source #

Eats up arguments

ensureGenerously :: Stack -> SZ -> IO Stack Source #

Like ensure, but grows by at least the stack's current size. Native code pays for every growth by unwinding all its frames to the interpreter, so it asks for room in big steps.

useg :: [Int] -> USeg Source #

Converts a list of integers representing an unboxed segment back into the appropriate segment. Segments are stored backwards in the runtime, so this reverses the list.

bseg :: [Closure] -> BSeg Source #

Converts a list of closures back to a boxed segment. Segments are stored backwards, so this reverses the contents.

segFromList :: SegList -> Seg Source #

Converts from the list representation of a segment to the efficient stack form. Segments are stored backwards, so this reverses the contents.

traverseListToSeg :: (a -> IO Val) -> [a] -> IO Seg Source #

Unboxed type tags

data Tls Source #

Constructors

Tls 

Fields

Instances

Instances details
Eq Tls Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

(==) :: Tls -> Tls -> Bool #

(/=) :: Tls -> Tls -> Bool #

BuiltinForeign Tls Source # 
Instance details

Defined in Unison.Runtime.Stack