Changeset 11783


Ignore:
Timestamp:
04/25/09 14:19:51 (15 years ago)
Author:
ehuelsmann
Message:

Fix fasl reader special bindings leak.

  • Bind the *FASL-ANONYMOUS-PACKAGE* to the outer most scope which needs one, instead of binding it upon first use. Specials shouldn't be bound with indefinite extent: some other code might limit the extent by unbinding its specials.
Location:
trunk/abcl/src/org/armedbear/lisp
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/FaslReader.java

    r11488 r11783  
    285285            Symbol symbol = (Symbol) stream.readSymbol(FaslReadtable.getInstance());
    286286            LispObject pkg = Load._FASL_ANONYMOUS_PACKAGE_.symbolValue(thread);
    287             if (pkg == NIL) {
    288                 thread.bindSpecial(Load._FASL_ANONYMOUS_PACKAGE_,
    289                                    pkg = new Package());
    290             }
     287            Debug.assertTrue(pkg != NIL);
    291288            symbol = ((Package)pkg).intern(symbol.getName());
    292289            symbol.setPackage(NIL);
  • trunk/abcl/src/org/armedbear/lisp/Load.java

    r11714 r11783  
    345345    // ### *fasl-anonymous-package*
    346346    // internal symbol
     347    /**
     348     * This variable gets bound to a package with no name in which the
     349     * reader can intern its uninterned symbols.
     350     *
     351     */
    347352    public static final Symbol _FASL_ANONYMOUS_PACKAGE_ =
    348353        internSpecial("*FASL-ANONYMOUS-PACKAGE*", PACKAGE_SYS, NIL);
     
    474479        Stream in = (Stream) _LOAD_STREAM_.symbolValue(thread);
    475480        final Environment env = new Environment();
    476         while (true) {
    477             LispObject obj = in.faslRead(false, EOF, true, thread);
    478             if (obj == EOF)
    479                 break;
    480             eval(obj, env, thread);
     481        final SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
     482        try {
     483            thread.bindSpecial(_FASL_ANONYMOUS_PACKAGE_, new Package());
     484            while (true) {
     485                LispObject obj = in.faslRead(false, EOF, true, thread);
     486                if (obj == EOF)
     487                    break;
     488                eval(obj, env, thread);
     489            }
     490        }
     491        finally {
     492            thread.lastSpecialBinding = lastSpecialBinding;
    481493        }
    482494        return T;
  • trunk/abcl/src/org/armedbear/lisp/Primitives.java

    r11772 r11783  
    30183018    new Primitive("%make-package", PACKAGE_SYS, false)
    30193019    {
     3020      /**
     3021       * This invocation is solely used to be able to create
     3022       * a package to bind to *FASL-ANONYMOUS-PACKAGE*
     3023       */
     3024      @Override
     3025      public LispObject execute()
     3026        throws ConditionThrowable
     3027      {
     3028        return new Package();
     3029      }
     3030
     3031      /**
     3032       * This invocation is used by MAKE-PACKAGE to create a package
     3033       */
    30203034      @Override
    30213035      public LispObject execute(LispObject first, LispObject second,
  • trunk/abcl/src/org/armedbear/lisp/Stream.java

    r11754 r11783  
    519519    else
    520520      {
     521        SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
    521522        thread.bindSpecial(_SHARP_EQUAL_ALIST_, NIL);
    522         return faslReadPreservingWhitespace(eofError, eofValue, true, thread);
     523        try
     524          {
     525            return faslReadPreservingWhitespace(eofError, eofValue, true, thread);
     526          }
     527        finally
     528          {
     529            thread.lastSpecialBinding = lastSpecialBinding;
     530          }
    523531      }
    524532  }
  • trunk/abcl/src/org/armedbear/lisp/compile-file.lisp

    r11765 r11783  
    428428                  (*explain* *explain*)
    429429                  (jvm::*functions-defined-in-current-file* '())
    430                   (*fbound-names* '()))
     430                  (*fbound-names* '())
     431                  (*fasl-anonymous-package* (%make-package)))
    431432              (jvm::with-file-compilation
    432433                (write "; -*- Mode: Lisp -*-" :escape nil :stream out)
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11782 r11783  
    50205020         (set-compiland-and-write-class-file class-file compiland)
    50215021         (setf (local-function-class-file local-function) class-file)
    5022          (setf (local-function-function local-function) (load-compiled-function pathname))
     5022         (setf (local-function-function local-function)
     5023                     (load-compiled-function pathname))
    50235024         (when (local-function-variable local-function)
    50245025     (let ((g (declare-object (load-compiled-function pathname))))
  • trunk/abcl/src/org/armedbear/lisp/jvm.lisp

    r11719 r11783  
    414414(defun compile (name &optional definition)
    415415  (let ((*file-compilation* nil)
    416         (*pathnames-generator* #'make-temp-file))
     416        (*pathnames-generator* #'make-temp-file)
     417        (sys::*fasl-anonymous-package* (sys::%make-package)))
    417418    (jvm-compile name definition)))
    418419
Note: See TracChangeset for help on using the changeset viewer.