From: Mark Wooding Date: Sun, 30 Aug 2015 09:58:38 +0000 (+0100) Subject: src/: Tweak handling of `va_list' pointers in generated functions. X-Git-Tag: 0.2.0~20 X-Git-Url: https://git.distorted.org.uk/~mdw/sod/commitdiff_plain/2bbe0f1d36d39db51085bf88612055e0b5743ffb?ds=sidebyside src/: Tweak handling of `va_list' pointers in generated functions. In method entries, effective method bodies, and delegation trampolines, the `va_list' argument is named `sod__ap', and a copy is made for invoking direct methods into a temporary called `sod__tmp_ap'. The name `sod__master_ap' is now only used in direct method argument lists and the `CALL_NEXT_METHOD' machinery. This reduces the amount of mangling of argument lists which needs to be done. It will also make some future changes a little easier. --- diff --git a/src/codegen-proto.lisp b/src/codegen-proto.lisp index f6cd4bd..e947a72 100644 --- a/src/codegen-proto.lisp +++ b/src/codegen-proto.lisp @@ -74,6 +74,8 @@ (make-instance 'temporary-name :tag "sod__ap")) (defparameter *sod-master-ap* (make-instance 'temporary-name :tag "sod__master_ap")) +(defparameter *sod-tmp-ap* + (make-instance 'temporary-name :tag "sod__tmp_ap")) ;;;-------------------------------------------------------------------------- ;;; Instructions. diff --git a/src/method-impl.lisp b/src/method-impl.lisp index 6508f57..e6368e7 100644 --- a/src/method-impl.lisp +++ b/src/method-impl.lisp @@ -419,15 +419,10 @@ ;; Effective method function details. (emf-name (effective-method-function-name method)) (ilayout-type (c-type (* (struct (ilayout-struct-tag class))))) - (emf-arg-tail (mapcar (lambda (arg) - (if (eq (argument-name arg) *sod-ap*) - (make-argument *sod-master-ap* - (c-type va-list)) - arg)) - (sod-message-no-varargs-tail message))) + (emf-arg-tail (sod-message-no-varargs-tail message)) (emf-type (c-type (fun (lisp return-type) ("sod__obj" (lisp ilayout-type)) - . (sod-message-no-varargs-tail message)))) + . emf-arg-tail))) ;; Method entry details. (chain-tails (remove-if-not (lambda (super) @@ -450,12 +445,12 @@ (make-convert-to-ilayout-inst class head "me")))) (varargs-prologue () - (ensure-var codegen *sod-master-ap* (c-type va-list)) + (ensure-var codegen *sod-ap* (c-type va-list)) (emit-inst codegen - (make-va-start-inst *sod-master-ap* + (make-va-start-inst *sod-ap* (argument-name parm-n)))) (varargs-epilogue () - (emit-inst codegen (make-va-end-inst *sod-master-ap*))) + (emit-inst codegen (make-va-end-inst *sod-ap*))) (finish-entry (tail) (let* ((head (sod-class-chain-head tail)) (name (method-entry-function-name method head)) diff --git a/src/method-proto.lisp b/src/method-proto.lisp index 17db6e9..8b3822a 100644 --- a/src/method-proto.lisp +++ b/src/method-proto.lisp @@ -252,8 +252,7 @@ CLASS where CLASS is the class on which the method was defined. If the message accepts a variable-length argument list then a copy of the - prevailing master argument pointer is provided in place of the - `:ellipsis'." + prevailing argument pointer is provided in place of the `:ellipsis'." (let* ((message (sod-method-message direct-method)) (class (sod-method-class direct-method)) @@ -267,14 +266,14 @@ (convert-stmts codegen target (c-type-subtype (sod-method-type direct-method)) (lambda (var) - (ensure-var codegen *sod-ap* (c-type va-list)) + (ensure-var codegen *sod-tmp-ap* (c-type va-list)) (emit-inst codegen - (make-va-copy-inst *sod-ap* - *sod-master-ap*)) + (make-va-copy-inst *sod-tmp-ap* + *sod-ap*)) (deliver-expr codegen var (make-call-inst function arguments)) (emit-inst codegen - (make-va-end-inst *sod-ap*)))) + (make-va-end-inst *sod-tmp-ap*)))) (deliver-expr codegen target (make-call-inst function arguments))))) (export 'ensure-ilayout-var) @@ -313,8 +312,7 @@ (return-type (c-type-subtype message-type)) (raw-args (sod-message-argument-tail message)) (arguments (if (varargs-message-p message) - (cons (make-argument *sod-master-ap* - (c-type va-list)) + (cons (make-argument *sod-ap* (c-type va-list)) (butlast raw-args)) raw-args))) (codegen-push codegen) @@ -378,7 +376,7 @@ (let* ((message (codegen-message codegen)) (argument-tail (if (varargs-message-p message) - (cons *sod-master-ap* basic-tail) + (cons *sod-tmp-ap* basic-tail) basic-tail))) (labels ((next-trampoline (method chain) (if (or kernel chain)