diff --git a/regression/x86only/orig/test007.log b/regression/x86only/orig/test007.log new file mode 100644 index 000000000..865b114d1 --- /dev/null +++ b/regression/x86only/orig/test007.log @@ -0,0 +1,5 @@ +Cloning int: 5 +Cloning string: abc +Cloning array: [1, 2, 3, 4, 5] +Cloning sexp: A (1, 2, 3, 4, 5) +Cloning closure: address ok, 5, 6 diff --git a/regression/x86only/test007.expr b/regression/x86only/test007.expr new file mode 100644 index 000000000..0d6ab5ce9 --- /dev/null +++ b/regression/x86only/test007.expr @@ -0,0 +1,14 @@ +fun f (x, y) { + fun () {x+y} +} + +printf ("Cloning int: %d\n", clone (5)); +printf ("Cloning string: %s\n", clone ("abc")); +printf ("Cloning array: %s\n", clone ([1, 2, 3, 4, 5]).string); +printf ("Cloning sexp: %s\n", clone (A (1, 2, 3, 4, 5)).string); + +{ + local c = f (5, 6), cc = clone (c); + + printf ("Cloning closure: address %s, %d, %d\n", if cc[0] == c[0] then "ok" else "fail" fi, c[1], c[2]) +} diff --git a/runtime/runtime.c b/runtime/runtime.c index acbbd740a..7078064e6 100644 --- a/runtime/runtime.c +++ b/runtime/runtime.c @@ -485,7 +485,7 @@ void *Lclone (void *p) { if (UNBOXED(p)) return p; else { - data *a = TO_DATA(p), *res; + data *a = TO_DATA(p); int t = TAG(a->tag), l = LEN(a->tag); switch (t) { @@ -496,12 +496,15 @@ void *Lclone (void *p) { case ARRAY_TAG: case CLOSURE_TAG: res = (data*) alloc (sizeof(int) * (l+1)); - strncpy (res, p, sizeof(int) * (l+1)); + memcpy (res, a, sizeof(int) * (l+1)); + res = res->contents; break; case SEXP_TAG: - res = (data*) alloc (sizeof(int) * (l+2)); - strncpy (res, TO_SEXP(p), sizeof(int) * (l+2)); + res = (sexp*) alloc (sizeof(int) * (l+2)); + memcpy (res, TO_SEXP(p), sizeof(int) * (l+2)); + res = res->contents; + res = res->contents; break; default: @@ -1142,7 +1145,7 @@ extern void __gc_root_scan_stack (); /* Mark-and-copy */ /* ======================================== */ -static size_t SPACE_SIZE = 32; +static size_t SPACE_SIZE = 32 * 1024; // static size_t SPACE_SIZE = 128; // static size_t SPACE_SIZE = 1024 * 1024; diff --git a/src/X86.ml b/src/X86.ml index dabb1b8e4..48490934b 100644 --- a/src/X86.ml +++ b/src/X86.ml @@ -183,7 +183,7 @@ let compile cmd env code = match scode with | [] -> env, [] | instr :: scode' -> - let stack = env#show_stack in + let stack = "" (* env#show_stack*) in let env', code' = match instr with | PUBLIC name -> env#register_public name, [] diff --git a/stdlib/Collection.expr b/stdlib/Collection.expr index 66283f0fb..d1f0f6e5e 100644 --- a/stdlib/Collection.expr +++ b/stdlib/Collection.expr @@ -255,5 +255,5 @@ public fun emptyMemo () { } public fun lookupMemo (m, v) { - + skip } \ No newline at end of file diff --git a/stdlib/Makefile b/stdlib/Makefile index 1d56d19d8..d0f6b3e29 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -6,6 +6,8 @@ RC=../src/rc.opt all: $(ALL) +Collection.o: List.o + %.o: %.expr $(RC) -I . -c $<