Changeset 12398 in project for chicken/trunk/compiler.scm


Ignore:
Timestamp:
11/07/08 15:11:26 (12 years ago)
Author:
felix winkelmann
Message:

allocation estimation in preparation phase of the compiler takes maximum allocation for each conditional branch, not sum

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/compiler.scm

    r12301 r12398  
    25852585                   (else (make-node '##core#literal (list (literal c)) '())) ) ) )
    25862586
    2587           ;;*** conditionals (if + ##core#cond) are missing here: allocation
    2588           ;; calculation should use max of both branches, not sum.
     2587          ((if ##core#cond)
     2588           (let* ((test (walk (first subs) e here boxes))
     2589                  (a0 allocated)
     2590                  (x1 (walk (second subs) e here boxes))
     2591                  (a1 allocated)
     2592                  (x2 (walk (third subs) e here boxes)))
     2593             (set! allocated (+ a0 (max (- allocated a1) (- a1 a0))))
     2594             (make-node class params (list test x1 x2))))
     2595
     2596          ((##core#switch)
     2597           (let* ((exp (walk (first subs) e here boxes))
     2598                  (a0 allocated))
     2599             (make-node
     2600              class
     2601              params
     2602              (cons
     2603               exp
     2604               (let loop ((j (first params)) (subs (cdr subs)) (ma 0))
     2605                 (set! allocated a0)
     2606                 (if (zero? j)
     2607                     (let ((def (walk (car subs) e here boxes)))
     2608                       (set! allocated (+ a0 (max ma (- allocated a0))))
     2609                       (list def))
     2610                     (let* ((const (walk (car subs) e here boxes))
     2611                            (body (walk (cadr subs) e here boxes)))
     2612                       (cons*
     2613                        const body
     2614                        (loop (sub1 j) (cddr subs) (max (- allocated a0) ma))))))))))
    25892615
    25902616          (else (make-node class params (mapwalk subs e here boxes)) ) ) ) )
Note: See TracChangeset for help on using the changeset viewer.