From 1c09520cfbe88c76e5ac8b8b6c3c0d67f67a0d44 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Mon, 1 Dec 2008 15:32:21 +0000 Subject: [PATCH] 1.0.23.3: faster generic arithmetic dispatch on x86 and x86-64 * Single branch to check if both arguments are fixnums, rerorder fixnum branch to be the fallthru. --- NEWS | 1 + src/assembly/x86-64/arith.lisp | 18 ++++++++---------- src/assembly/x86/arith.lisp | 18 ++++++++---------- version.lisp-expr | 2 +- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/NEWS b/NEWS index 69e84d9..443a38b 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ ;;;; -*- coding: utf-8; -*- + * optimization: faster generic arithmetic dispatch on x86 and x86-64. * bug fix: lexical type declarations are now correctly reported by SB-CLTL2. (reported by Larry D'Anna) * bug fix: STRING-TO-OCTETS did not handle :START properly when diff --git a/src/assembly/x86-64/arith.lisp b/src/assembly/x86-64/arith.lisp index 4e8f81d..22fee87 100644 --- a/src/assembly/x86-64/arith.lisp +++ b/src/assembly/x86-64/arith.lisp @@ -28,15 +28,16 @@ (:res res (descriptor-reg any-reg) rdx-offset) (:temp rax unsigned-reg rax-offset) - (:temp rbx unsigned-reg rbx-offset) (:temp rcx unsigned-reg rcx-offset)) - (declare (ignorable rbx)) - - (inst test x 7) ; fixnum? + (inst mov rcx x) + (inst or rcx y) + (inst test rcx 7) ; both fixnums? (inst jmp :nz DO-STATIC-FUN) ; no - do generic - (inst test y 7) ; fixnum? - (inst jmp :z DO-BODY) ; yes - doit here + + ,@body + (inst clc) + (inst ret) DO-STATIC-FUN (inst pop rax) @@ -51,10 +52,7 @@ (make-ea :qword :disp (+ nil-value (static-fun-offset - ',(symbolicate "TWO-ARG-" fun))))) - - DO-BODY - ,@body))) + ',(symbolicate "TWO-ARG-" fun)))))))) (define-generic-arith-routine (+ 10) (move res x) diff --git a/src/assembly/x86/arith.lisp b/src/assembly/x86/arith.lisp index 33c0439..0d3b721 100644 --- a/src/assembly/x86/arith.lisp +++ b/src/assembly/x86/arith.lisp @@ -28,15 +28,16 @@ (:res res (descriptor-reg any-reg) edx-offset) (:temp eax unsigned-reg eax-offset) - (:temp ebx unsigned-reg ebx-offset) (:temp ecx unsigned-reg ecx-offset)) - (declare (ignorable ebx)) - - (inst test x 3) ; fixnum? + (inst mov ecx x) + (inst or ecx y) + (inst test ecx 3) ; both fixnums? (inst jmp :nz DO-STATIC-FUN) ; no - do generic - (inst test y 3) ; fixnum? - (inst jmp :z DO-BODY) ; yes - doit here + + ,@body + (inst clc) ; single-value return + (inst ret) DO-STATIC-FUN (inst pop eax) @@ -51,10 +52,7 @@ (make-ea :dword :disp (+ nil-value (static-fun-offset - ',(symbolicate "TWO-ARG-" fun))))) - - DO-BODY - ,@body))) + ',(symbolicate "TWO-ARG-" fun)))))))) (define-generic-arith-routine (+ 10) (move res x) diff --git a/version.lisp-expr b/version.lisp-expr index d4b8998..82d37e0 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.23.2" +"1.0.23.3" -- 1.7.10.4