Shrink hashtb.{bin,com,bci} further with judicious use of syntax.
authorTaylor R Campbell <campbell@mumble.net>
Sun, 5 Sep 2010 18:57:11 +0000 (18:57 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Sun, 5 Sep 2010 18:57:11 +0000 (18:57 +0000)
src/runtime/hashtb.scm

index fe6b4fa8a181e1a0055ab515cf2fe9b4db81db01..97481d412e40193cb753515bae5fcd58ba1baf8a 100644 (file)
@@ -1101,7 +1101,31 @@ USA.
     (make-table-type key-hash key=? rehash-after-gc? compute-hash!
                     entry-type)))
 
-(define-integrable (open-type-constructor entry-type)
+;;; Using syntax rather than integrable procedures avoids some
+;;; unnecessary duplicates of the great pile of hash table code.  This
+;;; is a non-hygienic kludge, so don't use it outside this file.  It's
+;;; non-hygienic because of a collection of bugs: SYNTAX-RULES and
+;;; DECLARE don't mix, hygienically macro-generated macro definitions
+;;; aren't fasdumpable...
+
+(define-syntax define-integrableish
+  (sc-macro-transformer
+   (lambda (form environment)
+     environment                       ;ignore
+     (let ((name (caadr form))
+          (parameters (cdadr form))
+          (body (cddr form)))
+       `(DEFINE-SYNTAX ,name
+         (SC-MACRO-TRANSFORMER
+          (LAMBDA (FORM ENVIRONMENT)
+            (CONS '(NAMED-LAMBDA (,name ,@parameters)
+                     (DECLARE (INTEGRATE ,@parameters))
+                     ,@body)
+                  (MAP (LAMBDA (SUBFORM)
+                         (CLOSE-SYNTAX SUBFORM ENVIRONMENT))
+                       (CDR FORM))))))))))
+
+(define-integrableish (open-type-constructor entry-type)
   (declare (integrate-operator %make-hash-table-type make-table-type))
   (declare (integrate-operator make-method:get make-method:put!))
   (declare (integrate-operator make-method:modify! make-method:remove!))
@@ -1117,12 +1141,12 @@ USA.
       (make-table-type key-hash key=? rehash-after-gc? compute-hash!
                       entry-type))))
 
-(define-integrable (open-type-constructor! entry-type)
+(define-integrableish (open-type-constructor! entry-type)
   (hash-table/put! hash-table-type-constructors
                   entry-type
                   (open-type-constructor entry-type)))
 
-(define-integrable (open-type key-hash key=? rehash-after-gc? entry-type)
+(define-integrableish (open-type key-hash key=? rehash-after-gc? entry-type)
   (declare (integrate-operator %make-hash-table-type make-table-type))
   (declare (integrate-operator compute-address-hash compute-non-address-hash))
   (declare (integrate-operator make-method:get make-method:put!))
@@ -1135,7 +1159,7 @@ USA.
                       (compute-non-address-hash key-hash))
                   entry-type))
 
-(define-integrable (open-type! key-hash key=? rehash-after-gc? entry-type)
+(define-integrableish (open-type! key-hash key=? rehash-after-gc? entry-type)
   (let ((hash-table-type
         (open-type key-hash key=? rehash-after-gc? entry-type)))
     (memoize-hash-table-type! key-hash key=? rehash-after-gc? entry-type