| [13075] | 1 | ;;; Copyright 2009 Clozure Associates
|
|---|
| 2 | ;;; This file is part of Clozure CL.
|
|---|
| 3 | ;;;
|
|---|
| 4 | ;;; Clozure CL is licensed under the terms of the Lisp Lesser GNU
|
|---|
| 5 | ;;; Public License , known as the LLGPL and distributed with Clozure
|
|---|
| 6 | ;;; CL as the file "LICENSE". The LLGPL consists of a preamble and
|
|---|
| 7 | ;;; the LGPL, which is distributed with Clozure CL as the file "LGPL".
|
|---|
| 8 | ;;; Where these conflict, the preamble takes precedence.
|
|---|
| 9 | ;;;
|
|---|
| 10 | ;;; Clozure CL is referenced in the preamble as the "LIBRARY."
|
|---|
| 11 | ;;;
|
|---|
| 12 | ;;; The LLGPL is also available online at
|
|---|
| 13 | ;;; http://opensource.franz.com/preamble.html
|
|---|
| 14 |
|
|---|
| [8000] | 15 | (in-package "CCL")
|
|---|
| 16 |
|
|---|
| 17 | (eval-when (:compile-toplevel :execute)
|
|---|
| 18 | (require "X8632-ARCH")
|
|---|
| 19 | (require "X86-LAPMACROS"))
|
|---|
| 20 |
|
|---|
| 21 | ;;; This assumes that macros & special-operators
|
|---|
| 22 | ;;; have something that's not FUNCTIONP in their
|
|---|
| 23 | ;;; function-cells. It also assumes that NIL
|
|---|
| 24 | ;;; isn't a true symbol, but that NILSYM is.
|
|---|
| 25 | (defx8632lapfunction %function ((sym arg_z))
|
|---|
| 26 | (check-nargs 1)
|
|---|
| 27 | (let ((symaddr temp0))
|
|---|
| [10959] | 28 | (movl ($ (+ (target-nil-value) x8632::nilsym-offset)) (% symaddr))
|
|---|
| [8000] | 29 | (cmp-reg-to-nil sym)
|
|---|
| 30 | (cmovne (% sym) (% symaddr))
|
|---|
| 31 | (trap-unless-typecode= symaddr x8632::subtag-symbol)
|
|---|
| 32 | (movl (% sym) (% arg_y))
|
|---|
| 33 | (movl (@ x8632::symbol.fcell (% symaddr)) (% arg_z))
|
|---|
| 34 | (extract-typecode arg_z imm0)
|
|---|
| 35 | (cmpb ($ x8632::subtag-function) (%b imm0))
|
|---|
| 36 | (je.pt @ok)
|
|---|
| 37 | (uuo-error-udf (% arg_y))
|
|---|
| 38 | @ok
|
|---|
| 39 | (single-value-return)))
|
|---|
| 40 |
|
|---|
| 41 | ;;; Traps unless sym is NIL or some other symbol. If NIL, return
|
|---|
| 42 | ;;; nilsym
|
|---|
| 43 | (defx8632lapfunction %symbol->symptr ((sym arg_z))
|
|---|
| 44 | (let ((tag imm0))
|
|---|
| [10959] | 45 | (movl ($ (+ (target-nil-value) x8632::nilsym-offset)) (% tag))
|
|---|
| [8000] | 46 | (cmp-reg-to-nil sym)
|
|---|
| [10446] | 47 | (cmove (% tag) (% sym))
|
|---|
| [8000] | 48 | (je :done)
|
|---|
| [8001] | 49 | (trap-unless-typecode= sym x8632::subtag-symbol)
|
|---|
| [8000] | 50 | :done
|
|---|
| 51 | (single-value-return)))
|
|---|
| 52 |
|
|---|
| 53 | ;;; If symptr is NILSYM, return NIL; else typecheck and return symptr
|
|---|
| 54 | (defx8632lapfunction %symptr->symbol ((symptr arg_z))
|
|---|
| [10959] | 55 | (cmpl ($ (+ (target-nil-value) x8632::nilsym-offset)) (% symptr))
|
|---|
| [8000] | 56 | (jne @typecheck)
|
|---|
| [10959] | 57 | (movl ($ (target-nil-value)) (% arg_z))
|
|---|
| [8000] | 58 | (single-value-return)
|
|---|
| 59 | @typecheck
|
|---|
| 60 | (trap-unless-typecode= symptr x8632::subtag-symbol)
|
|---|
| 61 | (single-value-return))
|
|---|
| 62 |
|
|---|
| 63 | (defx8632lapfunction %symptr-value ((symptr arg_z))
|
|---|
| 64 | (jmp-subprim .SPspecref))
|
|---|
| 65 |
|
|---|
| 66 | (defx8632lapfunction %set-symptr-value ((symptr arg_y) (val arg_z))
|
|---|
| 67 | (jmp-subprim .SPspecset))
|
|---|
| 68 |
|
|---|
| 69 | ;;; This gets a tagged symbol as an argument.
|
|---|
| 70 | ;;; If there's no thread-local binding, it should return
|
|---|
| 71 | ;;; the underlying symbol vector as a first return value.
|
|---|
| 72 | (defx8632lapfunction %symptr-binding-address ((symptr arg_z))
|
|---|
| 73 | (movl (@ x8632::symbol.binding-index (% symptr)) (% arg_y))
|
|---|
| [10575] | 74 | (rcmp (% arg_y) (:rcontext x8632::tcr.tlb-limit))
|
|---|
| 75 | (movl (:rcontext x8632::tcr.tlb-pointer) (% temp0))
|
|---|
| [8000] | 76 | (jae @sym)
|
|---|
| [8001] | 77 | (cmpb ($ x8632::subtag-no-thread-local-binding) (@ (% temp0) (% arg_y)))
|
|---|
| [8000] | 78 | (je @sym)
|
|---|
| 79 | (shl ($ x8632::word-shift) (% arg_y))
|
|---|
| 80 | (push (% temp0))
|
|---|
| 81 | (push (% arg_y))
|
|---|
| 82 | (set-nargs 2)
|
|---|
| 83 | (lea (@ '2 (% esp)) (% temp0))
|
|---|
| 84 | (jmp-subprim .SPvalues)
|
|---|
| 85 | @sym
|
|---|
| 86 | (push (% arg_z))
|
|---|
| [8001] | 87 | (pushl ($ '#.x8632::symbol.vcell))
|
|---|
| [8000] | 88 | (set-nargs 2)
|
|---|
| 89 | (lea (@ '2 (% esp)) (% temp0))
|
|---|
| 90 | (jmp-subprim .SPvalues))
|
|---|
| 91 |
|
|---|
| 92 | (defx8632lapfunction %tcr-binding-location ((tcr arg_y) (sym arg_z))
|
|---|
| 93 | (movl (@ x8632::symbol.binding-index (% sym)) (% temp0))
|
|---|
| [10959] | 94 | (movl ($ (target-nil-value)) (% arg_z))
|
|---|
| [8000] | 95 | (rcmp (% temp0) (@ x8632::tcr.tlb-limit (% tcr)))
|
|---|
| 96 | (movl (@ x8632::tcr.tlb-pointer (% tcr)) (% arg_y))
|
|---|
| 97 | (jae @done)
|
|---|
| 98 | (lea (@ (% arg_y) (% temp0)) (% arg_y))
|
|---|
| 99 | ;; We're little-endian, so the tag is at the EA with no
|
|---|
| 100 | ;; displacement
|
|---|
| 101 | (cmpb ($ x8632::subtag-no-thread-local-binding) (@ (% arg_y)))
|
|---|
| 102 | (cmovnel (% arg_y) (% arg_z))
|
|---|
| 103 | @done
|
|---|
| 104 | (single-value-return))
|
|---|
| 105 |
|
|---|
| 106 | (defx86lapfunction %pname-hash ((str arg_y) (len arg_z))
|
|---|
| 107 | (let ((accum imm0)
|
|---|
| 108 | (offset temp0))
|
|---|
| 109 | (xor (% offset) (% offset))
|
|---|
| 110 | (xor (% accum) (% accum))
|
|---|
| 111 | (testl (% len) (% len))
|
|---|
| 112 | (jz.pn @done)
|
|---|
| 113 | @loop8
|
|---|
| 114 | (roll ($ 5) (%l accum))
|
|---|
| 115 | (xorl (@ x8632::misc-data-offset (% str) (% offset)) (%l accum))
|
|---|
| 116 | (addl ($ '1) (% offset))
|
|---|
| 117 | (subl ($ '1) (% len))
|
|---|
| 118 | (jnz @loop8)
|
|---|
| 119 | (shll ($ 5) (% accum))
|
|---|
| 120 | (shrl ($ (- 5 x8632::fixnumshift)) (% accum))
|
|---|
| 121 | (movl (% accum) (% arg_z))
|
|---|
| 122 | @done
|
|---|
| 123 | (single-value-return)))
|
|---|
| 124 |
|
|---|
| [10330] | 125 | (defx8632lapfunction %string-hash ((start 4) #|(ra 0)|# (str arg_y) (len arg_z))
|
|---|
| 126 | (let ((accum imm0)
|
|---|
| 127 | (offset temp0))
|
|---|
| 128 | (movl (@ start (% esp)) (% offset))
|
|---|
| 129 | (xorl (% accum) (% accum))
|
|---|
| 130 | (testl (% len) (% len))
|
|---|
| 131 | (jz @done)
|
|---|
| 132 | @loop8
|
|---|
| 133 | (roll ($ 5) (%l accum))
|
|---|
| 134 | (xorl (@ x8632::misc-data-offset (% str) (% offset)) (%l accum))
|
|---|
| 135 | (addl ($ '1) (% offset))
|
|---|
| 136 | (subl ($ '1) (% len))
|
|---|
| 137 | (jnz @loop8)
|
|---|
| 138 | (shll ($ 5) (% accum))
|
|---|
| 139 | (shrl ($ (- 5 x8632::fixnumshift)) (% accum))
|
|---|
| 140 | (movl (% accum) (% arg_z))
|
|---|
| 141 | @done
|
|---|
| 142 | (single-value-return 3)))
|
|---|