Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added USE_BOEHM compile option

  • Loading branch information...
commit 42551a08ba494e988734bb2e7a5765ec5faef524 1 parent 7eb29f3
Edwin Brady authored
View
4 Epic/Compiler.lhs
@@ -76,7 +76,7 @@ Chop off everything after the last / - get the directory a file is in
> fp <- getDataFileName "evm/closure.h"
> let libdir = trimLast fp
> let dbg = if (elem Debug opts) then "-g" else "-O3"
-> let cmd = "gcc -c " ++ dbg ++ " -foptimize-sibling-calls -x c " ++ tmpn ++ " -I" ++ libdir ++ " -o " ++ outf ++ " " ++ addGCC opts ++ doTrace opts
+> let cmd = "gcc -DUSE_BOEHM -c " ++ dbg ++ " -foptimize-sibling-calls -x c " ++ tmpn ++ " -I" ++ libdir ++ " -o " ++ outf ++ " " ++ addGCC opts ++ doTrace opts
> -- putStrLn $ cmd
> -- putStrLn $ fp
> exit <- system cmd
@@ -120,7 +120,7 @@ Chop off everything after the last / - get the directory a file is in
> fp <- getDataFileName "evm/closure.h"
> let libdir = trimLast fp
> let dbg = if (elem Debug opts) then "-g" else "-O3"
-> let cmd = "gcc -x c " ++ dbg ++ " -foptimize-sibling-calls " ++ mainprog ++ " -x none -L" ++
+> let cmd = "gcc -DUSE_BOEHM -x c " ++ dbg ++ " -foptimize-sibling-calls " ++ mainprog ++ " -x none -L" ++
> libdir++" -I"++libdir ++ " " ++
> (concat (map (++" ") infs)) ++
> " -levm -lgc -lpthread -lgmp -o "++outf
View
4 epic.cabal
@@ -16,8 +16,8 @@ Description: Epic is a simple functional language which compiles to
(<http://www.cs.st-and.ac.uk/~eb/Idris>).
It can be invoked either as a library or an application.
-Data-files: evm/libevm.a evm/closure.h evm/stdfuns.h evm/stdfuns.c evm/mainprog.c evm/emalloc.h
-Extra-source-files: evm/closure.c evm/closure.h evm/stdfuns.h evm/mainprog.c evm/stdfuns.c evm/Makefile evm/emalloc.c evm/emalloc.h
+Data-files: evm/libevm.a evm/closure.h evm/stdfuns.h evm/stdfuns.c evm/mainprog.c evm/emalloc.h evm/gc_header.h
+Extra-source-files: evm/closure.c evm/closure.h evm/stdfuns.h evm/mainprog.c evm/stdfuns.c evm/Makefile evm/emalloc.c evm/emalloc.h evm/gc_header.h
Cabal-Version: >= 1.2.3
Build-type: Custom
View
9 evm/closure.h
@@ -1,14 +1,7 @@
#ifndef _CLOSURE_H
#define _CLOSURE_H
-# ifndef WIN32
-# include <pthread.h>
-# define GC_THREADS
-# else
-# define GC_WIN32_THREADS
-# endif
-
-#include <gc/gc.h>
+#include <gc_header.h>
//#include <emalloc.h>
#include <gmp.h>
View
7 evm/emalloc.c
@@ -9,10 +9,13 @@
// Actually, should the root set be the addresses of the local variables? Then
// when they are copied, they can be updated with the new location.
+extern ALLOCATOR allocate;
+extern REALLOCATOR reallocate;
+
void* e_malloc(VMState* vm, size_t size) {
- return (VAL)GC_malloc(size);
+ return (VAL)allocate(size);
}
void* e_realloc(VMState* vm, void* ptr, size_t size) {
- return (VAL)GC_realloc(ptr, size);
+ return (VAL)reallocate(ptr, size);
}
View
12 evm/gc_header.h
@@ -0,0 +1,12 @@
+#ifdef USE_BOEHM
+
+# ifndef WIN32
+# include <pthread.h>
+# define GC_THREADS
+# else
+# define GC_WIN32_THREADS
+# endif
+
+#include <gc/gc.h>
+
+#endif
View
8 evm/mainprog.c
@@ -1,10 +1,4 @@
-# ifndef WIN32
-# include <pthread.h>
-# define GC_THREADS
-# else
-# define GC_WIN32_THREADS
-# endif
-
+#include <gc_header.h>
#include "closure.h"
void* _do__U_main();
View
9 evm/stdfuns.c
@@ -11,10 +11,13 @@ void putStr(char* s) { printf("%s",s); }
void printBigInt(mpz_t x) { printf("%s\n",mpz_get_str(NULL,10,x)); }
void epicGC() {
+#ifdef USE_BOEHM
GC_gcollect();
+#endif
}
void epicMemInfo() {
+#ifdef USE_BOEHM
GC_gcollect();
int heap = GC_get_heap_size();
int free = GC_get_free_bytes();
@@ -23,6 +26,7 @@ void epicMemInfo() {
printf("Heap size %d\n", heap);
printf("Heap used %d\n", heap-free);
printf("Total allocations %d\n", total);
+#endif
}
int readInt() {
@@ -47,8 +51,11 @@ void* freadStr(void* h) {
FILE* f = (FILE*)h;
fgets(bufin,128,f);
int len = strlen(bufin);
-
+#ifdef USE_BOEHM
VAL c = GC_MALLOC_ATOMIC(sizeof(Closure)+len*sizeof(char)+sizeof(char)+1);
+#else
+ VAL c = EMALLOC(sizeof(Closure)+len*sizeof(char)+sizeof(char)+1);
+#endif
SETTY(c, STRING);
c->info = ((void*)(c+1));
char *buf = (char*)(c->info);
Please sign in to comment.
Something went wrong with that request. Please try again.