[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 04/11: Add missing compiler support for heap-object? pri
From: |
Andy Wingo |
Subject: |
[Guile-commits] 04/11: Add missing compiler support for heap-object? primcall et al. |
Date: |
Sun, 29 Oct 2017 16:05:01 -0400 (EDT) |
wingo pushed a commit to branch master
in repository guile.
commit c2fa345093ab79331d331b6765bf41a3da68eff1
Author: Andy Wingo <address@hidden>
Date: Sun Oct 29 14:35:19 2017 +0100
Add missing compiler support for heap-object? primcall et al.
* module/language/cps/effects-analysis.scm: Reorder effect-free
primitives. Add immediate predicates and heap-number?.
* module/language/cps/primitives.scm (*heap-type-predicates*): Add
heap-number?.
* module/language/cps/type-fold.scm (heap-number?): New folder.
* module/language/cps/types.scm (heap-number?): New inferrer.
---
module/language/cps/effects-analysis.scm | 24 +++++++++++++++++-------
module/language/cps/primitives.scm | 4 ++--
module/language/cps/type-fold.scm | 7 +++++++
module/language/cps/types.scm | 7 +++++++
4 files changed, 33 insertions(+), 9 deletions(-)
diff --git a/module/language/cps/effects-analysis.scm
b/module/language/cps/effects-analysis.scm
index 1cc03c0..cdb482c 100644
--- a/module/language/cps/effects-analysis.scm
+++ b/module/language/cps/effects-analysis.scm
@@ -263,24 +263,34 @@ is or might be a read or a write to the same location as
A."
;; Generic effect-free predicates.
(define-primitive-effects
- ((eq? . _))
- ((eqv? . _))
- ((equal? . _))
- ((pair? arg))
+ ((eq? x y))
+ ((equal? x y))
+ ((fixnum? arg))
+ ((char? arg))
+ ((eq-null? arg))
+ ((eq-nil? arg))
+ ((eq-false? arg))
+ ((eq-true? arg))
+ ((unspecified? arg))
+ ((undefined? arg))
+ ((eof-object? arg))
((null? arg))
- ((nil? arg ))
+ ((false? arg))
+ ((nil? arg))
+ ((heap-object? arg))
+ ((pair? arg))
((symbol? arg))
((variable? arg))
((vector? arg))
((struct? arg))
((string? arg))
((number? arg))
- ((char? arg))
((bytevector? arg))
((keyword? arg))
((bitvector? arg))
((procedure? arg))
- ((thunk? arg)))
+ ((thunk? arg))
+ ((heap-number? arg)))
;; Fluids.
(define-primitive-effects
diff --git a/module/language/cps/primitives.scm
b/module/language/cps/primitives.scm
index 71ce8de..e62acd3 100644
--- a/module/language/cps/primitives.scm
+++ b/module/language/cps/primitives.scm
@@ -95,12 +95,12 @@
string?
keyword?
bytevector?
- bitvector?))
+ bitvector?
+ heap-number?))
;; FIXME: Support these.
(define *other-predicates*
'(weak-vector?
- number?
hash-table?
pointer?
fluid?
diff --git a/module/language/cps/type-fold.scm
b/module/language/cps/type-fold.scm
index 2824625..f216aca 100644
--- a/module/language/cps/type-fold.scm
+++ b/module/language/cps/type-fold.scm
@@ -97,6 +97,13 @@
((type<=? type &immediate-types) (values #t #f))
(else (values #f #f))))
+(define-unary-branch-folder (heap-number? type min max)
+ (define &types (logior &bignum &flonum &fraction &complex))
+ (cond
+ ((zero? (logand type &types)) (values #t #f))
+ ((type<=? type &types) (values #t #t))
+ (else (values #f #f))))
+
;; All the cases that are in compile-bytecode.
(define-unary-type-predicate-folder pair? &pair)
(define-unary-type-predicate-folder symbol? &symbol)
diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm
index e07bb92..90611be 100644
--- a/module/language/cps/types.scm
+++ b/module/language/cps/types.scm
@@ -596,6 +596,13 @@ minimum, and maximum."
(logand &all-types (lognot &immediate-types)))
(restrict! val (if true? &heap-object-types &immediate-types) -inf.0 +inf.0))
+(define-predicate-inferrer (heap-number? val true?)
+ (define &heap-number-types
+ (logior &bignum &flonum &complex &fraction))
+ (define &other-types
+ (logand &all-types (lognot &heap-number-types)))
+ (restrict! val (if true? &heap-number-types &other-types) -inf.0 +inf.0))
+
(define-syntax-rule (define-simple-predicate-inferrer predicate type)
(define-predicate-inferrer (predicate val true?)
(let ((type (if true?
- [Guile-commits] branch master updated (9d1235a -> d1c69b5), Andy Wingo, 2017/10/29
- [Guile-commits] 01/11: Minor optimization compiling 'and', Andy Wingo, 2017/10/29
- [Guile-commits] 08/11: Add untag-fixnum instruction, Andy Wingo, 2017/10/29
- [Guile-commits] 10/11: Inline u64/scm comparisons, Andy Wingo, 2017/10/29
- [Guile-commits] 02/11: Rename "number" tag to "heap-number", Andy Wingo, 2017/10/29
- [Guile-commits] 03/11: Simplify lowering of branching primcalls to CPS, Andy Wingo, 2017/10/29
- [Guile-commits] 11/11: Remove compiler support for u64-scm comparisons, Andy Wingo, 2017/10/29
- [Guile-commits] 05/11: Lower eqv? and equal? to new instructions., Andy Wingo, 2017/10/29
- [Guile-commits] 04/11: Add missing compiler support for heap-object? primcall et al.,
Andy Wingo <=
- [Guile-commits] 07/11: Add compiler support for fixnum? primcall predicate, Andy Wingo, 2017/10/29
- [Guile-commits] 06/11: Add compiler support for s64 comparisons., Andy Wingo, 2017/10/29
- [Guile-commits] 09/11: Add hacks around lack of allocation sinking, Andy Wingo, 2017/10/29