mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-12 07:50:26 -07:00
cmp: cmppass1-call: don't use with-stack for unoptimized long calls
WITH-STACK depends on FFI:C-INLINE so it can't be present in the first pass for standard operators. As a bonus disassembled result is less obfuscated.
This commit is contained in:
parent
a35b89866a
commit
fb95debd48
3 changed files with 29 additions and 18 deletions
|
|
@ -40,6 +40,23 @@
|
|||
(unwind-exit (call-unknown-global-loc nil loc (inline-args args) function-p))
|
||||
(close-inline-blocks)))
|
||||
|
||||
(defun c2fcall (c1form form args)
|
||||
(declare (ignore c1form))
|
||||
(let ((fun-var (make-temp-var)))
|
||||
(wt-nl-open-brace)
|
||||
(wt-nl "struct ecl_stack_frame _ecl_inner_frame_aux;")
|
||||
(wt-nl *volatile* "cl_object _ecl_inner_frame = ecl_stack_frame_open(cl_env_copy,(cl_object)&_ecl_inner_frame_aux,0);")
|
||||
(let ((*unwind-exit* `((STACK "_ecl_inner_frame") ,@*unwind-exit*)))
|
||||
(let ((*destination* fun-var))
|
||||
(c2expr* form))
|
||||
(dolist (inlined-arg (inline-args args))
|
||||
(wt-nl (produce-inline-loc (list inlined-arg) '(t) :void
|
||||
"ecl_stack_frame_push(_ecl_inner_frame,#0);" t t)))
|
||||
(wt-nl "cl_env_copy->values[0]=ecl_apply_from_stack_frame(_ecl_inner_frame," fun-var ");"))
|
||||
(wt-nl "ecl_stack_frame_close(_ecl_inner_frame);")
|
||||
(wt-nl-close-brace)
|
||||
(unwind-exit 'values)))
|
||||
|
||||
;;;
|
||||
;;; c2call-global:
|
||||
;;; ARGS is the list of arguments
|
||||
|
|
|
|||
|
|
@ -9,20 +9,12 @@
|
|||
|
||||
(in-package #:compiler)
|
||||
|
||||
(defun unoptimized-long-call (fun arguments)
|
||||
(let ((frame (gensym))
|
||||
(f-arg (gensym)))
|
||||
`(with-stack ,frame
|
||||
(let ((,f-arg ,fun))
|
||||
,@(loop for i in arguments collect `(stack-push ,frame ,i))
|
||||
(si::apply-from-stack-frame ,frame ,f-arg)))))
|
||||
|
||||
(defun unoptimized-funcall (fun arguments)
|
||||
(let ((l (length arguments)))
|
||||
(if (<= l si:c-arguments-limit)
|
||||
(make-c1form* 'CL:FUNCALL :sp-change t :side-effects t
|
||||
:args (c1expr fun) (c1args* arguments))
|
||||
(unoptimized-long-call fun arguments))))
|
||||
(if (<= (length arguments) si:c-arguments-limit)
|
||||
(make-c1form* 'CL:FUNCALL
|
||||
:sp-change t :side-effects t :args (c1expr fun) (c1args* arguments))
|
||||
(make-c1form* 'FCALL
|
||||
:sp-change t :side-effects t :args (c1expr fun) (c1args* arguments))))
|
||||
|
||||
(defun optimized-lambda-call (lambda-form arguments apply-p)
|
||||
(multiple-value-bind (bindings body)
|
||||
|
|
@ -125,13 +117,12 @@
|
|||
(default-apply fun arguments))))))
|
||||
|
||||
(defun c1call (fname args macros-allowed &aux fd success can-inline)
|
||||
(cond ((> (length args) si::c-arguments-limit)
|
||||
;; XXX: try to remove the first condition
|
||||
(cond ((> (length args) si:c-arguments-limit)
|
||||
(if (and macros-allowed
|
||||
(setf fd (cmp-macro-function fname)))
|
||||
(cmp-expand-macro fd (list* fname args))
|
||||
;; When it is a function and takes too many arguments, we need a
|
||||
;; special C form to call it with the stack (see with-stack).
|
||||
(unoptimized-long-call `(function ,fname) args)))
|
||||
(unoptimized-funcall `(function ,fname) args)))
|
||||
((setq fd (local-function-ref fname))
|
||||
(c1call-local fname fd args))
|
||||
((and macros-allowed ; macrolet
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
(CL:TAGBODY tag-var tag-body :pure)
|
||||
(CL:RETURN-FROM blk-var nonlocal value :side-effects)
|
||||
(CL:FUNCALL fun-value (arg-value*) :side-effects)
|
||||
(FCALL fun-value (arg-value*) :side-effects)
|
||||
(CALL-LOCAL obj-fun (arg-value*) :side-effects)
|
||||
(CALL-GLOBAL fun-name (arg-value*))
|
||||
(CL:CATCH catch-value body :side-effects)
|
||||
|
|
@ -216,6 +217,7 @@
|
|||
'((cl:block . c2block)
|
||||
(cl:return-from . c2return-from)
|
||||
(cl:funcall . c2funcall)
|
||||
(fcall . c2fcall)
|
||||
(call-global . c2call-global)
|
||||
(cl:catch . c2catch)
|
||||
(cl:unwind-protect . c2unwind-protect)
|
||||
|
|
@ -272,6 +274,8 @@
|
|||
(defconstant +p1-dispatch-alist+
|
||||
'((cl:block . p1block)
|
||||
(cl:return-from . p1return-from)
|
||||
(cl:funcall . p1trivial)
|
||||
(fcall . p1trivial)
|
||||
(call-global . p1call-global)
|
||||
(call-local . p1call-local)
|
||||
(cl:catch . p1catch)
|
||||
|
|
@ -300,7 +304,6 @@
|
|||
(ffi:c-inline . p1trivial)
|
||||
(ffi:c-progn . p1trivial)
|
||||
(cl:function . p1trivial)
|
||||
(cl:funcall . p1trivial)
|
||||
(cl:load-time-value . p1trivial)
|
||||
(make-form . p1trivial)
|
||||
(init-form . p1trivial)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue