source: release/1.11/source/level-0/X86/X8632/x8632-symbol.lisp

Last change on this file was 16688, checked in by R. Matthew Emerson, 9 years ago

Merge copyright/license header changes to 1.11 release branch.

File size: 5.2 KB
RevLine 
[16688]1;;;
[13067]2;;; Copyright 2009 Clozure Associates
3;;;
[16688]4;;; Licensed under the Apache License, Version 2.0 (the "License");
5;;; you may not use this file except in compliance with the License.
6;;; You may obtain a copy of the License at
[13067]7;;;
[16688]8;;; http://www.apache.org/licenses/LICENSE-2.0
[13067]9;;;
[16688]10;;; Unless required by applicable law or agreed to in writing, software
11;;; distributed under the License is distributed on an "AS IS" BASIS,
12;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13;;; See the License for the specific language governing permissions and
14;;; limitations under the License.
[13067]15
[8000]16(in-package "CCL")
17
18(eval-when (:compile-toplevel :execute)
19 (require "X8632-ARCH")
20 (require "X86-LAPMACROS"))
21
22;;; This assumes that macros & special-operators
23;;; have something that's not FUNCTIONP in their
24;;; function-cells. It also assumes that NIL
25;;; isn't a true symbol, but that NILSYM is.
26(defx8632lapfunction %function ((sym arg_z))
27 (check-nargs 1)
28 (let ((symaddr temp0))
[10959]29 (movl ($ (+ (target-nil-value) x8632::nilsym-offset)) (% symaddr))
[8000]30 (cmp-reg-to-nil sym)
31 (cmovne (% sym) (% symaddr))
32 (trap-unless-typecode= symaddr x8632::subtag-symbol)
33 (movl (% sym) (% arg_y))
34 (movl (@ x8632::symbol.fcell (% symaddr)) (% arg_z))
35 (extract-typecode arg_z imm0)
36 (cmpb ($ x8632::subtag-function) (%b imm0))
37 (je.pt @ok)
38 (uuo-error-udf (% arg_y))
39 @ok
40 (single-value-return)))
41
42;;; Traps unless sym is NIL or some other symbol. If NIL, return
43;;; nilsym
44(defx8632lapfunction %symbol->symptr ((sym arg_z))
45 (let ((tag imm0))
[10959]46 (movl ($ (+ (target-nil-value) x8632::nilsym-offset)) (% tag))
[8000]47 (cmp-reg-to-nil sym)
[10446]48 (cmove (% tag) (% sym))
[8000]49 (je :done)
[8001]50 (trap-unless-typecode= sym x8632::subtag-symbol)
[8000]51 :done
52 (single-value-return)))
53
54;;; If symptr is NILSYM, return NIL; else typecheck and return symptr
55(defx8632lapfunction %symptr->symbol ((symptr arg_z))
[10959]56 (cmpl ($ (+ (target-nil-value) x8632::nilsym-offset)) (% symptr))
[8000]57 (jne @typecheck)
[10959]58 (movl ($ (target-nil-value)) (% arg_z))
[8000]59 (single-value-return)
60 @typecheck
61 (trap-unless-typecode= symptr x8632::subtag-symbol)
62 (single-value-return))
63
64(defx8632lapfunction %symptr-value ((symptr arg_z))
65 (jmp-subprim .SPspecref))
66
67(defx8632lapfunction %set-symptr-value ((symptr arg_y) (val arg_z))
68 (jmp-subprim .SPspecset))
69
70;;; This gets a tagged symbol as an argument.
71;;; If there's no thread-local binding, it should return
72;;; the underlying symbol vector as a first return value.
73(defx8632lapfunction %symptr-binding-address ((symptr arg_z))
74 (movl (@ x8632::symbol.binding-index (% symptr)) (% arg_y))
[10575]75 (rcmp (% arg_y) (:rcontext x8632::tcr.tlb-limit))
76 (movl (:rcontext x8632::tcr.tlb-pointer) (% temp0))
[8000]77 (jae @sym)
[8001]78 (cmpb ($ x8632::subtag-no-thread-local-binding) (@ (% temp0) (% arg_y)))
[8000]79 (je @sym)
80 (shl ($ x8632::word-shift) (% arg_y))
81 (push (% temp0))
82 (push (% arg_y))
83 (set-nargs 2)
84 (lea (@ '2 (% esp)) (% temp0))
85 (jmp-subprim .SPvalues)
86 @sym
87 (push (% arg_z))
[8001]88 (pushl ($ '#.x8632::symbol.vcell))
[8000]89 (set-nargs 2)
90 (lea (@ '2 (% esp)) (% temp0))
91 (jmp-subprim .SPvalues))
92
93(defx8632lapfunction %tcr-binding-location ((tcr arg_y) (sym arg_z))
94 (movl (@ x8632::symbol.binding-index (% sym)) (% temp0))
[10959]95 (movl ($ (target-nil-value)) (% arg_z))
[14640]96 (rcmp (% temp0) (@ (- x8632::tcr.tlb-limit x8632::tcr-bias) (% tcr)))
97 (movl (@ (- x8632::tcr.tlb-pointer x8632::tcr-bias) (% tcr)) (% arg_y))
[8000]98 (jae @done)
99 (lea (@ (% arg_y) (% temp0)) (% arg_y))
100 ;; We're little-endian, so the tag is at the EA with no
101 ;; displacement
102 (cmpb ($ x8632::subtag-no-thread-local-binding) (@ (% arg_y)))
103 (cmovnel (% arg_y) (% arg_z))
104 @done
105 (single-value-return))
106
107(defx86lapfunction %pname-hash ((str arg_y) (len arg_z))
108 (let ((accum imm0)
109 (offset temp0))
110 (xor (% offset) (% offset))
111 (xor (% accum) (% accum))
112 (testl (% len) (% len))
113 (jz.pn @done)
114 @loop8
115 (roll ($ 5) (%l accum))
116 (xorl (@ x8632::misc-data-offset (% str) (% offset)) (%l accum))
117 (addl ($ '1) (% offset))
118 (subl ($ '1) (% len))
119 (jnz @loop8)
120 (shll ($ 5) (% accum))
121 (shrl ($ (- 5 x8632::fixnumshift)) (% accum))
122 (movl (% accum) (% arg_z))
123 @done
124 (single-value-return)))
125
[10330]126(defx8632lapfunction %string-hash ((start 4) #|(ra 0)|# (str arg_y) (len arg_z))
127 (let ((accum imm0)
128 (offset temp0))
129 (movl (@ start (% esp)) (% offset))
130 (xorl (% accum) (% accum))
131 (testl (% len) (% len))
132 (jz @done)
133 @loop8
134 (roll ($ 5) (%l accum))
135 (xorl (@ x8632::misc-data-offset (% str) (% offset)) (%l accum))
136 (addl ($ '1) (% offset))
137 (subl ($ '1) (% len))
138 (jnz @loop8)
139 (shll ($ 5) (% accum))
140 (shrl ($ (- 5 x8632::fixnumshift)) (% accum))
141 (movl (% accum) (% arg_z))
142 @done
143 (single-value-return 3)))
[13745]144
145;;; Ensure that the current thread's thread-local-binding vector
146;;; contains room for an entry with index INDEX.
147;;; Return the fixnum-tagged tlb vector.
148(defx8632lapfunction %ensure-tlb-index ((idx arg_z))
149 (cmp (:rcontext x8632::tcr.tlb-limit) (% idx))
150 (jb @ok)
151 (push (% arg_z)) ; exception handler will pop this
152 (ud2a) (:byte 1) ; tlb_too_small()
153 @ok
154 (mov (:rcontext x8632::tcr.tlb-pointer) (% arg_z))
155 (single-value-return))
156
157
Note: See TracBrowser for help on using the repository browser.