[uim-commit] r997 - branches/r5rs/sigscheme

tkng at freedesktop.org tkng at freedesktop.org
Thu Jul 21 17:40:32 EST 2005


Author: tkng
Date: 2005-07-21 00:40:29 -0700 (Thu, 21 Jul 2005)
New Revision: 997

Modified:
   branches/r5rs/sigscheme/datas.c
   branches/r5rs/sigscheme/sigschemetype.h
Log:
* sigscheme/sigschemetype.h:
 - (ScmPortInfo): Added a new member 'line'.

* sigscheme/datas.c:
 - (Scm_NewPort): Added a initialization for line.


Modified: branches/r5rs/sigscheme/datas.c
===================================================================
--- branches/r5rs/sigscheme/datas.c	2005-07-21 06:52:26 UTC (rev 996)
+++ branches/r5rs/sigscheme/datas.c	2005-07-21 07:40:29 UTC (rev 997)
@@ -59,6 +59,10 @@
 #include <stdlib.h>
 #include <malloc.h>
 
+#ifdef USE_BOEHM_GC
+  #include <gc/gc.h>
+#endif
+
 /*=======================================
   Local Include
 =======================================*/
@@ -81,12 +85,21 @@
 =======================================*/
 #define NAMEHASH_SIZE 1024
 
+#ifdef USE_BOEHM_GC
+
 #define SCM_NEW_OBJ_INTERNAL(VALNAME)                                   \
+  VALNAME = GC_MALLOC(sizeof(ScmObjInternal));
+
+#else
+
+#define SCM_NEW_OBJ_INTERNAL(VALNAME)                                   \
     if (EQ(scm_freelist, SCM_NIL))					\
 	gc_mark_and_sweep();						\
     VALNAME = scm_freelist;						\
     scm_freelist = SCM_FREECELL_CDR(scm_freelist);			\
 
+#endif
+
 /*=======================================
   Variable Declarations
 =======================================*/
@@ -132,24 +145,41 @@
 /*=======================================
   Function Implementations
 =======================================*/
-void SigScm_InitStorage()
+void SigScm_InitStorage(void)
 {
-    allocate_heap(&scm_heaps, scm_heap_num, SCM_HEAP_SIZE, &scm_freelist);
-    initialize_symbol_hash();
+#ifdef USE_BOEHM_GC
+  GC_enable_incremental();
+#endif
+
+  allocate_heap(&scm_heaps, scm_heap_num, SCM_HEAP_SIZE, &scm_freelist);
+  initialize_symbol_hash();
 }
 
-void SigScm_FinalizeStorage()
+void SigScm_FinalizeStorage(void)
 {
+#ifdef USE_BOEHM_GC
+  /*    GC_invoke_finalizers(); */
+#else 
     finalize_heap();
     finalize_symbol_hash();
+#endif
 }
 
 static void *malloc_aligned(size_t size)
 {
+
+#ifdef USE_BOEHM_GC
+  return  GC_MALLOC(size);
+
+#else
+
     /* TODO : Need to reserch System Dependency! */
     void *p;
     posix_memalign(&p, 16, size);
     return p;
+
+#endif
+
 }
 
 
@@ -160,8 +190,12 @@
     ScmObj prev = NULL;
     ScmObj next = NULL;
 
+#ifdef USE_BOEHM_GC
+    return;
+#endif
+
 #if DEBUG_GC
-    printf("allocate_heap\n");
+    printf("allocate_heap num:%d size:%d\n", num_heap, HEAP_SIZE);
 #endif
 
     /* allocate heap */
@@ -205,7 +239,7 @@
     ScmObj next     = NULL;
 
 #if DEBUG_GC
-    printf("add_heap\n");
+    printf("add_heap current num of heaps:%d\n", *orig_num_heap);
 #endif
 
     /* increment num_heap */
@@ -217,7 +251,8 @@
 
     /* allocate heap */
     (*heaps)[num_heap - 1] = (ScmObj)malloc_aligned(sizeof(ScmObjInternal) * HEAP_SIZE);
-
+    memset((*heaps)[num_heap - 1], 0, sizeof(ScmObjInternal) * HEAP_SIZE);
+    
     /* link in order */
     for (i = 0; i < HEAP_SIZE; i++) {
         next = &(*heaps)[num_heap - 1][i];
@@ -268,14 +303,22 @@
     printf("[ gc start ]\n");
 #endif
 
+#ifdef USE_BOEHM_GC
+
+    return;
+#endif
+
     gc_preprocess();
-
     gc_mark();
     gc_sweep();
-
+    
     /* we cannot sweep the object, so let's add new heap */
-    if (SCM_NULLP(scm_freelist))
+    if (SCM_NULLP(scm_freelist)) {
+#if DEBUG_GC
+      printf("Cannot sweeped the object, allocating new heap.\n");
+#endif
         add_heap(&scm_heaps, &scm_heap_num, SCM_HEAP_SIZE, &scm_freelist);
+    }
 }
 
 static void mark_obj(ScmObj obj)
@@ -373,9 +416,7 @@
     /* get size */
     size = end - start;
 
-#if DEBUG_GC
-	printf("gc_mark_stack() size = %d\n", size);
-#endif
+	printf("gc_mark_stack() size = %p\n", start);
 
     /* mark stack */
     for (i = 0; i < size; i++) {
@@ -410,6 +451,13 @@
 {
     /* if the type has the pointer to free, then free it! */
     switch (SCM_GETTYPE(obj)) {
+        case ScmInt:
+        case ScmCons:
+        case ScmFunc:
+        case ScmClosure:
+        case ScmFreeCell:
+        case ScmEtc:
+	  break;
 	case ScmChar:
 	    if (SCM_CHAR_CH(obj)) {
 		free(SCM_CHAR_CH(obj));
@@ -471,7 +519,7 @@
 	}
 	
 #if DEBUG_GC
-	printf("scm[%d] corrected = %d\n", i, corrected_obj_num);
+	printf("scm[%d] sweeped = %d\n", i, corrected_obj_num);
 #endif
     }
     scm_freelist = scm_new_freelist;
@@ -616,6 +664,7 @@
     SCM_SETPORT(obj);
     pinfo  = (ScmPortInfo *)malloc(sizeof(ScmPortInfo));
     pinfo->file         = file;
+    pinfo->line         = 0;
     pinfo->ungottenchar = 0;
     SCM_SETPORT_PORTINFO(obj, pinfo);
     SCM_SETPORT_PORTTYPE(obj, ptype);

Modified: branches/r5rs/sigscheme/sigschemetype.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype.h	2005-07-21 06:52:26 UTC (rev 996)
+++ branches/r5rs/sigscheme/sigschemetype.h	2005-07-21 07:40:29 UTC (rev 997)
@@ -95,6 +95,7 @@
 typedef struct _ScmPortInfo ScmPortInfo;
 struct _ScmPortInfo {
     FILE *file;
+    int line;
     char ungottenchar;
 };
 
@@ -297,6 +298,7 @@
 #define SCM_SETPORT_PORTTYPE(a, ptype) (SCM_PORT_PORTTYPE(a) = ptype)
 #define SCM_SETPORT_PORTINFO(a, pinfo) (SCM_PORT_PORTINFO(a) = pinfo)
 #define SCM_PORTINFO_FILE(a) (SCM_PORT_PORTINFO(a)->file)
+#define SCM_PORTINFO_LINE(a) (SCM_PORT_PORTINFO(a)->line)
 #define SCM_PORTINFO_UNGOTTENCHAR(a) (SCM_PORT_PORTINFO(a)->ungottenchar)
 
 #define SCM_CONTINUATIONP(a) (SCM_GETTYPE(a) == ScmContinuation)



More information about the uim-commit mailing list