| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Base
Contents
Description
The ABS' AST and the ABS-runtime data-structures
- type Ref = Int
- type ObjRef = Ref
- type FutRef = Ref
- type Counter = Ref
- data Heap = Heap {}
- type Objects = IOVector (Attrs, Seq Proc)
- type Attrs = IOVector Ref
- type Futures = IOVector (Either [ObjRef] Ref)
- type Cont = Stmt
- newtype Proc = Proc {}
- type SchedQueue = Q ObjRef
- data Stmt
- data Rhs
- data V
- data BExp
- type Method = [Ref] -> ObjRef -> Maybe Ref -> Cont -> Cont
The values of our language
An object value is a reference (index) to the object heap
note: type synonym for clarity
A future value is a reference (index) to the future heap
(note: type synonym for clarity)
The datastructures used at ABS-runtime
An ever-increasing memory-counter to pick new unique references when creating new objects (via new) and futures (via async)
(note: type synonym for making the translation clear)
the simulated Heap datastructure where all objects&futurues live in.
NB: assume no Garbage-Collection of the Heap for the moment. At runtime, no GC will be performed from the underlying Haskell-GC, because we do not delete objects.
type Objects = IOVector (Attrs, Seq Proc) Source
The objects of the heap is a growable 0-int-indexed array where each cell is a pair of the object's attributes and the object's process queue
type Attrs = IOVector Ref Source
The attributes is a fixed array of attribute names (Ints) to attribute values (Refs)
We assume a preprocessing step to transform all the attribute names occuring in a program to Ints so they can become the indices to this array. NB: All objects have the same fixed size attr-array, although they may only use a subset of all the attributes.
type Futures = IOVector (Either [ObjRef] Ref) Source
The futures of the heap is a growable int-indexed array of the futures' potential final values.
A future is empty (Left), with n callers waiting on it.
A future is resolved (filled with 'Right value'), hence its type "Either [ObjRef] Ref".
NB: The correctness and preservation assume ABS programs with only 1 waiting-caller, in other words programs that do not pass-over a created future to another object.
A future reference must be _final_ after resolved, and this must be guaranteed by the runtime system.
We have a single (universal) type for our continuations. Later, if we introduce local-variables we are going to need an extra type for Continuations: 'Ref -> Stmt'
Each process is a pair of its destiny future-reference, and its (resumable) continuation
(note: is a newtype just for overriding its Show instance, check module PP)
type SchedQueue = Q ObjRef Source
The global-system scheduler's runtime Process Table.
It is simply a queue of object-references
Our language's AST and types
An ABS statement.
Statements are "chained" (sequantially composed) by deeply nesting them through Continuations.
Constructors
| Assign Int Rhs Cont | "attr" := Rhs; cont... |
| Await Int Cont | await "attr"; cont... |
| If BExp (Cont -> Stmt) (Cont -> Stmt) Cont | if pred ThenClause ElseClause; cont... |
| While BExp (Cont -> Stmt) Cont | while pred BodyClause; cont... |
| Skip Cont | skip; cont... |
| Return Int (Maybe Int) Cont | return "attr" WriteBack; cont... (note: if it is a sync call then we pass as an argument to return, the attribute to write back to, if it is async call then we pass Nothing) |
| GetBlocked | Dummy instruction to be returned by sched' |
the RHS of an assignment
Constructors
| I Int | |
| Add V V | |
| Sub V V | |
| Prod V V | |
| Div V V | |
| Mod V V | |
| Attr Ref | dereference a given attribute by looking it up in this object's attribute-array |
| Param Int | do not dereference the given value, because it is method's parameter, thus passed-by-value. This is mainly used because all |
A boolean expression occurs only as a control-flow predicate (if & while)
It only references equality of attributes (BEq), combinators on them
(conjuction,disjunction,negation) and comparison between integer expressions
Arguments
| = [Ref] | a list of passed (deref) parameters |
| -> ObjRef | this obj |
| -> Maybe Ref | in case of sync call: a writeback attribute to write the return result to |
| -> Cont | the continuation after the method is finished |
| -> Cont | the resulting method's continuation that will start executing when applied to () |
The type of every top-level ABS-method.