guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 09/11: Add hacks around lack of allocation sinking


From: Andy Wingo
Subject: [Guile-commits] 09/11: Add hacks around lack of allocation sinking
Date: Sun, 29 Oct 2017 16:05:02 -0400 (EDT)

wingo pushed a commit to branch master
in repository guile.

commit f34abbc3968ef48763e428adb5b7d7d4f1b47813
Author: Andy Wingo <address@hidden>
Date:   Sun Oct 29 20:33:35 2017 +0100

    Add hacks around lack of allocation sinking
    
    * module/language/cps/compile-bytecode.scm (compile-function):
    * module/language/cps/cse.scm (compute-equivalent-subexpressions):
    * module/language/cps/effects-analysis.scm:
    * module/language/cps/primitives.scm (*macro-instruction-arities*):
    * module/language/cps/specialize-numbers.scm (compute-specializable-vars):
    * module/language/cps/types.scm: Add new variants of u64->scm and
      s64->scm that can't be replaced by CSE's auxiliary definitions, so we
      can sink unlikely allocations to side branches.  This is a hack until
      we can get allocation sinking working
---
 module/language/cps/compile-bytecode.scm   | 4 ++--
 module/language/cps/cse.scm                | 4 ++--
 module/language/cps/effects-analysis.scm   | 2 ++
 module/language/cps/primitives.scm         | 4 +++-
 module/language/cps/specialize-numbers.scm | 1 +
 module/language/cps/types.scm              | 2 ++
 6 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/module/language/cps/compile-bytecode.scm 
b/module/language/cps/compile-bytecode.scm
index 055cc83..ea46f68 100644
--- a/module/language/cps/compile-bytecode.scm
+++ b/module/language/cps/compile-bytecode.scm
@@ -221,13 +221,13 @@
          (emit-scm->u64/truncate asm (from-sp dst) (from-sp (slot src))))
         (($ $primcall 'load-u64 (src))
          (emit-load-u64 asm (from-sp dst) (constant src)))
-        (($ $primcall 'u64->scm (src))
+        (($ $primcall (or 'u64->scm 'u64->scm/unlikely) (src))
          (emit-u64->scm asm (from-sp dst) (from-sp (slot src))))
         (($ $primcall 'scm->s64 (src))
          (emit-scm->s64 asm (from-sp dst) (from-sp (slot src))))
         (($ $primcall 'load-s64 (src))
          (emit-load-s64 asm (from-sp dst) (constant src)))
-        (($ $primcall 's64->scm (src))
+        (($ $primcall (or 's64->scm 's64->scm/unlikely) (src))
          (emit-s64->scm asm (from-sp dst) (from-sp (slot src))))
         (($ $primcall 'bv-length (bv))
          (emit-bv-length asm (from-sp dst) (from-sp (slot bv))))
diff --git a/module/language/cps/cse.scm b/module/language/cps/cse.scm
index fb27635..2623e4a 100644
--- a/module/language/cps/cse.scm
+++ b/module/language/cps/cse.scm
@@ -310,7 +310,7 @@ false.  It could be that both true and false proofs are 
available."
              (match defs
                ((u64)
                 (add-def! `(primcall u64->scm ,u64) scm))))
-            (('primcall 'u64->scm u64)
+            (('primcall (or 'u64->scm 'u64->scm/unlikely) u64)
              (match defs
                ((scm)
                 (add-def! `(primcall scm->u64 ,scm) u64)
@@ -319,7 +319,7 @@ false.  It could be that both true and false proofs are 
available."
              (match defs
                ((s64)
                 (add-def! `(primcall s64->scm ,s64) scm))))
-            (('primcall 's64->scm s64)
+            (('primcall (or 's64->scm 's64->scm/unlikely) s64)
              (match defs
                ((scm)
                 (add-def! `(primcall scm->s64 ,scm) s64))))
diff --git a/module/language/cps/effects-analysis.scm 
b/module/language/cps/effects-analysis.scm
index 87f8235..675b524 100644
--- a/module/language/cps/effects-analysis.scm
+++ b/module/language/cps/effects-analysis.scm
@@ -381,9 +381,11 @@ is or might be a read or a write to the same location as 
A."
   ((scm->u64/truncate _)                                       &type-check)
   ((load-u64 _))
   ((u64->scm _))
+  ((u64->scm/unlikely _))
   ((scm->s64 _)                                                &type-check)
   ((load-s64 _))
   ((s64->scm _))
+  ((s64->scm/unlikely _))
   ((untag-fixnum _)))
 
 ;; Bytevectors.
diff --git a/module/language/cps/primitives.scm 
b/module/language/cps/primitives.scm
index 1437a4e..f5966a5 100644
--- a/module/language/cps/primitives.scm
+++ b/module/language/cps/primitives.scm
@@ -66,7 +66,9 @@
     (bytevector-ieee-double-native-set! . bv-f64-set!)))
 
 (define *macro-instruction-arities*
-  '((cache-current-module! . (0 . 2))
+  '((u64->scm/unlikely . (1 . 1))
+    (s64->scm/unlikely . (1 . 1))
+    (cache-current-module! . (0 . 2))
     (cached-toplevel-box . (1 . 3))
     (cached-module-box . (1 . 4))))
 
diff --git a/module/language/cps/specialize-numbers.scm 
b/module/language/cps/specialize-numbers.scm
index 67aea82..4a687e7 100644
--- a/module/language/cps/specialize-numbers.scm
+++ b/module/language/cps/specialize-numbers.scm
@@ -550,6 +550,7 @@ BITS indicating the significant bits needed for a variable. 
 BITS may be
   (define (exp-result-u64? exp)
     (match exp
       ((or ($ $primcall 'u64->scm (_))
+           ($ $primcall 'u64->scm/unlikely (_))
            ($ $const (and (? number?) (? exact-integer?)
                           (? (lambda (n) (<= 0 n #xffffffffffffffff))))))
        #t)
diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm
index 05f6a8d..6905959 100644
--- a/module/language/cps/types.scm
+++ b/module/language/cps/types.scm
@@ -862,6 +862,7 @@ minimum, and maximum."
   #t)
 (define-type-inferrer (u64->scm u64 result)
   (define-exact-integer! result (&min/0 u64) (&max/u64 u64)))
+(define-type-aliases u64->scm u64->scm/unlikely)
 
 (define-type-checker (scm->s64 scm)
   (check-type scm &exact-integer &s64-min &s64-max))
@@ -869,6 +870,7 @@ minimum, and maximum."
   (restrict! scm &exact-integer &s64-min &s64-max)
   (define! result &s64 (&min/s64 scm) (&max/s64 scm)))
 (define-type-aliases scm->s64 load-s64)
+(define-type-aliases s64->scm s64->scm/unlikely)
 
 (define-simple-type-checker (untag-fixnum &fixnum))
 (define-type-inferrer (untag-fixnum scm result)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]