mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-11 23:07:36 +02:00
WIP - emitting obj instead of closure
This commit is contained in:
parent
d0fccf44f8
commit
5d1ed67c48
1 changed files with 22 additions and 6 deletions
|
@ -1232,6 +1232,12 @@
|
||||||
(closure->fv exp))) ; Note these are not necessarily symbols, but in cc form
|
(closure->fv exp))) ; Note these are not necessarily symbols, but in cc form
|
||||||
(cv-name (mangle (gensym 'c)))
|
(cv-name (mangle (gensym 'c)))
|
||||||
(lid (allocate-lambda lam (c-compile-lambda lam trace cps?) cps?))
|
(lid (allocate-lambda lam (c-compile-lambda lam trace cps?) cps?))
|
||||||
|
(use-obj-instead-of-closure?
|
||||||
|
(with-fnc (ast:lambda-id lam) (lambda (fnc)
|
||||||
|
(and (adbf:well-known fnc) ;; Only optimize well-known functions
|
||||||
|
(equal? (length free-vars) 1) ;; Sanity check
|
||||||
|
(equal? (adbf:closure-size fnc) 1) ;; From closure conv
|
||||||
|
))))
|
||||||
(macro? (assoc (st:->var trace) (get-macros)))
|
(macro? (assoc (st:->var trace) (get-macros)))
|
||||||
(call/cc? (and (equal? (car trace) "scheme/base.sld")
|
(call/cc? (and (equal? (car trace) "scheme/base.sld")
|
||||||
(equal? (st:->var trace) 'call/cc)))
|
(equal? (st:->var trace) 'call/cc)))
|
||||||
|
@ -1239,6 +1245,12 @@
|
||||||
(if call/cc?
|
(if call/cc?
|
||||||
"1" ;; Special case, need to change runtime checks for call/cc
|
"1" ;; Special case, need to change runtime checks for call/cc
|
||||||
(number->string (compute-num-args lam))))
|
(number->string (compute-num-args lam))))
|
||||||
|
(create-object (lambda ()
|
||||||
|
TODO: seems broken, why are we getting NULL in the generated code???
|
||||||
|
(trace:error `(create-object free-vars ,free-vars))
|
||||||
|
(c-code/vars
|
||||||
|
(car free-vars)
|
||||||
|
(list))))
|
||||||
(create-nclosure (lambda ()
|
(create-nclosure (lambda ()
|
||||||
(string-append
|
(string-append
|
||||||
"closureN_type " cv-name ";\n"
|
"closureN_type " cv-name ";\n"
|
||||||
|
@ -1281,12 +1293,16 @@
|
||||||
cv-name ".num_args = " (number->string (compute-num-args lam)) ";"
|
cv-name ".num_args = " (number->string (compute-num-args lam)) ";"
|
||||||
)))))
|
)))))
|
||||||
;(trace:info (list 'JAE-DEBUG trace macro?))
|
;(trace:info (list 'JAE-DEBUG trace macro?))
|
||||||
|
(cond
|
||||||
|
(use-obj-instead-of-closure?
|
||||||
|
(create-object))
|
||||||
|
(else
|
||||||
(c-code/vars
|
(c-code/vars
|
||||||
(string-append "&" cv-name)
|
(string-append "&" cv-name)
|
||||||
(list
|
(list
|
||||||
(if (> (length free-vars) 0)
|
(if (> (length free-vars) 0)
|
||||||
(create-nclosure)
|
(create-nclosure)
|
||||||
(create-mclosure))))))
|
(create-mclosure))))))))
|
||||||
|
|
||||||
; c-compile-formals : list[symbol] -> string
|
; c-compile-formals : list[symbol] -> string
|
||||||
(define (c-compile-formals formals type)
|
(define (c-compile-formals formals type)
|
||||||
|
|
Loading…
Add table
Reference in a new issue