From e4ab9662d1d554e2fb9e1a49e565dcf471c660be Mon Sep 17 00:00:00 2001 From: Stephen Adams Date: Fri, 17 Oct 1997 01:25:41 +0000 Subject: [PATCH] Changed the instruction sequence for procedure return (and computed jump). The code for clearing the type code from a continuation now loads the value into a register instead of modifying it in-place on the stack. I have left the code using an indirect jump. An alternative is to push the value back on the stack and do a RET. The indirect jump seems faster, especially when returning to the same address as the previous jump, but the branch prediction mechanisms for RET and JMP seem quite different. Speeds up the modified Gabriel Benchmark Suite (/scheme/8.0/src/bench) by 10% overall! I guess this is because the Pentium Pro really doesn't like the old read-modify-write instruction. Test Old New Ratio ctak 11.59 11.54 0.996 conform 0.62 0.50 0.806 traverse 1.57 0.92 0.586 takl 0.23 0.20 0.870 peval 0.40 0.35 0.875 browse 0.59 0.56 0.949 tak 0.28 0.25 0.893 wttree 1.61 1.49 0.925 deriv 0.34 0.29 0.853 boyer 0.47 0.42 0.894 div 0.42 0.39 0.929 dderiv 0.44 0.38 0.864 cpstak 0.42 0.41 0.976 matmul1 0.27 0.27 1.000 fib 0.68 0.55 0.809 fcomp 0.61 0.54 0.885 triangle 2.89 2.36 0.817 puzzle 0.47 0.47 1.000 matmul2 0.66 0.69 1.045 destruct 0.28 0.28 1.000 ~a.mean - - 0.899 ~g.mean - - 0.892 --- v7/src/compiler/machines/i386/rules3.scm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/v7/src/compiler/machines/i386/rules3.scm b/v7/src/compiler/machines/i386/rules3.scm index 0bbffe7bb..f928a3633 100644 --- a/v7/src/compiler/machines/i386/rules3.scm +++ b/v7/src/compiler/machines/i386/rules3.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: rules3.scm,v 1.27 1993/08/26 05:45:40 gjr Exp $ +$Id: rules3.scm,v 1.28 1997/10/17 01:25:41 adams Exp $ Copyright (c) 1992-1993 Massachusetts Institute of Technology @@ -39,8 +39,8 @@ MIT in each case. |# ;;;; Invocations -(define-integrable (clear-continuation-type-code) - (LAP (AND W (@R ,regnum:stack-pointer) (R ,regnum:datum-mask)))) +;;(define-integrable (clear-continuation-type-code) +;; (LAP (AND W (@R ,regnum:stack-pointer) (R ,regnum:datum-mask)))) (define-rule statement (POP-RETURN) @@ -52,8 +52,9 @@ MIT in each case. |# (let ((interrupt-label (generate-label 'INTERRUPT))) (LAP (CMP W (R ,regnum:free-pointer) ,reg:compiled-memtop) (JGE (@PCR ,interrupt-label)) - ,@(clear-continuation-type-code) - (RET) + (POP (R ,eax)) + (AND W (R ,eax) (R ,regnum:datum-mask)) + (JMP (R ,eax)) (LABEL ,interrupt-label) ,@(invoke-hook entry:compiler-interrupt-continuation-2)))))) @@ -94,8 +95,9 @@ MIT in each case. |# frame-size continuation ;; It expects the procedure at the top of the stack (LAP ,@(clear-map!) - ,@(clear-continuation-type-code) - (RET))) + (POP (R ,eax)) + (AND W (R ,eax) (R ,regnum:datum-mask)) + (JMP (R ,eax)))) (define-rule statement (INVOCATION:LEXPR (? number-pushed) (? continuation) (? label)) @@ -112,8 +114,8 @@ MIT in each case. |# continuation ;; It expects the procedure at the top of the stack (LAP ,@(clear-map!) - ,@(clear-continuation-type-code) (POP (R ,ecx)) + (AND W (R ,ecx) (R ,regnum:datum-mask)) (MOV W (R ,edx) (& ,number-pushed)) ,@(invoke-interface code:compiler-lexpr-apply))) -- 2.25.1