#| -*-Scheme-*-
-$Id: lapgn1.scm,v 4.14 1992/12/30 14:13:35 gjr Exp $
+$Id: lapgn1.scm,v 4.15 1993/08/26 05:47:34 gjr Exp $
-Copyright (c) 1987-1992 Massachusetts Institute of Technology
+Copyright (c) 1987-1993 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
(assq (rtl:expression-type (rtl:assign-address rtl))
*assign-rules*)))
(or (and rules (pattern-lookup (cdr rules) rtl))
- (pattern-lookup *assign-variable-rules* rtl)))))
\ No newline at end of file
+ (pattern-lookup *assign-variable-rules* rtl)))))
+\f
+;;; Instruction sequence sharing mechanisms
+
+(define *block-associations*)
+
+(define (block-association token)
+ (let ((place (assq token *block-associations*)))
+ (and place (cdr place))))
+
+(define (block-associate! token frob)
+ (set! *block-associations*
+ (cons (cons token frob)
+ *block-associations*))
+ unspecific)
+
+;; This can only be used when the instruction sequences are bit-wise identical.
+;; In other words, no variable registers, constants, etc.
+
+(define (share-instruction-sequence! name if-shared generator)
+ (cond ((block-association name)
+ => if-shared)
+ (else
+ (let ((label (generate-label name)))
+ (block-associate! name label)
+ (generator label)))))
+
+(define (make-new-sblock instructions)
+ (let ((bblock (make-sblock instructions)))
+ (node-mark! bblock)
+ bblock))
+
+(define (current-bblock-continue! bblock)
+ (let ((current-bblock *current-bblock*))
+ (if (sblock-continuation current-bblock)
+ (error "current-bblock-continue! bblock already has a continuation"
+ current-bblock)
+ (begin
+ (create-edge! current-bblock set-snode-next-edge! bblock)
+ (set-bblock-continuations! current-bblock (list bblock))
+ (set-sblock-continuation! current-bblock bblock)))))
\ No newline at end of file
#| -*-Scheme-*-
-$Id: rules3.scm,v 1.26 1993/07/16 19:27:55 gjr Exp $
+$Id: rules3.scm,v 1.27 1993/08/26 05:45:40 gjr Exp $
Copyright (c) 1992-1993 Massachusetts Institute of Technology
(define-rule statement
(POP-RETURN)
- (LAP ,@(clear-map!)
- ,@(clear-continuation-type-code)
- (RET)))
+ (cond ((block-association 'POP-RETURN)
+ => current-bblock-continue!)
+ (else
+ (let ((bblock
+ (make-new-sblock
+ (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)
+ (LABEL ,interrupt-label)
+ ,@(invoke-hook
+ entry:compiler-interrupt-continuation-2))))))
+ (block-associate! 'POP-RETURN bblock)
+ (current-bblock-continue! bblock))))
+ (clear-map!))
(define-rule statement
(INVOCATION:APPLY (? frame-size) (? continuation))
(define-rule statement
(CONTINUATION-HEADER (? internal-label))
+ #|
(simple-procedure-header (continuation-code-word internal-label)
internal-label
- entry:compiler-interrupt-continuation))
+ entry:compiler-interrupt-continuation)
+ |#
+ (make-external-label (continuation-code-word internal-label)
+ internal-label))
(define-rule statement
(IC-PROCEDURE-HEADER (? internal-label))
0)))
(MOV W (@RO B ,regnum:free-pointer -4) ,temp))))))
\f
+(define closure-share-names
+ '#(
+ closure-0-interrupt closure-1-interrupt closure-2-interrupt closure-3-interrupt
+ closure-4-interrupt closure-5-interrupt closure-6-interrupt closure-7-interrupt
+ ))
+
(define (generate/closure-header internal-label nentries entry)
nentries ; ignored
- (let ((rtl-proc (label->object internal-label)))
- (let ((gc-label (generate-label))
- (external-label (rtl-procedure/external-label rtl-proc)))
- (if (zero? nentries)
- (LAP (EQUATE ,external-label ,internal-label)
- ,@(simple-procedure-header
- (internal-procedure-code-word rtl-proc)
- internal-label
- entry:compiler-interrupt-procedure))
- (LAP (LABEL ,gc-label)
- ,@(if (zero? entry)
- (LAP)
- (LAP (ADD W (@R ,esp) (& ,(* 10 entry)))))
- ,@(invoke-hook entry:compiler-interrupt-closure)
- ,@(make-external-label internal-entry-code-word
- external-label)
- (ADD W (@R ,esp)
- (&U ,(generate/make-magic-closure-constant entry)))
- (LABEL ,internal-label)
- ,@(interrupt-check internal-label gc-label))))))
+ (let* ((rtl-proc (label->object internal-label))
+ (external-label (rtl-procedure/external-label rtl-proc)))
+ (if (zero? nentries)
+ (LAP (EQUATE ,external-label ,internal-label)
+ ,@(simple-procedure-header
+ (internal-procedure-code-word rtl-proc)
+ internal-label
+ entry:compiler-interrupt-procedure))
+ (let ((prefix
+ (lambda (gc-label)
+ (LAP (LABEL ,gc-label)
+ ,@(if (zero? entry)
+ (LAP)
+ (LAP (ADD W (@R ,esp) (& ,(* 10 entry)))))
+ ,@(invoke-hook entry:compiler-interrupt-closure))))
+ (suffix
+ (lambda (gc-label)
+ (LAP ,@(make-external-label internal-entry-code-word
+ external-label)
+ (ADD W (@R ,esp)
+ (&U ,(generate/make-magic-closure-constant entry)))
+ (LABEL ,internal-label)
+ ,@(interrupt-check internal-label gc-label)))))
+ (if (>= entry (vector-length closure-share-names))
+ (let ((gc-label (generate-label)))
+ (LAP ,@(prefix gc-label)
+ ,@(suffix gc-label)))
+ (share-instruction-sequence!
+ (vector-ref closure-share-names entry)
+ suffix
+ (lambda (gc-label)
+ (LAP ,@(prefix gc-label)
+ ,@(suffix gc-label)))))))))
(define (generate/make-magic-closure-constant entry)
(- (make-non-pointer-literal (ucode-type compiled-entry) 0)