Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add malloc_ to Epic interface

  • Loading branch information...
commit 3cb552371037dee8e75ef1b05e39e7b3c9ed5f92 1 parent b1b415e
Edwin Brady authored
Showing with 26 additions and 0 deletions.
  1. +10 −0 Epic/Epic.lhs
  2. +16 −0 Papers/Epic/implementation.tex
View
10 Epic/Epic.lhs
@@ -21,6 +21,7 @@
> foreign_, foreignL_, foreignConst_, foreignConstL_,
> let_, letN_, update_, op_,
> str, int, float, char, bool, unit_, (!.), fn, ref, (+>),
+> malloc_,
> -- * Types
> Type, tyInt, tyChar, tyBool, tyFloat, tyString,
> tyPtr, tyUnit, tyAny, tyC,
@@ -262,6 +263,15 @@ Remaining expression constructs
> foreignConst_ t str = term $ ForeignCall t str []
> foreignConstL_ t str = term $ LazyForeignCall t str []
+> -- | Evaluate an expression under manually allocated memory. Creates a pool
+> -- of memory. All allocation is from this pool, and there is no garbage
+> -- collection. The pool is freed after evaluation.
+> malloc_ :: (EpicExpr a, EpicExpr b) =>
+> a -- ^ Size of block to allocate
+> -> b -- ^ Expression to evaluate
+> -> Term
+> malloc_ = exp2 (WithMem FixedPool)
+
mkCon :: Int -> [Term] -> Term
mkCon tag args = do args' <- mapM expr args
return (Con tag args')
View
16 Papers/Epic/implementation.tex
@@ -0,0 +1,16 @@
+\section{Implementation}
+
+How it's implemented is not really important to the user --- a
+compiler can target Epic without knowing, and we could drop in a new
+back end at any time in principle.
+
+There is currently one back end, but more are planned. Compiled via
+C. Garbage collection with Boehm~\cite{boehm-gc},
+\texttt{\%memory}. (Note that a non-moving collector makes things
+easier for foreign functions, but may not be the best choice in the
+long run).
+
+Later plans: compile via LLVM, allow plug in garbage collectors
+(important for embedded systems, device drivers, operating system
+services, for example).
+
Please sign in to comment.
Something went wrong with that request. Please try again.