Changeset 12706


Ignore:
Timestamp:
05/18/10 22:39:43 (12 years ago)
Author:
astalla
Message:

Split potentially huge CASE in the fasl-loader in multiple smaller sub-CASEs to avoid stack overflow in the precompiler for big FASLs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/less-reflection/abcl/src/org/armedbear/lisp/compile-file.lisp

    r12698 r12706  
    666666    (values (truename output-file) warnings-p failure-p)))
    667667
     668(defmacro ncase (expr min max &rest clauses)
     669  "A CASE where all test clauses are numbers ranging from a minimum to a maximum."
     670  ;;Expr is subject to multiple evaluation, but since we only use ncase for
     671  ;;fn-index below, let's ignore it.
     672  (let* ((half (floor (/ (- max min) 2)))
     673   (middle (+ min half)))
     674    (if (> (- max min) 10)
     675  `(if (< ,expr ,middle)
     676       (ncase ,expr ,min ,middle ,@(subseq clauses 0 half))
     677       (ncase ,expr ,middle ,max ,@(subseq clauses half)))
     678  `(case ,expr ,@clauses))))
     679
    668680(defun generate-loader-function ()
    669681  (let* ((basename (base-classname))
    670682   (expr `(lambda (fasl-loader fn-index)
    671683      (identity fasl-loader) ;;to avoid unused arg
    672       (ecase fn-index
     684      (ncase fn-index 0 ,(1- *class-number*)
    673685        ,@(loop
    674686       :for i :from 1 :to *class-number*
Note: See TracChangeset for help on using the changeset viewer.