Changeset 10266


Ignore:
Timestamp:
Jul 31, 2008, 5:50:05 PM (11 years ago)
Author:
rme
Message:

New locking stuff, tcr suspend/resume traps, static-cons stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-0/X86/X8632/x8632-misc.lisp

    r9475 r10266  
    443443  (single-value-return))
    444444
    445 ;;; Return true iff we were able to increment a non-negative
    446 ;;; lock._value
    447 (defx8632lapfunction %try-read-lock-rwlock ((lock arg_z))
    448   (check-nargs 1)
    449   (mark-as-imm temp0)
    450   (let ((imm1 temp0))
    451     @try
    452     (movl (@ x8632::lock._value (% lock)) (% eax))
    453     (movl (% eax) (% imm1))
    454     (addl ($ '1) (% imm1))
    455     (jle @fail)
    456     (lock)
    457     (cmpxchgl (% imm1) (@ x8632::lock._value (% lock)))
    458     (jne @try)
    459     (mark-as-node temp0)
    460     (single-value-return)               ; return the lock
    461     @fail
    462     (mark-as-node temp0)
    463     (movl ($ x8632::nil-value) (% arg_z))
    464     (single-value-return)))
    465 
    466 (defx8632lapfunction unlock-rwlock ((lock arg_z))
    467   (cmpl ($ 0) (@ x8632::lock._value (% lock)))
    468   (jle @unlock-write)
    469   @unlock-read
    470   (mark-as-imm temp0)
    471   (let ((imm1 temp0))
    472     (movl (@ x8632::lock._value (% lock)) (% eax))
    473     (lea (@ '-1 (% imm0)) (% imm1))
    474     (lock)
    475     (cmpxchgl (% imm1) (@ x8632::lock._value (% lock)))
    476     (jne @unlock-read))
    477   (mark-as-node temp0)
    478   (single-value-return)
    479   @unlock-write
    480   ;;; If we aren't the writer, return NIL.
    481   ;;; If we are and the value's about to go to 0, clear the writer field.
    482   (movl (@ x8632::lock.writer (% lock)) (% imm0))
    483   (cmpl (% imm0) (@ (% :rcontext) x8632::tcr.linear))
    484   (jne @fail)
    485   (cmpl ($ '-1) (@ x8632::lock._value (% lock)))
    486   (jne @still-owner)
    487   (movss (% fpzero) (@ x8632::lock.writer (% lock)))
    488   @still-owner
    489   (addl ($ '1) (@ x8632::lock._value (% lock)))
    490   (single-value-return)
    491   @fail
    492   (movl ($ x8632::nil-value) (%l arg_z))
    493   (single-value-return))
    494 
    495445(defx8632lapfunction %atomic-incf-node ((by 4) #|(ra 0)|# (node arg_y) (disp arg_z))
    496446  (check-nargs 3)
     
    616566  (single-value-return 3))
    617567
    618 (defx86lapfunction %ptr-store-fixnum-conditional ((ptr 4) #|(ra 0)|# (expected-oldval arg_y) (newval arg_z))
     568(defx8632lapfunction %ptr-store-fixnum-conditional ((ptr 4) #|(ra 0)|# (expected-oldval arg_y) (newval arg_z))
    619569  (mark-as-imm temp0)
    620570  (let ((address temp0))
     
    632582  (mark-as-node temp0)
    633583  (single-value-return 3))
     584
     585(defx8632lapfunction xchgl ((newval arg_y) (ptr arg_z))
     586  (unbox-fixnum newval imm0)
     587  (macptr-ptr ptr arg_y)                ;better be aligned
     588  (xchgl (% imm0) (@ (% arg_y)))
     589  (box-fixnum imm0 arg_z)
     590  (single-value-return))
    634591
    635592(defx8632lapfunction %macptr->dead-macptr ((macptr arg_z))
     
    709666  (lea (@ x8632::nil-value (% imm0)) (% arg_z))
    710667  (single-value-return))
     668
     669(defx8632lapfunction debug-trap-with-string ((arg arg_z))
     670  (check-nargs 1)
     671  (uuo-error-debug-trap-with-string)
     672  (single-value-return))
     673
     674(defx8632lapfunction %%tcr-interrupt ((target arg_z))
     675  (check-nargs 1)
     676  (ud2a)
     677  (:byte 4)
     678  (box-fixnum imm0 arg_z)
     679  (single-value-return))
     680
     681(defx8632lapfunction %suspend-tcr ((target arg_z))
     682  (check-nargs 1)
     683  (ud2a)
     684  (:byte 5)
     685  (testl (%l imm0) (%l imm0))
     686  (movl ($ target::nil-value) (%l arg_z))
     687  (cmovel (@ target::t-offset (% arg_z)) (%l arg_z))
     688  (single-value-return))
     689
     690(defx8632lapfunction %suspend-other-threads ()
     691  (check-nargs 0)
     692  (ud2a)
     693  (:byte 6)
     694  (movl ($ target::nil-value) (%l arg_z))
     695  (single-value-return))
     696
     697(defx8632lapfunction %resume-tcr ((target arg_z))
     698  (check-nargs 1)
     699  (ud2a)
     700  (:byte 7)
     701  (testl (%l imm0) (%l imm0))
     702  (movl ($ target::nil-value) (%l arg_z))
     703  (cmovel (@ target::t-offset (% arg_z)) (%l arg_z))
     704  (single-value-return))
     705
     706(defx8632lapfunction %resume-other-threads ()
     707  (check-nargs 0)
     708  (ud2a)
     709  (:byte 8)
     710  (movl ($ target::nil-value) (%l arg_z))
     711  (single-value-return))
     712
     713(defx8632lapfunction %get-spin-lock ((p arg_z))
     714  (check-nargs 1)
     715  (save-simple-frame)
     716  (push (% arg_z))
     717  @again
     718  (mark-as-imm temp1)
     719  (movl (@ -4 (% ebp)) (% arg_z))
     720  (macptr-ptr arg_z temp1)
     721  (movl (@ '*spin-lock-tries* (% fn)) (% arg_y))
     722  (movl (@ '*spin-lock-timeouts* (% fn)) (% arg_z))
     723  (movl (@ target::symbol.vcell (% arg_y)) (% arg_y))
     724  (movl (@ (% :rcontext) x8664::tcr.linear) (% temp0))
     725  @try-swap
     726  (xorl (% eax) (% eax))
     727  (lock)
     728  (cmpxchgl (% temp0) (@ (% temp1)))
     729  (je @done)
     730  @spin
     731  (pause)
     732  (cmpl ($ 0) (@ (% temp1)))
     733  (je @try-swap)
     734  (subl ($ '1) (% arg_y))
     735  (jne @spin)
     736  @wait
     737  (addl ($ x8632::fixnumone) (@ x8632::symbol.vcell (% arg_z)))
     738  (mark-as-node temp1)
     739  (call-symbol yield 0)
     740  (jmp @again)
     741  @done
     742  (mark-as-node temp1)
     743  (movl (@ -4 (% ebp)) (% arg_z))
     744  (restore-simple-frame)
     745  (single-value-return))
     746
     747;;; future %%apply-in-frame-proto would go here
     748
     749(defx8632lapfunction %atomic-pop-static-cons ()
     750  @again
     751  (movl (@ (+ x8632::nil-value (x8632::kernel-global static-conses))) (% eax))
     752  (testl ($ x8632::nil-value) (% eax))
     753  (jz @lose)
     754  (%cdr eax temp0)
     755  (lock)
     756  (cmpxchgl (% temp0) (@ (+ x8632::nil-value (x8632::kernel-global static-conses))))
     757  (jnz @again)
     758  @lose
     759  (movl (% eax) (% arg_z))
     760  (single-value-return))
     761
     762(defx8632lapfunction %staticp ((x arg_z))
     763  (check-nargs 1)
     764  (ref-global tenured-area temp0)
     765  (movl (% x) (% imm0))
     766  (subl (@ target::area.low (% temp0)) (% imm0))
     767  (shrl ($ target::dnode-shift) (% imm0))
     768  (cmpl (@ target::area.static-dnodes (% temp0)) (% imm0))
     769  (leal (@ (% imm0) target::fixnumone) (% arg_z))
     770  (movl ($ target::nil-value) (%l imm0))
     771  (cmovael (% imm0) (% arg_z))
     772  (single-value-return))
     773
     774(defx8632lapfunction %static-inverse-cons ((n arg_z))
     775  (check-nargs 1)
     776  (ref-global tenured-area temp0)
     777  (movl (@ target::area.low (% temp0)) (% imm0))
     778  (leal (@ target::fulltag-cons (% imm0) (% n) 2) (% arg_z))
     779  (single-value-return))
Note: See TracChangeset for help on using the changeset viewer.