mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 16:57:35 +02:00
WIP
This commit is contained in:
parent
11cb6579b3
commit
c733e440d4
1 changed files with 20 additions and 1 deletions
|
@ -468,10 +468,19 @@
|
||||||
(not (adbv:reassigned? var))
|
(not (adbv:reassigned? var))
|
||||||
))))
|
))))
|
||||||
(ast:lambda-formals->list (car exp)))
|
(ast:lambda-formals->list (car exp)))
|
||||||
|
;; Check all args are valid primitives that can be inlined
|
||||||
(every
|
(every
|
||||||
(lambda (arg)
|
(lambda (arg)
|
||||||
(and (prim-call? arg)
|
(and (prim-call? arg)
|
||||||
(not (prim:cont? (car arg)))))
|
(not (prim:cont? (car arg)))
|
||||||
|
;; Disallow primitives that allocate a new obj,
|
||||||
|
;; because if the object is mutated all copies
|
||||||
|
;; must be modified.
|
||||||
|
;;
|
||||||
|
;; TODO: Technically this could be allowed if
|
||||||
|
;; there is only one reference of the variable
|
||||||
|
;(not (prim-creates-mutable-obj? (car arg)))
|
||||||
|
))
|
||||||
(cdr exp))
|
(cdr exp))
|
||||||
(inline-prim-call?
|
(inline-prim-call?
|
||||||
(ast:lambda-body (car exp))
|
(ast:lambda-body (car exp))
|
||||||
|
@ -510,6 +519,16 @@
|
||||||
(else '())))
|
(else '())))
|
||||||
exps)))
|
exps)))
|
||||||
|
|
||||||
|
;; Does the given primitive return a new instance of an object that
|
||||||
|
;; can be mutated?
|
||||||
|
;;
|
||||||
|
;; TODO: strings are a problem because there are
|
||||||
|
;; a lot of primitives that allocate them fresh!
|
||||||
|
(define (prim-creates-mutable-obj? prim)
|
||||||
|
(member
|
||||||
|
prim
|
||||||
|
'(cons make-vector make-bytevector)))
|
||||||
|
|
||||||
;; Find variables passed to a primitive
|
;; Find variables passed to a primitive
|
||||||
(define (prim-call->arg-variables exp)
|
(define (prim-call->arg-variables exp)
|
||||||
(filter symbol? (cdr exp)))
|
(filter symbol? (cdr exp)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue