Add O(1) ADD-TO-POPULATION!/UNSAFE to the runtime (unexported).
authorTaylor R Campbell <campbell@mumble.net>
Wed, 7 Jul 2010 19:34:05 +0000 (19:34 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Wed, 7 Jul 2010 19:34:05 +0000 (19:34 +0000)
This does not check whether the population already holds the object
to be added; hence it is unsafe.

Change MAKE-1D-TABLE and MAKE-THREAD to use it: newly allocated
objects are guaranteed not to be in the population.

src/runtime/poplat.scm
src/runtime/prop1d.scm
src/runtime/runtime.pkg
src/runtime/thread.scm

index 9e4e0b2069cce61baa31ced2e33bfd1a3028c4e8..5b937540349d41dea82628e37911b08b9855f116 100644 (file)
@@ -73,6 +73,12 @@ USA.
   (and (pair? object)
        (eq? (car object) population-tag)))
 
+(define (add-to-population!/unsafe population object)
+  (set-cdr! population
+           (system-pair-cons weak-cons-type
+                             (canonicalize object)
+                             (cdr population))))
+
 (define (add-to-population! population object)
   (let ((object (canonicalize object)))
     (let loop ((previous population) (this (cdr population)))
index 19a44523347af2563bea036c62fefdce99d48512..3a56dcbfd24b6ba168a0bfab41b7211865642d36 100644 (file)
@@ -43,7 +43,7 @@ USA.
 
 (define (make-1d-table)
   (let ((table (list 1d-table-tag)))
-    (add-to-population! population-of-1d-tables table)
+    (add-to-population!/unsafe population-of-1d-tables table)
     table))
 
 (define (1d-table? object)
index 354c3148a7101db40bd4e9d4f1dfca6f977111a0..063d4ca6e7b582b0936dc172bfe8dcc866a10231 100644 (file)
@@ -2955,6 +2955,8 @@ USA.
          map-over-population!
          population?
          remove-from-population!)
+  (export (runtime)
+         add-to-population!/unsafe)
   (initialization (initialize-package!)))
 
 (define-package (runtime pretty-printer)
index 9913529560a46b13a8475584e2ce8711477444ce..40d52be22d43836f25326555a7b9b7088b0b690a 100644 (file)
@@ -108,7 +108,7 @@ USA.
     (set-thread/continuation! thread continuation)
     (set-thread/root-state-point! thread
                                  (current-state-point state-space:local))
-    (add-to-population! thread-population thread)
+    (add-to-population!/unsafe thread-population thread)
     (thread-running thread)
     thread))