From 7a2ac14f5ad2b944e0f09a013f1e291434ad4de9 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Thu, 10 Jan 2008 03:26:18 -0500 Subject: [PATCH] Eliminated frame-pointer adjustment around calls if the adjustment is 0. Previously, you'd get addl 0, fpr subl 0, fpr which are useless. --- scheme/ikarus.compiler.altcogen.ss | 28 +++++++++++++++++----------- scheme/ikarus.compiler.ss | 14 ++++++++++---- scheme/last-revision | 2 +- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/scheme/ikarus.compiler.altcogen.ss b/scheme/ikarus.compiler.altcogen.ss index 45658f3..9c4efdb 100644 --- a/scheme/ikarus.compiler.altcogen.ss +++ b/scheme/ikarus.compiler.altcogen.ss @@ -2367,14 +2367,20 @@ (when (< padding 0) (error 'compile-call-frame "call sequence too long" call-sequence)) (list 'seq + (if (or (= framesize 0) (= framesize 1)) + '(seq) + `(subl ,(* (fxsub1 framesize) wordsize) ,fpr)) (jmp L_CALL) `(byte-vector ,livemask-vec) - `(int ,framesize) + `(int ,(* framesize wordsize)) '(current-frame-offset) multiarg-rp `(byte-vector ,(make-vector padding 0)) L_CALL - call-sequence))) + call-sequence + (if (or (= framesize 0) (= framesize 1)) + '(seq) + `(addl ,(* (fxsub1 framesize) wordsize) ,fpr))))) @@ -2479,33 +2485,33 @@ (label-address (sl-mv-ignore-rp-label)))) (cond [(string? target) ;; foreign call - (cons* `(subl ,(* (fxsub1 size) wordsize) ,fpr) + (cons* ;`(subl ,(* (fxsub1 size) wordsize) ,fpr) `(movl (foreign-label "ik_foreign_call") %ebx) (compile-call-frame - (* size wordsize) + size mask (rp-label value) `(call %ebx)) - `(addl ,(* (fxsub1 size) wordsize) ,fpr) + ;`(addl ,(* (fxsub1 size) wordsize) ,fpr) ac)] [target ;;; known call - (cons* `(subl ,(* (fxsub1 size) wordsize) ,fpr) + (cons* ;`(subl ,(* (fxsub1 size) wordsize) ,fpr) (compile-call-frame - (* size wordsize) + size mask (rp-label value) `(call (label ,target))) - `(addl ,(* (fxsub1 size) wordsize) ,fpr) + ;`(addl ,(* (fxsub1 size) wordsize) ,fpr) ac)] [else - (cons* `(subl ,(* (fxsub1 size) wordsize) ,fpr) + (cons* ;`(subl ,(* (fxsub1 size) wordsize) ,fpr) (compile-call-frame - (* size wordsize) + size mask (rp-label value) `(call (disp ,(fx- disp-closure-code closure-tag) ,cp-register))) - `(addl ,(* (fxsub1 size) wordsize) ,fpr) + ;`(addl ,(* (fxsub1 size) wordsize) ,fpr) ac)]))] [(asm-instr op d s) (case op diff --git a/scheme/ikarus.compiler.ss b/scheme/ikarus.compiler.ss index 6b5496e..4b18db7 100644 --- a/scheme/ikarus.compiler.ss +++ b/scheme/ikarus.compiler.ss @@ -2409,14 +2409,14 @@ (cmpl (int closure-tag) ebx) (jne (label (sl-nonprocedure-error-label))) (movl (int (argc-convention 0)) eax) - (subl (int (fx* wordsize 2)) fpr) + ;(subl (int (fx* wordsize 2)) fpr) (compile-call-frame - (* wordsize 3) + 3 '#(#b110) (label-address L_cwv_multi_rp) (indirect-cpr-call)) ;;; one value returned - (addl (int (fx* wordsize 2)) fpr) + ;(addl (int (fx* wordsize 2)) fpr) (movl (mem (fx* -2 wordsize) fpr) ebx) ; consumer (movl ebx cpr) (movl eax (mem (fx- 0 wordsize) fpr)) @@ -2529,6 +2529,12 @@ (tail-indirect-cpr-call)))) SL_fx+_overflow])) +(define (print-instr x) + (cond + [(and (pair? x) (eq? (car x) 'seq)) + (for-each print-instr (cdr x))] + [else + (printf " ~s\n" x)])) (define (compile-core-expr->code p) (let* ([p (recordize p)] @@ -2548,7 +2554,7 @@ (for-each (lambda (ls) (newline) - (for-each (lambda (x) (printf " ~s\n" x)) ls)) + (for-each print-instr ls)) ls*))) (let ([code* (assemble-sources diff --git a/scheme/last-revision b/scheme/last-revision index 7345521..a369ea6 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1336 +1337