[movitz-cvs] CVS update: movitz/losp/muerte/cpu-id.lisp

Frode Vatvedt Fjeld ffjeld at common-lisp.net
Fri Apr 23 13:00:18 UTC 2004


Update of /project/movitz/cvsroot/movitz/losp/muerte
In directory common-lisp.net:/tmp/cvs-serv6368

Modified Files:
	cpu-id.lisp 
Log Message:
Changed read-time-stamp-counter to return two 29-bit fixnums, which
seems more useful for most cases, even if the upper 6 bits are lost.

Date: Fri Apr 23 09:00:17 2004
Author: ffjeld

Index: movitz/losp/muerte/cpu-id.lisp
diff -u movitz/losp/muerte/cpu-id.lisp:1.3 movitz/losp/muerte/cpu-id.lisp:1.4
--- movitz/losp/muerte/cpu-id.lisp:1.3	Wed Apr 14 18:49:14 2004
+++ movitz/losp/muerte/cpu-id.lisp	Fri Apr 23 09:00:17 2004
@@ -10,7 +10,7 @@
 ;;;; Author:        Frode Vatvedt Fjeld <frodef at acm.org>
 ;;;; Created at:    Mon Apr 15 22:47:13 2002
 ;;;;                
-;;;; $Id: cpu-id.lisp,v 1.3 2004/04/14 22:49:14 ffjeld Exp $
+;;;; $Id: cpu-id.lisp,v 1.4 2004/04/23 13:00:17 ffjeld Exp $
 ;;;;                
 ;;;;------------------------------------------------------------------
 
@@ -190,27 +190,56 @@
 
 (defun read-time-stamp-counter ()
   "Read the 64-bit i686 time-stamp counter.
-Returned as three values: low 24 bits, mid 24 bits, high 16 bits.
+Returned as two values: low 29 bits, mid 29 bits.
 This is an illegal instruction on lesser CPUs."
   (with-inline-assembly (:returns :multiple-values)
     (:std)
     (:rdtsc)				; Read Time-Stamp Counter into EDX:EAX
-    ;; Load upper 16 bits (of EDX) as ternary value.
+    (:shldl 5 :eax :edx)
+    (:shll #.movitz:+movitz-fixnum-shift+ :eax)
+    (:andl #.(cl:logxor #xffffffff movitz::+movitz-fixnum-zmask+) :edx)
+    (:andl #.(cl:* movitz:+movitz-fixnum-factor+ movitz:+movitz-most-positive-fixnum+)
+	   :eax)
     (:movl :edx :ebx)
-    (:andl #xffff0000 :edx)
-    (:shll #.(cl:- 16 movitz::+movitz-fixnum-shift+) :edx)
-    ((:fs-override) :movl :edx (:edi #.(movitz::global-constant-offset 'values)))
-    ;; Bits 24-47 as fixnum into EBX
-    (:shldl #.(cl:+ 8 movitz::+movitz-fixnum-shift+) :eax :ebx)
-    (:andl #.(cl:* #x00ffffff movitz::+movitz-fixnum-factor+) :ebx)
-    ;; Bits 0-23 as fixnum into EAX
-    (:andl #x00ffffff :eax)
-    (:shll #.movitz::+movitz-fixnum-shift+ :eax)
     (:cld)
-    ;; Return 3 values
-    ((:fs-override) :movl 1 (:edi #.(movitz::global-constant-offset 'num-values)))
-    (:movl 3 :ecx)
+    (:movl 2 :ecx)
     (:stc)))
+
+(define-compiler-macro read-time-stamp-counter ()
+  `(with-inline-assembly-case ()
+     (do-case (:register :same)
+       (:std)
+       (:rdtsc)
+       (:movl :edi :edx)
+       (:leal ((:eax ,movitz:+movitz-fixnum-factor+)) (:result-register))
+       (:cld))
+     (do-case (t :multiple-values)
+       (:compile-form (:result-mode :multiple-values) (no-macro-call read-time-stamp-counter)))))
+		      
+
+;;;(defun read-time-stamp-counter ()
+;;;  "Read the 64-bit i686 time-stamp counter.
+;;;Returned as three values: low 24 bits, mid 24 bits, high 16 bits.
+;;;This is an illegal instruction on lesser CPUs."
+;;;  (with-inline-assembly (:returns :multiple-values)
+;;;    (:std)
+;;;    (:rdtsc)				; Read Time-Stamp Counter into EDX:EAX
+;;;    ;; Load upper 16 bits (of EDX) as ternary value.
+;;;    (:movl :edx :ecx)
+;;;    (:andl #xffff0000 :edx)
+;;;    (:shll #.(cl:- 16 movitz::+movitz-fixnum-shift+) :edx)
+;;;    ((:fs-override) :movl :edx (:edi #.(movitz::global-constant-offset 'values)))
+;;;    ;; Bits 24-47 as fixnum into EBX
+;;;    (:shldl #.(cl:+ 8 movitz::+movitz-fixnum-shift+) :eax :ebx)
+;;;    (:andl #.(cl:* #x00ffffff movitz::+movitz-fixnum-factor+) :ebx)
+;;;    ;; Bits 0-23 as fixnum into EAX
+;;;    (:andl #x00ffffff :eax)
+;;;    (:shll #.movitz::+movitz-fixnum-shift+ :eax)
+;;;    (:cld)
+;;;    ;; Return 3 values
+;;;    ((:fs-override) :movl 1 (:edi #.(movitz::global-constant-offset 'num-values)))
+;;;    (:movl 3 :ecx)
+;;;    (:stc)))
 
 (defun clear-time-stamp-counter ()
   "Reset the i686 time-stamp-counter.





More information about the Movitz-cvs mailing list