<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -18,7 +18,7 @@
  |#
 (library (core.exceptions)
   (export with-exception-handler raise raise-continuable assert error
-          assertion-violation describe-os-error)
+          assertion-violation)
   (import (core.forms))
 
   (define (default-exception obj)
@@ -61,8 +61,4 @@
 
   (define assertion-violation error)
 
-  (define (describe-os-error)
-    (builtin-call os-strerror
-                  (builtin-call os-errno)))
-
   )</diff>
      <filename>scheme/core.exceptions.scm</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ LDFLAGS += -pthread
 
 vm_obj = vm.o heap.o native.o primitives.o hash.o \
 		 module.o strings.o bytevector.o struct.o \
-		posix.o const_allocator.o types.o
+		const_allocator.o types.o
 
 .PHONY: all clean
 all: vm</diff>
      <filename>vm/Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -25,7 +25,7 @@
 /* TODO: tune it */
 #define FRESH_SIZE 1024*128
 #define SURVIVED_SIZE 1024*128
-#define OLD_SIZE 1024*512
+#define OLD_SIZE SURVIVED_SIZE*5
 
 #define HEAP_DBG printf
 #define NEXT_HDR(h) (BHDR_SIZE + (h)-&gt;size + (void*)h)
@@ -295,8 +295,13 @@ void heap_gc(heap_t *heap)
 	heap_swap_survived(heap);
 	thread_after_gc(&amp;heap-&gt;visitor, heap-&gt;thread);
 
-	if (heap-&gt;old.free_mem &lt; SURVIVED_SIZE)
-		heap-&gt;full_gc = 1;		/* Tell to perform full gc next time */
+	/*
+	 * Schedule full gc for the next time if old space present and may
+	 * not feet survived space
+	 */
+	if (heap-&gt;old.mem
+		&amp;&amp; (heap-&gt;old.free_mem &lt; SURVIVED_SIZE))
+		heap-&gt;full_gc = 1;
 
 	gettimeofday(&amp;tv2, NULL);
 	timersub(&amp;tv2, &amp;tv1, &amp;tv3);
@@ -350,7 +355,8 @@ static void heap_mark(visitor_t *visitor, obj_t *obj)
 		return;
 
 	void *p = PTR(*obj);
-	if (p &lt; heap-&gt;mem || p &gt; heap-&gt;mem+heap-&gt;mem_size)
+	if ((p &lt; heap-&gt;mem || p &gt; heap-&gt;mem+heap-&gt;mem_size)
+		&amp;&amp; !in_space(&amp;heap-&gt;old, p))
 		FATAL(&quot;Trying to mark %p which doesn't belong to this heap\n&quot;, p);
 
 	if (in_space(heap-&gt;future_survived, p)) {
@@ -404,7 +410,13 @@ static void heap_mark(visitor_t *visitor, obj_t *obj)
 			}
 			return; //Postpone copying
 		}
-		//HEAP_DBG(&quot;Got old object\n&quot;);
+
+		/* Allocate old space on demand */
+		if (!heap-&gt;old.mem) {
+			void *old_mem = mem_alloc(OLD_SIZE);
+			space_init(&amp;heap-&gt;old, old_mem, OLD_SIZE);
+		}
+
 		new_pos = space_copy(&amp;heap-&gt;old, p, ts);
 		heap_remember(heap, new_pos);
 		hdr-&gt;remembered = 0;
@@ -431,7 +443,7 @@ static void* heap_allocator_alloc(allocator_t *al, size_t size, int type_id)
 
 void heap_init(heap_t *heap, vm_thread_t *thread)
 {
-	heap-&gt;mem_size = FRESH_SIZE+SURVIVED_SIZE*2+OLD_SIZE;
+	heap-&gt;mem_size = FRESH_SIZE+SURVIVED_SIZE*2;
 	heap-&gt;mem = mem_alloc(heap-&gt;mem_size);
 
 	void *memp = heap-&gt;mem;
@@ -446,7 +458,6 @@ void heap_init(heap_t *heap, vm_thread_t *thread)
 	INIT_SPACE(&amp;heap-&gt;fresh, FRESH_SIZE);
 	INIT_SPACE(&amp;heap-&gt;survived_spaces[0], SURVIVED_SIZE);
 	INIT_SPACE(&amp;heap-&gt;survived_spaces[1], SURVIVED_SIZE);
-	INIT_SPACE(&amp;heap-&gt;old, OLD_SIZE);
 
 	heap-&gt;visitor.visit = heap_mark;
 	heap-&gt;visitor.user_data = heap;
@@ -463,4 +474,8 @@ void heap_destroy(heap_t *heap)
 			heap-&gt;gc_count,
 			heap-&gt;gc_time.tv_sec,
 			heap-&gt;gc_time.tv_usec);
+	if (heap-&gt;old.mem) {
+		LOG_DBG(&quot;%d object remained in the old space\n&quot;, heap-&gt;old.blocks);
+		mem_free(heap-&gt;old.mem);
+	}
 }</diff>
      <filename>vm/heap.c</filename>
    </modified>
    <modified>
      <diff>@@ -17,7 +17,6 @@
  * &lt;http://www.gnu.org/licenses&gt;.
  */
 #include &quot;primitives.h&quot;
-#include &quot;posix.h&quot;
 
 int t_pair, t_cont;
 
@@ -243,10 +242,6 @@ static native_module_t modules[] = {
 	{ strings_init, strings_cleanup },
 	{ struct_init },
 	{ bytevector_init },
-	{ posix_init },
-#ifdef HAVE_LIBFFI
-	{ ffi_init, ffi_cleanup }
-#endif
 };
 
 void primitives_init()</diff>
      <filename>vm/primitives.c</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>vm/posix.c</filename>
    </removed>
    <removed>
      <filename>vm/posix.h</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>2e454663fe32988ee5381151edbadd0a565d5bf4</id>
    </parent>
  </parents>
  <author>
    <name>Stepan Zastupov</name>
    <email>redchrom@gmail.com</email>
  </author>
  <url>http://github.com/redchrom/lgears/commit/8dd366dae00f7f76478aed32c4d048bb45e88b23</url>
  <id>8dd366dae00f7f76478aed32c4d048bb45e88b23</id>
  <committed-date>2009-06-23T12:59:32-07:00</committed-date>
  <authored-date>2009-06-23T12:59:32-07:00</authored-date>
  <message>Delete builtin posix support, allocate old space on demand

Builtin posix layer removed because it's a bad idea to hardcode os layer
inside VM, in any case, ffi will cover it in future.</message>
  <tree>4a11d2960b6278e62d30f8037be6483f740403ca</tree>
  <committer>
    <name>Stepan Zastupov</name>
    <email>redchrom@gmail.com</email>
  </committer>
</commit>
