Ignore:
Timestamp:
Aug 25, 2008, 4:03:13 AM (11 years ago)
Author:
gb
Message:

Start to get this working on IA32. Still needs objc-error-handler
support in callbacks, varargs method support.

Location:
trunk/source/objc-bridge
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/objc-bridge/objc-runtime.lisp

    r10545 r10562  
    539539)
    540540
     541;;; I think that we know where these constants come from.
     542#+x8632-target
     543(progn
     544  (defconstant JB-FPCW 0)
     545  (defconstant JB-MASK 4)
     546  (defconstant JB-MXCSR 8)
     547  (defconstant JB-EBX 12)
     548  (defconstant JB-ECX 16)
     549  (defconstant JB-EDX 20)
     550  (defconstant JB-EDI 24)
     551  (defconstant JB-ESI 28)
     552  (defconstant JB-EBP 32)
     553  (defconstant JB-ESP 36)
     554  (defconstant JB-SS 40)
     555  (defconstant JB-EFLAGS 44)
     556  (defconstant JB-EIP 48)
     557  (defconstant JB-CS 52)
     558  (defconstant JB-DS 56)
     559  (defconstant JB-ES 60)
     560  (defconstant JB-FS 64)
     561  (defconstant JB-GS 68)
     562
     563
     564  )
    541565
    542566 
    543567
    544 ;;; A malloc'ed pointer to thre words of machine code.  The first
     568;;; A malloc'ed pointer to three words of machine code.  The first
    545569;;; instruction copies the address of the trampoline callback from r14
    546570;;; to the count register.  The second instruction (rather obviously)
     
    571595        p)))
    572596
     597;;; This isn't used; it isn't right, either.
    573598#+x8664-target
    574599(defloadvar *setjmp-catch-rip-code*
     
    579604      (dotimes (i nbytes p)
    580605        (setf (%get-unsigned-byte p i) (pop code-bytes)))))
    581          
     606
     607#+x8632-target
     608(defloadvar *setjmp-catch-rip-code*
     609    (let* ((code-bytes '(#x83 #xec #x10 ; subl $16,%esp
     610                         #x89 #x04 #x24 ; movl %eax,(%esp)
     611                         #x89 #x7c #x24 #x04   ; movl %edi,4(%esp)
     612                         #xff #xd3))    ; call *%ebx
     613           (nbytes (length code-bytes))
     614           (p (malloc nbytes)))
     615      (dotimes (i nbytes p)
     616        (setf (%get-unsigned-byte p i) (pop code-bytes)))))
    582617
    583618;;; Catch frames are allocated on a stack, so it's OK to pass their
     
    614649  t)
    615650
     651#+x8632-target
     652;;; Ugh.  Apple stores segment register values in jmp_bufs.  You know,
     653;;; since they're so volatile and everything.
     654(defun %associate-jmp-buf-with-catch-frame (jmp-buf catch-frame c-frame)
     655  (setf (%get-unsigned-word jmp-buf JB-FS) (%get-fs-register)
     656        (%get-unsigned-word jmp-buf JB-GS) (%get-gs-register)
     657        (%get-unsigned-word jmp-buf JB-CS) #x17
     658        (%get-unsigned-word jmp-buf JB-DS) #x1f
     659        (%get-unsigned-word jmp-buf JB-ES) #x1f
     660        (%get-unsigned-word jmp-buf JB-SS) #x1f)
     661  (%set-object jmp-buf JB-ESP c-frame)
     662  (%set-object jmp-buf JB-EBP c-frame)
     663  (setf (%get-unsigned-long jmp-buf JB-MXCSR) #x1f80
     664        (%get-unsigned-long jmp-buf JB-FPCW) #x37f
     665        (%get-unsigned-long jmp-buf JB-MASK) 0)
     666  (setf (%get-ptr jmp-buf JB-EBX) throw-to-catch-frame
     667        (%get-ptr jmp-buf JB-EIP) *setjmp-catch-rip-code*)
     668  (%set-object jmp-buf JB-EDI catch-frame)
     669  t)
     670 
     671
     672       
    616673
    617674)
     
    20482105              arg-info))))
    20492106
    2050 #+x8664-target
     2107#+x86-target
    20512108(defun encode-objc-method-arglist (arglist result-spec)
    20522109  (let* ((offset 0)
     
    20552112                (dolist (argspec arglist (nreverse result))
    20562113                  (let* ((arg (parse-foreign-type argspec))
    2057                          (delta 8))
     2114                         (delta target::node-size))
    20582115                    (typecase arg
    20592116                      (foreign-double-float-type)
     
    20632120                      (foreign-record-type
    20642121                       (let* ((bits (ensure-foreign-type-bits arg)))
    2065                          (setq delta (ceiling bits 8))))
     2122                         (setq delta (ceiling bits target::node-size))))
    20662123                      (t (break "argspec = ~s, arg = ~s" argspec arg)))
    20672124                    (push (list (encode-objc-type arg) offset) result)
    2068                     (setq offset (* 8 (ceiling (+ offset delta) 8))))))))
     2125                    (setq offset (* target::node-size (ceiling (+ offset delta) target::node-size))))))))
    20692126    (let* ((max-parm-end offset))
    20702127      (format nil "~a~d~:{~a~d~}"
  • trunk/source/objc-bridge/objc-support.lisp

    r9761 r10562  
    311311)
    312312
     313#+x8632-target
     314(progn
     315(defun objc-callback-error-return (condition return-value-pointer return-address-pointer)
     316  (declare (ignorable oondition return-value-pointer return-address-pointer))
     317  #||
     318  (process-debug-condition *current-process* condition (%get-frame-ptr))
     319  (let* ((addr (%reference-external-entry-point (load-time-value (external "__NSRaiseError")))))
     320    (setf (%get-unsigned-long ) )
     321  (setf (%get-ptr return-value-pointer 0) (ns-exception condition))
     322  ||#
     323  nil)
     324)
    313325
    314326)
Note: See TracChangeset for help on using the changeset viewer.