[uim-commit] r1610 - branches/r5rs/sigscheme
yamaken at freedesktop.org
yamaken at freedesktop.org
Tue Sep 27 00:32:19 PDT 2005
Author: yamaken
Date: 2005-09-27 00:32:16 -0700 (Tue, 27 Sep 2005)
New Revision: 1610
Modified:
branches/r5rs/sigscheme/TODO
branches/r5rs/sigscheme/datas.c
branches/r5rs/sigscheme/operations.c
branches/r5rs/sigscheme/sigscheme.c
branches/r5rs/sigscheme/sigscheme.h
branches/r5rs/sigscheme/sigschemeinternal.h
branches/r5rs/sigscheme/sigschemetype.h
Log:
* This commit implements the VALUECONS feature which reduces 1 cons
cell consumption on a multiple values delivery
* sigscheme/sigscheme.h
- (SCM_USE_VALUECONS): Set to 1 by default
- Move "Struct Declarations" section to after "Macro Declarations"
since sigschemetype.h needs SCM_USE_VALUECONS definition
- (Scm_NewValuePacket): Disable when SCM_USE_VALUECONS is 1
* sigscheme/sigschemetype.h
- (enum ScmObjType): Remove ScmValueCons
- (SCM_AS_VALUECONS, SCM_VALUECONSP, SCM_ENTYPE_VALUECONS): Removed
- (SCM_VALUEPACKETP, SCM_NULLVALUESP, SCM_ENTYPE_VALUEPACKET,
SCM_VALUEPACKET_VALUES): New macro for SCM_USE_VALUECONS
* sigscheme/sigschemeinternal.h
- (NULLVALUESP): New macro
* sigscheme/operations.c
- (ScmOp_values, ScmOp_call_with_values): Support SCM_USE_VALUECONS
* sigscheme/datas.c
- (mark_obj): Ditto
- (Scm_NewValuePacket): Disable when SCM_USE_VALUECONS is 1
* sigscheme/sigscheme.c
- (SigScm_null_values_impl): Removed
- (SigScm_Initialize_internal): Support SCM_USE_VALUECONS
* sigscheme/TODO
- Update
Modified: branches/r5rs/sigscheme/TODO
===================================================================
--- branches/r5rs/sigscheme/TODO 2005-09-27 03:53:56 UTC (rev 1609)
+++ branches/r5rs/sigscheme/TODO 2005-09-27 07:32:16 UTC (rev 1610)
@@ -46,8 +46,6 @@
* Optimize ScmOp_map()
-* Suppress cons cell consumption of 'values' by ValueCons
-
* Object representation compaction ([Anthy-dev 2353], [Anthy-dev 2360])
* Replace almost ScmObj initialization by SCM_NULL with SCM_FALSE. SCM_NULL is
Modified: branches/r5rs/sigscheme/datas.c
===================================================================
--- branches/r5rs/sigscheme/datas.c 2005-09-27 03:53:56 UTC (rev 1609)
+++ branches/r5rs/sigscheme/datas.c 2005-09-27 07:32:16 UTC (rev 1610)
@@ -373,7 +373,12 @@
break;
case ScmValuePacket:
+#if SCM_USE_VALUECONS
+ mark_obj(SCM_VALUECONS_CAR(obj));
+ obj = SCM_VALUECONS_CDR(obj);
+#else
obj = SCM_VALUEPACKET_VALUES(obj);
+#endif
goto mark_loop;
case ScmVector:
@@ -786,6 +791,7 @@
return obj;
}
+#if !SCM_USE_VALUECONS
ScmObj Scm_NewValuePacket(ScmObj values)
{
ScmObj obj = SCM_FALSE;
@@ -796,6 +802,7 @@
return obj;
}
+#endif
#if SCM_USE_NONSTD_FEATURES
ScmObj Scm_NewCPointer(void *data)
Modified: branches/r5rs/sigscheme/operations.c
===================================================================
--- branches/r5rs/sigscheme/operations.c 2005-09-27 03:53:56 UTC (rev 1609)
+++ branches/r5rs/sigscheme/operations.c 2005-09-27 07:32:16 UTC (rev 1610)
@@ -1836,8 +1836,17 @@
if (CONSP(argl) && NULLP(CDR(argl)))
return CAR(argl);
+#if SCM_USE_VALUECONS
+ if (NULLP(argl)) {
+ return SigScm_null_values;
+ } else {
+ SCM_ENTYPE_VALUEPACKET(argl);
+ return argl;
+ }
+#else
/* Otherwise, we'll return the values in a packet. */
return Scm_NewValuePacket(argl);
+#endif
}
ScmObj ScmOp_call_with_values(ScmObj producer, ScmObj consumer)
@@ -1846,6 +1855,16 @@
vals = Scm_call(producer, SCM_NULL);
+#if SCM_USE_VALUECONS
+ if (SCM_NULLVALUESP(vals)) {
+ vals = SCM_NULL;
+ } else if (VALUEPACKETP(vals)) {
+ SCM_ENTYPE_CONS(vals);
+ } else {
+ /* got back a single value */
+ vals = CONS(vals, SCM_NULL);
+ }
+#else
if (!VALUEPACKETP(vals)) {
/* got back a single value */
vals = CONS(vals, SCM_NULL);
@@ -1853,6 +1872,7 @@
/* extract */
vals = SCM_VALUEPACKET_VALUES(vals);
}
+#endif
return Scm_call(consumer, vals);
}
Modified: branches/r5rs/sigscheme/sigscheme.c
===================================================================
--- branches/r5rs/sigscheme/sigscheme.c 2005-09-27 03:53:56 UTC (rev 1609)
+++ branches/r5rs/sigscheme/sigscheme.c 2005-09-27 07:32:16 UTC (rev 1610)
@@ -73,9 +73,6 @@
static ScmObjInternal SigScm_null_impl, SigScm_true_impl, SigScm_false_impl, SigScm_eof_impl;
static ScmObjInternal SigScm_unbound_impl, SigScm_undef_impl;
-#if SCM_USE_VALUECONS
-static ScmObj SigScm_null_values_impl;
-#endif
/*=======================================
Function Implementations
@@ -104,9 +101,6 @@
SCM_ETC_SET_IMPL(SigScm_eof, SigScm_eof_impl );
SCM_ETC_SET_IMPL(SigScm_unbound, SigScm_unbound_impl);
SCM_ETC_SET_IMPL(SigScm_undef, SigScm_undef_impl );
-#if SCM_USE_VALUECONS
- SCM_ETC_SET_IMPL(SigScm_null_values, SigScm_null_values_impl);
-#endif
#if SCM_COMPAT_SIOD_BUGS
SigScm_false = SigScm_null;
@@ -143,6 +137,18 @@
SCM_SYMBOL_SET_VCELL(Scm_Intern("else"), SCM_TRUE);
SCM_SYMBOL_SET_VCELL(Scm_Intern("=>"), SCM_TRUE);
/*=======================================================================
+ Symbol-less Internal Variables
+ =======================================================================*/
+#if SCM_USE_VALUECONS
+ /*
+ * To keep storage model abstract, the cell is allocated from a heap
+ * instead of directly construct ScmObjInternal
+ */
+ SigScm_null_values = CONS(SCM_NULL, SCM_NULL);
+ SCM_ENTYPE_VALUEPACKET(SigScm_null_values);
+ SigScm_GC_Protect(&SigScm_null_values);
+#endif
+ /*=======================================================================
Export Scheme Functions
=======================================================================*/
/* eval.c */
Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h 2005-09-27 03:53:56 UTC (rev 1609)
+++ branches/r5rs/sigscheme/sigscheme.h 2005-09-27 07:32:16 UTC (rev 1610)
@@ -51,14 +51,6 @@
=======================================*/
/*=======================================
- Struct Declarations
-=======================================*/
-typedef void (*ScmCFunc)(void);
-
-/* type declaration */
-#include "sigschemetype.h"
-
-/*=======================================
Macro Declarations
=======================================*/
/* FIXME: split off to config.h */
@@ -75,7 +67,7 @@
#define SCM_STRICT_ARGCHECK 1 /* enable strict argument check */
#define SCM_ACCESSOR_ASSERT 0 /* enable strict type check with accessor */
#define SCM_GCC4_READY_GC 1 /* use experimental gcc4-ready stack protection */
-#define SCM_USE_VALUECONS 0 /* use experimental values passing */
+#define SCM_USE_VALUECONS 1 /* use experimental values passing */
#define SCM_VOLATILE_OUTPUT 0 /* always flush files on write */
/* dependency resolution */
@@ -149,6 +141,14 @@
#endif /* SCM_GCC4_READY_GC */
/*=======================================
+ Struct Declarations
+=======================================*/
+typedef void (*ScmCFunc)(void);
+
+/* type declaration */
+#include "sigschemetype.h"
+
+/*=======================================
Variable Declarations
=======================================*/
/* storage-protection.c */
@@ -336,7 +336,9 @@
ScmObj Scm_NewFilePort(FILE *file, const char *filename, enum ScmPortDirection pdireciton);
ScmObj Scm_NewStringPort(const char *str); /* input only? */
ScmObj Scm_NewContinuation(void);
+#if !SCM_USE_VALUECONS
ScmObj Scm_NewValuePacket(ScmObj values);
+#endif
#if SCM_USE_NONSTD_FEATURES
ScmObj Scm_NewCPointer(void *data);
ScmObj Scm_NewCFuncPointer(ScmCFunc func);
Modified: branches/r5rs/sigscheme/sigschemeinternal.h
===================================================================
--- branches/r5rs/sigscheme/sigschemeinternal.h 2005-09-27 03:53:56 UTC (rev 1609)
+++ branches/r5rs/sigscheme/sigschemeinternal.h 2005-09-27 07:32:16 UTC (rev 1610)
@@ -138,6 +138,9 @@
#define VECTORP SCM_VECTORP
#define PORTP SCM_PORTP
#define CONTINUATIONP SCM_CONTINUATIONP
+#if SCM_USE_VALUECONS
+#define NULLVALUESP SCM_NULLVALUESP
+#endif /* SCM_USE_VALUECONS */
#define VALUEPACKETP SCM_VALUEPACKETP
#define FREECELLP SCM_FREECELLP
#define C_POINTERP SCM_C_POINTERP
Modified: branches/r5rs/sigscheme/sigschemetype.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype.h 2005-09-27 03:53:56 UTC (rev 1609)
+++ branches/r5rs/sigscheme/sigschemetype.h 2005-09-27 07:32:16 UTC (rev 1610)
@@ -92,11 +92,7 @@
ScmPort = 8,
ScmContinuation = 9,
ScmEtc = 10,
-#if SCM_USE_VALUECONS
- ScmValueCons = 11,
-#else
ScmValuePacket = 11,
-#endif
ScmFreeCell = 12,
ScmCPointer = 20,
@@ -299,11 +295,7 @@
#define SCM_AS_VECTOR(a) (SCM_ASSERT_TYPE(SCM_VECTORP(a), (a)))
#define SCM_AS_PORT(a) (SCM_ASSERT_TYPE(SCM_PORTP(a), (a)))
#define SCM_AS_CONTINUATION(a) (SCM_ASSERT_TYPE(SCM_CONTINUATIONP(a), (a)))
-#if SCM_USE_VALUECONS
-#define SCM_AS_VALUECONS(a) (SCM_ASSERT_TYPE(SCM_VALUECONSP(a), (a)))
-#else
#define SCM_AS_VALUEPACKET(a) (SCM_ASSERT_TYPE(SCM_VALUEPACKETP(a), (a)))
-#endif /* SCM_USE_VALUECONS */
#define SCM_AS_C_POINTER(a) (SCM_ASSERT_TYPE(SCM_C_POINTERP(a), (a)))
#define SCM_AS_C_FUNCPOINTER(a) (SCM_ASSERT_TYPE(SCM_C_FUNCPOINTERP(a), (a)))
@@ -390,11 +382,15 @@
#define SCM_CONTINUATION_SET_CONTINFO(a, cinfo) (SCM_CONTINUATION_CONTINFO(a) = (cinfo))
#if SCM_USE_VALUECONS
-/* to modify a ValueCons, rewrite its type to cons by SCM_ENTYPE_CONS(vcons) */
-#define SCM_VALUECONSP(a) (SCM_TYPE(a) == ScmValueCons)
-#define SCM_ENTYPE_VALUECONS(a) (SCM_ENTYPE((a), ScmValueCons))
-#define SCM_VALUECONS_CAR(a) (SCM_AS_VALUE_CONS(a)->obj.cons.car)
-#define SCM_VALUECONS_CDR(a) (SCM_AS_VALUE_CONS(a)->obj.cons.cdr)
+/* to modify a VALUECONS, rewrite its type to cons by SCM_ENTYPE_CONS(vcons) */
+#define SCM_VALUEPACKETP(a) (SCM_TYPE(a) == ScmValuePacket)
+#define SCM_NULLVALUESP(a) (EQ(a, SigScm_null_values))
+#define SCM_ENTYPE_VALUEPACKET(a) (SCM_ENTYPE((a), ScmValuePacket))
+#define SCM_VALUEPACKET_VALUES(a) ((SCM_NULLVALUESP(a)) ? SCM_NULL : \
+ (SCM_CONS(SCM_VALUECONS_CAR(a), \
+ SCM_VALUECONS_CDR(a))))
+#define SCM_VALUECONS_CAR(a) (SCM_AS_VALUEPACKET(a)->obj.cons.car)
+#define SCM_VALUECONS_CDR(a) (SCM_AS_VALUEPACKET(a)->obj.cons.cdr)
#else /* SCM_USE_VALUECONS */
#define SCM_VALUEPACKETP(a) (SCM_TYPE(a) == ScmValuePacket)
#define SCM_ENTYPE_VALUEPACKET(a) (SCM_ENTYPE((a), ScmValuePacket))
More information about the uim-commit
mailing list