Avoiding cycles in everything but closures

original commit: 7bffbc31a2
This commit is contained in:
Blake Johnson 2010-10-07 13:24:25 -06:00 committed by Jay McCarthy
parent 7aac10e938
commit 6b8a9b0861
3 changed files with 37 additions and 18 deletions

View File

@ -76,6 +76,7 @@ Here's the idea:
(define merged-source-path (path-add-suffix file-to-batch #".merged.rkt")) (define merged-source-path (path-add-suffix file-to-batch #".merged.rkt"))
(define merged-struct-path (path-add-suffix file-to-batch #".mergeds.rkt"))
(define-values (merged-source-base merged-source-name _1) (split-path merged-source-path)) (define-values (merged-source-base merged-source-name _1) (split-path merged-source-path))
(define merged-zo-path (build-compiled-path merged-source-base (path-add-suffix merged-source-name #".zo"))) (define merged-zo-path (build-compiled-path merged-source-base (path-add-suffix merged-source-name #".zo")))
@ -113,6 +114,13 @@ Here's the idea:
(pretty-print (decompile batch-final))) (pretty-print (decompile batch-final)))
#:exists 'replace) #:exists 'replace)
(log-debug "Writing merged struct~n")
(with-output-to-file
merged-struct-path
(lambda ()
(pretty-write batch-final))
#:exists 'replace)
(log-debug "Writing merged zo~n") (log-debug "Writing merged zo~n")
(void (void
(with-output-to-file (with-output-to-file

View File

@ -68,20 +68,22 @@
(out-compilation-top (out-compilation-top
(λ (v #:error? [error? #f]) (λ (v #:error? [error? #f])
(cond (cond
[(hash? v) (error 'create-symbol-table "current type trace: ~a" (current-type-trace))] [(hash? v) (error 'create-symbol-table "current type trace: ~a" (current-type-trace))]
[(closure? v) [(closure? v)
(let ([pos (share! v)]) (let ([pos (share! v)])
(if (encountered? v) (if (encountered? v)
pos pos
(encounter! v)))] (encounter! v)))]
[error? ; If we would error if this were not present, then we must share it [(member v (rest (continuation-mark-set->list (current-continuation-marks) 'cycle)))
(encounter! v) #f]
(share! v)] [error? ; If we would error if this were not present, then we must share it
[(encountered? v) (encounter! v)
(share! v)] (share! v)]
[else [(encountered? v)
(encounter! v)])) (share! v)]
[else
(encounter! v)]))
(λ (v) (λ (v)
(unencounter! v)) (unencounter! v))
(open-output-nowhere)) (open-output-nowhere))
@ -455,7 +457,7 @@
(define (shareable? v) (define (shareable? v)
(define never-share-this? (define never-share-this?
(or-pred? v char? maybe-same-as-fixnum? empty? boolean? void? hash? )) (or-pred? v char? maybe-same-as-fixnum? empty? boolean? void? hash?))
(define always-share-this? (define always-share-this?
(or-pred? v closure?)) (or-pred? v closure?))
(or always-share-this? (or always-share-this?
@ -481,11 +483,18 @@
(define-syntax with-type-trace (define-syntax with-type-trace
(syntax-rules () (syntax-rules ()
[(_ v body ...) [(_ v body ...)
#;(begin body ...) (begin body ...)
(with-continuation-mark 'zo (typeof v) #;(with-continuation-mark 'zo (typeof v)
(begin0 (begin body ...) (void)))]))
(define-syntax with-cycle-check
(syntax-rules ()
[(_ v body ...)
(with-continuation-mark 'cycle v
(begin0 (begin body ...) (void)))])) (begin0 (begin body ...) (void)))]))
(define (out-anything v out) (define (out-anything v out)
(with-cycle-check v
(with-type-trace v (with-type-trace v
(out-shared (out-shared
v out v out
@ -861,7 +870,7 @@
(define bstr (get-output-bytes s)) (define bstr (get-output-bytes s))
(out-number (bytes-length bstr) out) (out-number (bytes-length bstr) out)
(out-bytes bstr out)] (out-bytes bstr out)]
[else (error 'out-anything "~s" (current-type-trace))]))))) [else (error 'out-anything "~s" (current-type-trace))]))))))
(define-struct module-decl (content)) (define-struct module-decl (content))

View File

@ -1046,6 +1046,8 @@
(for ([i (in-range 1 symtabsize)]) (for ([i (in-range 1 symtabsize)])
(read-sym cp i)) (read-sym cp i))
#;(for ([(i v) (in-dict (cport-symtab cp))])
(printf "~a = ~a\n" i (placeholder-get v)) )
(set-cport-pos! cp shared-size) (set-cport-pos! cp shared-size)
(make-reader-graph (make-reader-graph
(read-marshalled 'compilation-top-type cp)))) (read-marshalled 'compilation-top-type cp))))