Changeset 9127


Ignore:
Timestamp:
Apr 10, 2008, 5:48:51 AM (11 years ago)
Author:
rme
Message:

Implement %clone-x86-function, replace-function-code. (These are almost
exactly the same and the x8664 versions, and should probably be merged.)

%apply-lexpr-tail-wise: do the register shuffle...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ia32/level-0/X86/X8632/x8632-def.lisp

    r8906 r9127  
    6868  (box-fixnum imm0 arg_z)
    6969  (single-value-return))
     70
     71;;; XXX probably should unify these next two with the x8664 versions.
     72
     73;;; Make a new function, with PROTO's code and the specified immediates.
     74;;; IMMEDIATES should contain lfun-bits as the last element.
     75(defun %clone-x86-function (proto &rest immediates)
     76  (declare (dynamic-extent immediates))
     77  (let* ((protov (%function-to-function-vector proto))
     78         (code-words (%function-code-words proto))
     79         (numimms (length immediates))
     80         (newv (allocate-typed-vector :function (the fixnum (+ code-words numimms)))))
     81    (declare (fixnum code-words numimms))
     82    (%copy-ivector-to-ivector protov 0 newv 0 (the fixnum (ash code-words target::word-shift)))
     83    (%update-self-references newv)
     84    (do* ((k code-words (1+ k))
     85          (imms immediates (cdr imms)))
     86         ((null imms) (%function-vector-to-function newv))
     87      (declare (fixnum k) (list imms))
     88      (setf (%svref newv k) (car imms)))))
     89
     90(defun replace-function-code (target proto)
     91  (let* ((target-words (%function-code-words target))
     92         (proto-words (%function-code-words proto)))
     93    (declare (fixnum target-words proto-words))
     94    (if (= target-words proto-words)
     95      (progn
     96        (%copy-ivector-to-ivector (%function-to-function-vector proto)
     97                                  0
     98                                  (%function-to-function-vector target)
     99                                  0
     100                                  (the fixnum (ash target-words
     101                                                   target::word-shift)))
     102        (%update-self-references target)
     103        target)
     104      (error "Code size mismatch: target = ~s, proto = ~s"
     105             target-words proto-words))))
    70106
    71107(defx8632lapfunction %get-kernel-global-from-offset ((offset arg_z))
     
    387423;;; entry must be in %rbp.
    388424(defx8632lapfunction %apply-lexpr-tail-wise ((method arg_y) (args arg_z))
    389   (int ($ 3))
    390425  (addl ($ x8632::node-size) (% esp))   ; discard extra return address
    391426  (movl (% method) (% xfn))             ;temp1
     
    394429  (movl (@ x8632::lisp-frame.return-address (% ebp)) (% temp0))
    395430  (movl (@ 0 (% ebp)) (% ebp))
    396   (rcmpl (% nargs) ($ '2))
     431  (rcmpl (% imm0) ($ '2))
    397432  (jbe @pop-regs)
    398433  ;; More than 2 args; some must have been pushed by caller,
     
    402437  (jmp @popped)
    403438  @pop-regs
    404   (rcmpl (% nargs) ($ '1))
     439  (rcmpl (% imm0) ($ '1))
    405440  (jb @discard)
    406441  (ja @pop2)
     
    414449  @popped
    415450  (push (% temp0))                      ;return address
    416   (jmp (% xfn)))
     451  (movl (% xfn) (% temp0))              ;temp1 is also nargs
     452  (movl (% imm0) (% nargs))
     453  (jmp (% temp0)))
    417454
    418455(defun closure-function (fun)
Note: See TracChangeset for help on using the changeset viewer.