mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-04-27 19:50:44 -07:00
cmp: resurrect a previously removed optimization
The optimization allows the compiler to use more precise type
information. This can be used to remove unnecessary boxing of
variables, see e.g. the disassembly of the following code:
(lambda (i)
(declare (fixnum i))
(code-char (mod i 128)))
The optimization was removed in commit
c7da5bc919. The promised FCALL-ARG
destination has not been implemented so far, thus we restore the old
implementation for now.
This commit is contained in:
parent
c20a53921e
commit
5426270f8b
1 changed files with 17 additions and 1 deletions
|
|
@ -108,6 +108,21 @@
|
|||
(let ((var-form (make-c1form 'VARIABLE form var nil)))
|
||||
(emit-inlined-temp-var var-form lisp-type (var-host-type var)))))))
|
||||
|
||||
(defun emit-inlined-fcall (form)
|
||||
(let ((args (c1form-arg 1 form))
|
||||
(fname (c1form-arg 2 form))
|
||||
(call-type (c1form-arg 3 form)))
|
||||
(if (not (and (eq call-type :global)
|
||||
(<= (length args) si:c-arguments-limit)))
|
||||
(emit-inlined-temp-var form t :object)
|
||||
(let* ((return-type (c1form-primary-type form))
|
||||
(fun (find fname *global-funs* :key #'fun-name :test #'same-fname-p))
|
||||
(loc (call-global-loc fname fun (inline-args args) return-type))
|
||||
(type (type-and return-type (loc-lisp-type loc)))
|
||||
(temp (make-inlined-temp-var type (loc-host-type loc))))
|
||||
(set-loc temp loc)
|
||||
(precise-loc-lisp-type temp type)))))
|
||||
|
||||
(defun emit-inlined-progn (form rest-forms)
|
||||
(let ((args (c1form-arg 0 form)))
|
||||
(loop with *destination* = 'TRASH
|
||||
|
|
@ -137,9 +152,10 @@
|
|||
(with-c1form-env (form form)
|
||||
(precise-loc-lisp-type
|
||||
(case (c1form-name form)
|
||||
(LOCATION (c1form-arg 0 form) )
|
||||
(LOCATION (c1form-arg 0 form))
|
||||
(VARIABLE (emit-inlined-variable form forms))
|
||||
(SETQ (emit-inlined-setq form forms))
|
||||
(FCALL (emit-inlined-fcall form))
|
||||
(PROGN (emit-inlined-progn form forms))
|
||||
(VALUES (emit-inlined-values form forms))
|
||||
(t (emit-inlined-temp-var form t :object)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue