This commit is contained in:
Justin Ethier 2018-10-23 12:16:33 -04:00
parent c39183500a
commit d0564e991e

View file

@ -947,36 +947,34 @@
(adbf:calls-self? ast-fnc) (adbf:calls-self? ast-fnc)
(self-closure-call? fun (car (adbf:all-params ast-fnc))) (self-closure-call? fun (car (adbf:all-params ast-fnc)))
) )
;; TODO: need to emit all of this: (let* ((params (map mangle (cdr (adbf:all-params ast-fnc))))
;; arg reassignment ;; TODO: doesn't work, arg may contain non-CPS functions which have their own args...
;; GC check (w/fnc args and closure) - do after so we can just use args directly (args (map (lambda (s)
;; continue statement (string-replace-all s " " ""))
;; (string-split (c:body cargs) #\,)))
;; example: (reassignments (apply string-append
;; (map
;; if (stack_overflow(c_73374, (((gc_thread_data *)data)->stack_limit))) { (lambda (param arg)
;; //printf("starting GC\n"); (cond
;; object buf[3]; buf[0] = k_73154; buf[1] = l_7317_73101;buf[2] = a_7318_73102; ((equal? param arg) "") ;; No need to reassign
;; GC(data, self_73251, buf, argc); (else
;; } (string-append
;;//return_closcall3(data, car(((closureN)self_73251)->elements[0]), k_73154, Cyc_cddr(data, l_7317_73101), c_73374); param " = " arg ";\n"))))
;; // same, no need to reassign: k_73154 = k_73154; params
;; l_7317_73101 = Cyc_cddr(data, l_7317_73101); args))
;; a_7318_73102 = c_73374; ))
;; continue; ;(for-each
; (lambda (param arg)
;; TODO: how to handle varargs (maybe we don't)?? ; (trace:error `(JAE ,param = ,arg)))
(for-each ; params
(lambda (param arg) ; args)
(trace:error `(JAE ,param = ,arg)))
(cdr (adbf:all-params ast-fnc))
(string-split (c:body cargs) #\,))
(c-code (c-code
(string-append (string-append
(c:allocs->str (c:allocs cfun) "\n") (c:allocs->str (c:allocs cfun) "\n")
(c:allocs->str (c:allocs cargs) "\n") (c:allocs->str (c:allocs cargs) "\n")
;; TODO: reassign args ;; TODO: reassign args
reassignments
;; TODO: consider passing in a "top" instead of always calling alloca in macro below: ;; TODO: consider passing in a "top" instead of always calling alloca in macro below:
"continue_or_gc" (number->string (c:num-args cargs)) "continue_or_gc" (number->string (c:num-args cargs))
"(data," "(data,"
@ -985,6 +983,7 @@
(c:body cargs) (c:body cargs)
");" ");"
))) )))
)
((and wkf fnc ((and wkf fnc
*optimize-well-known-lambdas* *optimize-well-known-lambdas*