Changeset 6478


Ignore:
Timestamp:
May 9, 2007, 7:42:03 AM (15 years ago)
Author:
gb
Message:

Handle new-style tras, other new-calling-sequence changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-0/X86/x86-def.lisp

    r4955 r6478  
    9292  (jmp-subprim .SPvalues))
    9393 
    94 
    9594       
    9695
     
    156155
    157156(defx86lapfunction %fixnum-ref ((fixnum arg_y) #| &optional |# (offset arg_z))
     157  (:arglist (fixnum &optional offset))
    158158  (check-nargs 1 2)
    159159  (cmpw ($ x8664::fixnumone) (% nargs))
     
    167167
    168168(defx86lapfunction %fixnum-ref-natural ((fixnum arg_y) #| &optional |# (offset arg_z))
     169  (:arglist (fixnum &optional offset))
    169170  (check-nargs 1 2)
    170171  (cmpw ($ x8664::fixnumone) (% nargs))
     
    178179
    179180(defx86lapfunction %fixnum-set ((fixnum arg_x) (offset arg_y) #| &optional |# (new-value arg_z))
     181  (:arglist (fixnum offset &optional newval))
    180182  (check-nargs 2 3)
    181183  (cmpw ($ '2) (% nargs))
     
    190192
    191193
    192 
    193194(defx86lapfunction %fixnum-set-natural ((fixnum arg_x) (offset arg_y) #| &optional |# (new-value arg_z))
     195  (:arglist (fixnum offset &optional newval))
    194196  (check-nargs 2 3)
    195197  (save-simple-frame)
     
    223225  (single-value-return))
    224226
    225 
     227;;; Look for "lea -nnnn(%rip),%fn" AT the tra; if that's present, use
     228;;; the dispacement -nnnn to find the function.  The end of the
     229;;; encoded displacement is
     230;;; x8664::recover-fn-from-rip-disp-offset (= 7) bytes from the tra.
    226231(defx86lapfunction %return-address-function ((r arg_z))
    227232  (extract-lisptag r imm0)
    228233  (cmpb ($ x8664::tag-tra) (% imm0.b))
    229234  (jne @fail)
    230   (movl (@ -4 (% r)) (% imm0.l))
    231   (testl (% imm0.l) (% imm0.l))
    232   (jle @fail)
    233   (subq (% imm0) (% arg_z))
     235  (cmpw ($ x8664::recover-fn-from-rip-word0) (@ (% r)))
     236  (jne @fail)
     237  (cmpb ($ x8664::recover-fn-from-rip-byte2) (@ 2 (% r)))
     238  (movslq (@ x8664::recover-fn-from-rip-disp-offset (% r)) (% imm0))
     239  (jne @fail)
     240  (lea (@ x8664::recover-fn-from-rip-length (% imm0) (% r)) (% arg_z))
    234241  (single-value-return)
    235242  @fail
     
    241248  (cmpb ($ x8664::tag-tra) (% imm0.b))
    242249  (jne @fail)
    243   (movl (@ -4 (% r)) (% imm0.l))
    244   (testl (% imm0.l) (% imm0.l))
    245   (jle @fail)
    246   (box-fixnum imm0 arg_z)
     250  (cmpw ($ x8664::recover-fn-from-rip-word0) (@ (% r)))
     251  (jne @fail)
     252  (cmpb ($ x8664::recover-fn-from-rip-byte2) (@ 2 (% r)))
     253  (movslq (@ x8664::recover-fn-from-rip-disp-offset (% r)) (% imm0))
     254  (jne @fail)
     255  (negq (% imm0))
     256  (leaq (@ (ash x8664::recover-fn-from-rip-length x8664::fixnumshift) (% imm0) 8) (% arg_z))
    247257  (single-value-return)
    248258  @fail
     
    252262;;; It's always been the case that the function associated with a
    253263;;; frame pointer is the caller of the function that "uses" that frame.
    254 (defx86lapfunction %cfp-lfun ((p arg_z))
    255   (ref-global ret1valaddr imm0)
    256   (movq (@ x8664::lisp-frame.return-address (% p)) (% arg_y))
    257   (cmpq (% imm0) (% arg_y))
    258   (cmoveq (@ x8664::lisp-frame.xtra (% p)) (% arg_y))
    259   (extract-lisptag arg_y imm0)
    260   (cmpb ($ x8664::tag-tra) (%b imm0))
    261   (jne @no)
    262   (movl (@ -4 (% arg_y)) (%l imm0))
    263   (testl (% imm0.l) (% imm0.l))
    264   (je @no)
    265   (subq (% imm0) (% arg_y))
    266   (box-fixnum imm0 arg_z)
    267   (movq (% rsp) (% temp0))
    268   (pushq (% arg_y))
    269   (pushq (% arg_z))
    270   (set-nargs 2)
    271   (jmp-subprim .SPvalues)
    272   @no
    273   (movq (% rsp) (% temp0))
    274   (pushq ($ x8664::nil-value))
    275   (pushq ($ x8664::nil-value))
    276   (set-nargs 2)
    277   (jmp-subprim .SPvalues))
     264(defun %cfp-lfun (p)
     265  (let* ((ra (%fixnum-ref p x8664::lisp-frame.return-address)))
     266    (if (eq ra (%get-kernel-global ret1valaddr))
     267      (setq ra (%fixnum-ref p x8664::lisp-frame.xtra)))
     268    (values (%return-address-function ra) (%return-address-offset ra))))
    278269
    279270
     
    350341  ;;   but preserves x866::xfn/x8664::next-method-context.
    351342  ;; Jump to the function in x8664::xfn.
     343  (popq (% ra0))
    352344  (movq (% magic) (% next-method-context))
    353345  (movq (% function) (% xfn))
     
    381373  (jmp @three)
    382374  @go
    383   (xchgq (% xfn) (% fn))
    384   (jmp (% fn)))
     375  (push (% ra0))
     376  (jmp (% xfn)))
    385377
    386378(defx86lapfunction %apply-with-method-context ((magic arg_x)
     
    393385  ;;   but preserves x8664::xfn/x8664::next-method-context.
    394386  ;; Jump to the function in x8664::xfn.
    395   ;; We need to inline the "spreadargz" operation, 'cause there's no
    396   ;; good place to keep %ra0.
     387  (pop (% ra0)) 
    397388  (movq (% magic) (% x8664::next-method-context))
    398389  (movq (% function) (% x8664::xfn))
     
    431422  (je @discard-and-go)
    432423  @go
    433   (xchgq (% xfn) (% fn))
    434   (jmp (% fn))
     424  (push (% ra0))
     425  (jmp (% xfn))
    435426  @bad
    436427  (addq (% imm0) (% rsp))
     
    447438;;; entry must be in %rbp.
    448439(defx86lapfunction %apply-lexpr-tail-wise ((method arg_y) (args arg_z))
     440  (addq ($ x8664::node-size) (% rsp))   ; discard extra return address
    449441  (movq (% method) (% xfn))
    450442  (movq (% args) (% rsp))
     
    478470  (discard-reserved-frame)
    479471  @popped
    480   (xchgq (% xfn) (% fn))
    481   (jmp (% fn)))
     472  (push (% ra0))
     473  (jmp (% xfn)))
    482474
    483475
     
    495487(defun apply+ (&lap function arg1 arg2 &rest other-args)
    496488  (x86-lap-function apply+ ()
     489   (:arglist (function arg1 arg2 &rest other-args))
    497490   (check-nargs 3 nil)
    498491   (cmpw ($ '3) (% nargs))
     492   (pop (% ra0))
    499493   (ja @no-frame)
    500494   (pushq ($ x8664::reserved-frame-marker))
     
    533527   @no-discard
    534528   (load-constant funcall temp0)
     529   (push (% ra0))
    535530   (jmp-subprim .SPfuncall)
    536531   @bad                                 ; error spreading list.
     
    541536   (jmp-subprim .SPksignalerr) ))
    542537
    543 (lfun-bits #'apply+ (logior $lfbits-rest-bit
    544                             (dpb 3 $lfbits-numreq 0)))
     538
    545539
    546540;;; This needs to:
     
    551545;;;     (%rax/%xmm0) there
    552546(defx86lapfunction %do-ff-call ((nfp 0) (frame arg_x) (fp-regs arg_y) (entry arg_z))
     547  (popq (% ra0))
    553548  (popq (% rax))
    554   (movq (% rbp) (@ @ (% rsp)))
     549  (movq (% rbp) (@ (% rsp)))
    555550  (movq (% rsp) (% rbp))
    556551  (movq (% ra0) (@ 8 (% rbp)))
Note: See TracChangeset for help on using the changeset viewer.