[uim-commit] r2995 - branches/r5rs/sigscheme/src

yamaken at freedesktop.org yamaken at freedesktop.org
Wed Jan 25 23:19:54 PST 2006


Author: yamaken
Date: 2006-01-25 23:19:49 -0800 (Wed, 25 Jan 2006)
New Revision: 2995

Modified:
   branches/r5rs/sigscheme/src/storage-compact.h
   branches/r5rs/sigscheme/src/storage-fatty.h
Log:
* sigscheme/src/storage-fatty.h
  - (struct ScmCell_):
    * Change type of 'gcmark' to char
    * Add 'immutable'
  - (SCM_MUTABLEP, SCM_SET_MUTABLE, SCM_SET_IMMUTABLE): New macro
  - (SCM_INT_MSB, SCM_STRING_MUTABILITY_MASK, SCM_STRING_MUTABLE):
    Removed
  - (SCM_SAL_STRING_LEN, SCM_SAL_STRING_SET_LEN,
    SCM_SAL_STRING_MUTABLEP, SCM_SAL_STRING_SET_MUTABLE,
    SCM_SAL_STRING_SET_IMMUTABLE): Simplify with new mutability macros
* sigscheme/src/storage-compact.h
  - Copy the old implementation of string mutability from
    storage-fatty.h for reference


Modified: branches/r5rs/sigscheme/src/storage-compact.h
===================================================================
--- branches/r5rs/sigscheme/src/storage-compact.h	2006-01-26 06:23:13 UTC (rev 2994)
+++ branches/r5rs/sigscheme/src/storage-compact.h	2006-01-26 07:19:49 UTC (rev 2995)
@@ -888,6 +888,48 @@
 #define SCM_SAL_STRING_SET_LEN(a, val)          \
     SCM_OTHERS_SET_CDR_VAL((a), STRING, (val))
 
+#if 0
+/* For reference: a implementation of string mutability for storage-fatty */
+
+/* MSB (sign bit) of obj.string.len of a string object holds its
+ * mutability. The attribute is stored into there since:
+ *
+ * - efficient due to single-op sign detection
+ *
+ * - string length must be representable by a scheme integer object
+ * - string length is always zero or positive
+ * - thus the sign bit is always empty
+ *
+ * - enables convenience debugging with displaying the raw str
+ * - tagged pointer approach prevents leak detection
+ * - tagged pointer approach brings alignment restriction
+ */
+#define SCM_INT_MSB                    (~((scm_uint_t)-1 >> 1))
+#define SCM_STRING_MUTABILITY_MASK     SCM_INT_MSB
+#define SCM_STRING_MUTABLE             SCM_INT_MSB
+#define SCM_SAL_STRINGP(o)             (SCM_TYPE(o) == ScmString)
+#define SCM_SAL_ENTYPE_STRING(o)       (SCM_ENTYPE((o), ScmString))
+#define SCM_SAL_STRING_STR(o)          (SCM_AS_STRING(o)->obj.string.str)
+#define SCM_SAL_STRING_SET_STR(o, val)                                       \
+    (SCM_AS_STRING(o)->obj.string.str = (val))
+#define SCM_SAL_STRING_LEN(o)                                                \
+    ((scm_int_t)(SCM_AS_STRING(o)->obj.string.len                            \
+                 & ~SCM_STRING_MUTABILITY_MASK))
+#define SCM_SAL_STRING_SET_LEN(o, _len)                                      \
+    (SCM_AS_STRING(o)->obj.string.len                                        \
+     = (_len) | (scm_int_t)(SCM_AS_STRING(o)->obj.string.len                 \
+                            & SCM_STRING_MUTABILITY_MASK))
+#define SCM_SAL_STRING_MUTABLEP(o)                                           \
+    (SCM_AS_STRING(o)->obj.string.len < 0)
+#define SCM_SAL_STRING_SET_MUTABLE(o)                                        \
+    (SCM_AS_STRING(o)->obj.string.len                                        \
+     = (scm_int_t)(SCM_AS_STRING(o)->obj.string.len | SCM_STRING_MUTABLE))
+#define SCM_SAL_STRING_SET_IMMUTABLE(o)                                      \
+    (SCM_AS_STRING(o)->obj.string.len                                        \
+     = (scm_int_t)(SCM_AS_STRING(o)->obj.string.len                          \
+                   & ~SCM_STRING_MUTABILITY_MASK))
+#endif /* 0 */
+
 /*
  * Vector
  */

Modified: branches/r5rs/sigscheme/src/storage-fatty.h
===================================================================
--- branches/r5rs/sigscheme/src/storage-fatty.h	2006-01-26 06:23:13 UTC (rev 2994)
+++ branches/r5rs/sigscheme/src/storage-fatty.h	2006-01-26 07:19:49 UTC (rev 2995)
@@ -80,7 +80,7 @@
     union {
         struct {
             enum ScmObjType type;
-            scm_bool gcmark;
+            char gcmark, immutable, pad2, pad3;
         } v;
 
         /* to align against 64-bit primitives */
@@ -259,6 +259,9 @@
 /* ScmObj Global Attribute */
 #define SCM_SAL_TYPE(o)        ((o)->attr.v.type)
 #define SCM_ENTYPE(o, objtype) ((o)->attr.v.type = (objtype))
+#define SCM_MUTABLEP(o)        (!(o)->attr.v.immutable)
+#define SCM_SET_MUTABLE(o)     ((o)->attr.v.immutable = scm_false)
+#define SCM_SET_IMMUTABLE(o)   ((o)->attr.v.immutable = scm_true)
 
 /* Real Accessors */
 #define SCM_SAL_NUMBERP(o)             SCM_SAL_INTP(o)
@@ -293,43 +296,15 @@
 #define SCM_SAL_CHAR_VALUE(o)          (SCM_AS_CHAR(o)->obj.character.value)
 #define SCM_SAL_CHAR_SET_VALUE(o, val) (SCM_CHAR_VALUE(o) = (val))
 
-/* MSB (sign bit) of obj.string.len of a string object holds its
- * mutability. The attribute is stored into there since:
- *
- * - efficient due to single-op sign detection
- *
- * - string length must be representable by a scheme integer object
- * - string length is always zero or positive
- * - thus the sign bit is always empty
- *
- * - enables convenience debugging with displaying the raw str
- * - tagged pointer approach prevents leak detection
- * - tagged pointer approach brings alignment restriction
- */
-#define SCM_INT_MSB                    (~((scm_uint_t)-1 >> 1))
-#define SCM_STRING_MUTABILITY_MASK     SCM_INT_MSB
-#define SCM_STRING_MUTABLE             SCM_INT_MSB
-#define SCM_SAL_STRINGP(o)             (SCM_TYPE(o) == ScmString)
-#define SCM_SAL_ENTYPE_STRING(o)       (SCM_ENTYPE((o), ScmString))
-#define SCM_SAL_STRING_STR(o)          (SCM_AS_STRING(o)->obj.string.str)
-#define SCM_SAL_STRING_SET_STR(o, val)                                       \
-    (SCM_AS_STRING(o)->obj.string.str = (val))
-#define SCM_SAL_STRING_LEN(o)                                                \
-    ((scm_int_t)(SCM_AS_STRING(o)->obj.string.len                            \
-                 & ~SCM_STRING_MUTABILITY_MASK))
-#define SCM_SAL_STRING_SET_LEN(o, _len)                                      \
-    (SCM_AS_STRING(o)->obj.string.len                                        \
-     = (_len) | (scm_int_t)(SCM_AS_STRING(o)->obj.string.len                 \
-                            & SCM_STRING_MUTABILITY_MASK))
-#define SCM_SAL_STRING_MUTABLEP(o)                                           \
-    (SCM_AS_STRING(o)->obj.string.len < 0)
-#define SCM_SAL_STRING_SET_MUTABLE(o)                                        \
-    (SCM_AS_STRING(o)->obj.string.len                                        \
-     = (scm_int_t)(SCM_AS_STRING(o)->obj.string.len | SCM_STRING_MUTABLE))
-#define SCM_SAL_STRING_SET_IMMUTABLE(o)                                      \
-    (SCM_AS_STRING(o)->obj.string.len                                        \
-     = (scm_int_t)(SCM_AS_STRING(o)->obj.string.len                          \
-                   & ~SCM_STRING_MUTABILITY_MASK))
+#define SCM_SAL_STRINGP(o)              (SCM_TYPE(o) == ScmString)
+#define SCM_SAL_ENTYPE_STRING(o)        (SCM_ENTYPE((o), ScmString))
+#define SCM_SAL_STRING_STR(o)           (SCM_AS_STRING(o)->obj.string.str)
+#define SCM_SAL_STRING_SET_STR(o, val)  (SCM_STRING_STR(o) = (val))
+#define SCM_SAL_STRING_LEN(o)           (SCM_AS_STRING(o)->obj.string.len)
+#define SCM_SAL_STRING_SET_LEN(o, _len) (SCM_STRING_LEN(o) = (_len))
+#define SCM_SAL_STRING_MUTABLEP(o)      (SCM_MUTABLEP(o))
+#define SCM_SAL_STRING_SET_MUTABLE(o)   (SCM_SET_MUTABLE(o))
+#define SCM_SAL_STRING_SET_IMMUTABLE(o) (SCM_SET_IMMUTABLE(o))
 
 #define SCM_SAL_FUNCP(o)                   (SCM_TYPE(o) == ScmFunc)
 #define SCM_SAL_ENTYPE_FUNC(o)             (SCM_ENTYPE((o), ScmFunc))



More information about the uim-commit mailing list