Use new function from prim library

This commit is contained in:
Justin Ethier 2017-04-04 05:41:45 +00:00
parent 99bb171bb1
commit 0b76fbc8b2
2 changed files with 6 additions and 19 deletions

View file

@ -912,6 +912,11 @@
prim-call)))
;; Map from a Scheme function to a primitive, if possible.
;;
;; Inputs:
;; - Function symbol
;; - Number of arguments to the function
;;
;; Note the only reason to do this is to change from a CPS-style
;; function to one that can be inlined with no CPS, which yields
;; a significant speed improvement.

View file

@ -1194,24 +1194,6 @@
;; are renamed and if expressions always have an else clause.
;;
(define (prim-convert expr)
;; Map from a given function call to a primitive call, if possible
;; Inputs:
;; - Function symbol
;; - Number of arguments to the function
(define (func->prim/exact-args func-sym num-args)
(define mappings
'(
(char=? 2 Cyc-fast-char-eq )
(char>? 2 Cyc-fast-char-gt )
(char<? 2 Cyc-fast-char-lt )
(char>=? 2 Cyc-fast-char-gte)
(char<=? 2 Cyc-fast-char-lte)
))
(let ((m (assoc func-sym mappings)))
;(trace:error `(func->prim/exact-args ,func-sym ,num-args ,m))
(cond
((and m (= (cadr m) num-args)) (caddr m)) ;; Upgrade to a primitive
(else func-sym)))) ;; Remain a function
(define (conv ast)
(cond
((const? ast) ast)
@ -1240,7 +1222,7 @@
((app? ast)
(cond
((ref? (car ast))
`( ,(func->prim/exact-args (car ast) (- (length ast) 1))
`( ,(prim:func->prim (car ast) (- (length ast) 1))
,@(cdr ast)))
(else
(map conv ast))))