diff options
author | Andy Wingo <wingo@pobox.com> | 2015-07-27 15:11:09 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2015-07-27 15:19:45 +0200 |
commit | 48412395c6501d0f4f98494cfe20c1c18b14d7a6 (patch) | |
tree | 8cbceb95bd281da3db028153170c56befed33389 | |
parent | 90c11483e630dd4f1d04feae9d370304237aa6cb (diff) |
Add closure effects
* module/language/cps/effects-analysis.scm: Add closure effects, to
enable hoisting/CSE of free-ref/free-set!.
-rw-r--r-- | module/language/cps/effects-analysis.scm | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/module/language/cps/effects-analysis.scm b/module/language/cps/effects-analysis.scm index af1a5292e..778855de5 100644 --- a/module/language/cps/effects-analysis.scm +++ b/module/language/cps/effects-analysis.scm @@ -63,6 +63,7 @@ &struct &string &bytevector + &closure &object &field @@ -180,7 +181,10 @@ ;; Indicates that an expression depends on the contents of a ;; bytevector. We cannot be more precise, as bytevectors may alias ;; other bytevectors. - &bytevector) + &bytevector + + ;; Indicates a dependency on a free variable of a closure. + &closure) (define-inlinable (&field kind field) (ash (logior (ash field &memory-kind-bits) kind) &effect-kind-bits)) @@ -373,6 +377,17 @@ is or might be a read or a write to the same location as A." ((bv-f32-set! bv n x) (&write-object &bytevector) &type-check) ((bv-f64-set! bv n x) (&write-object &bytevector) &type-check)) +;; Closures. +(define (closure-field n constants) + (indexed-field &closure n constants)) +(define (read-closure-field n constants) + (logior &read (closure-field n constants))) +(define (write-closure-field n constants) + (logior &write (closure-field n constants))) +(define-primitive-effects* constants + ((free-ref closure idx) (read-closure-field idx constants)) + ((free-set! closure idx val) (write-closure-field idx constants))) + ;; Modules. (define-primitive-effects ((current-module) (&read-object &module)) |