[movitz-cvs] CVS movitz/losp/muerte

ffjeld ffjeld at common-lisp.net
Sun Feb 18 14:52:24 UTC 2007


Update of /project/movitz/cvsroot/movitz/losp/muerte
In directory clnet:/tmp/cvs-serv17716

Modified Files:
	primitive-functions.lisp 
Log Message:
Wrote primitive function decode-keyargs-default for new &key parsing implementation.


--- /project/movitz/cvsroot/movitz/losp/muerte/primitive-functions.lisp	2005/05/05 20:51:43	1.65
+++ /project/movitz/cvsroot/movitz/losp/muerte/primitive-functions.lisp	2007/02/18 14:52:24	1.66
@@ -10,7 +10,7 @@
 ;;;; Author:        Frode Vatvedt Fjeld <frodef at acm.org>
 ;;;; Created at:    Tue Oct  2 21:02:18 2001
 ;;;;                
-;;;; $Id: primitive-functions.lisp,v 1.65 2005/05/05 20:51:43 ffjeld Exp $
+;;;; $Id: primitive-functions.lisp,v 1.66 2007/02/18 14:52:24 ffjeld Exp $
 ;;;;                
 ;;;;------------------------------------------------------------------
 
@@ -734,3 +734,109 @@
     (:jnz 'copy-jumpers)
     (:locally (:movl 0 (:edi (:edi-offset atomically-continuation))))
     (:ret)))
+
+
+(define-primitive-function decode-keyargs-default ()
+  "Decode keyword arguments."
+  (with-inline-assembly (:returns :multiple-values)
+    ;; EAX: arg0 (if needed)
+    ;; EBX: arg1 (if needed)
+    ;; ECX: numargs (fixnum)
+    ;; EDX: arg-position of first keyword (fixnum)
+
+    (:subl :edx :ecx)			; find stop-pos
+    (:jbe '(:sub-program (no-key-args)
+	    (:ret)))
+
+    (:locally (:movl #xffffffff (:edi (:edi-offset scratch1)))) ; unbond-value
+    (:locally (:movl #xffffffff (:edi (:edi-offset scratch2)))) ; unbond-value
+    (:cmpl 4 :edx)			; keys start at 0 or 1?
+    (:jbe '(:sub-program (save-eax-ebx)
+	    (:je 'save-ebx-only)
+	    (:locally (:movl :eax (:edi (:edi-offset scratch1))))
+	    save-ebx-only
+	    (:locally (:movl :ebx (:edi (:edi-offset scratch2))))
+	    (:subl 8 :ecx)
+	    (:jmp 'continue-save-eax-ebx)))
+   continue-save-eax-ebx
+    (:testl 4 :ecx)
+    (:jnz '(:sub-program (odd-keywords)
+	    (:orl 32 (:ebp -16))
+	    (:andl -8 :ecx)
+	    (:jmp 'continue-from-odd-keywords)))
+   continue-from-odd-keywords
+    (:locally (:movl :ecx (:edi (:edi-offset raw-scratch0)))) ; save stop-pos
+    (:xorl :edx :edx)			; EDX scans the args, last-to-first.
+
+    (:cmpl :edx :ecx)			; might occur if key-arg-pos is 0 or 1,
+    (:jbe 'check-arg0-arg1)		; and numargs is 2 or 3.
+    
+   scan-args-loop
+    ;; Load current argument keyword and value into EAX and EBX
+    (:movl (:ebp :edx 12) :eax)
+    (:movl (:ebp :edx 8) :ebx)
+    
+   start-keyword-search
+    ;; EAX: (presumed) keyword, EBX corresponding value.
+    (:globally (:cmpl :eax (:edi (:edi-offset allow-other-keys-symbol))))
+    (:je '(:sub-program (found-allow-other-keys)
+	   ;; store boolean EBX in bit 2 of (ebx -16).
+	   (:andl -8 (:ebp -16))
+	   (:cmpl :edi :ebx)
+	   (:je 'finished-keyword-search)
+	   (:orl 4 (:ebp -16))		; Signal :allow-other-keys t
+	   (:jmp 'finished-keyword-search)))
+    (:leal (:eax -5) :ecx)
+    (:testb 5 :cl)
+    (:jnz '(:sub-program (keyword-not-symbol)
+	    (:orl 16 (:ebp -16))	; Signal keyword-not-symbol
+	    (:jmp 'finished-keyword-search)))
+    (:movl (:esi (:offset movitz-funobj num-jumpers))
+	   :ecx)
+    (:andl #xfffc :ecx)
+   position-search-loop
+    ;; ECX scans funobj's keyword vector for position of keyword in EAX
+    (:cmpl :eax (:esi :ecx (:offset movitz-funobj constant0)))
+    (:je 'found-keyword)
+    (:testb 1 (:esi :ecx (:offset movitz-funobj constant0)))
+    (:jz '(:sub-program (keyword-not-fund)
+	   (:orl 8 (:ebp -16))		; signal unknown-keyword
+	   (:jmp 'finished-keyword-search)))
+    (:addl 4 :ecx)
+    (:jmp 'position-search-loop)
+    
+   found-keyword
+    (:subw (:esi (:offset movitz-funobj num-jumpers)) :cx)
+    (:negl :ecx)
+    (:movl :ebx (:ebp -20 (:ecx 2)))
+    (:globally (:movl (:edi (:edi-offset t-symbol)) :ebx))
+    (:movl :ebx (:ebp -20 (:ecx 2) -4))
+    
+   finished-keyword-search
+    (:addl 8 :edx)
+    (:locally (:cmpl :edx (:edi (:edi-offset raw-scratch0)))) ; more args?
+    (:ja 'scan-args-loop)
+
+   check-arg0-arg1
+    (:locally (:cmpl -1 (:edi (:edi-offset scratch1))))
+    (:jne '(:sub-program (search-eax-ebx)
+	    ;; Search one more keyword, in arg0 and arg1
+	    (:locally (:movl (:edi (:edi-offset scratch1)) :eax))
+	    (:locally (:movl (:edi (:edi-offset scratch2)) :ebx))
+	    (:locally (:movl #xffffffff (:edi (:edi-offset scratch1))))
+	    (:locally (:movl #xffffffff (:edi (:edi-offset scratch2))))
+	    (:jmp 'start-keyword-search)))
+    (:locally (:cmpl -1 (:edi (:edi-offset scratch2))))
+    (:jne '(:sub-program (search-ebx)
+	    ;; Search one more keyword, in arg1 and last on-stack.
+	    (:locally (:movl (:edi (:edi-offset scratch2)) :eax))
+	    (:movl (:ebp :edx 8) :ebx)	    
+	    (:locally (:movl #xffffffff (:edi (:edi-offset scratch2))))
+	    (:jmp 'start-keyword-search)))
+    (:ret)))
+
+(define-primitive-function decode-keyargs-foo ()
+  "foo"
+  (with-inline-assembly (:returns :multiple-values)
+    (:ret)))
+




More information about the Movitz-cvs mailing list