Changeset 11780


Ignore:
Timestamp:
04/24/09 19:51:45 (13 years ago)
Author:
ehuelsmann
Message:

Clean up the known symbols cache:

  • instead of returning only the name of the field, also return the containing class
  • unify the SYMBOLS and KEYWORDS hashes into a single hash allowing extension when required
  • enlarge the symbols cache: there were 1057 symbols to be stored in a hash of 1024 initial size
Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11764 r11780  
    29582958               (emit 'getstatic *this-class* g +lisp-object+)))
    29592959            (t
    2960              (let ((name (lookup-known-symbol op)))
     2960             (multiple-value-bind
     2961                   (name class)
     2962                 (lookup-known-symbol op)
    29612963               (if name
    2962                    (emit 'getstatic +lisp-symbol-class+ name +lisp-symbol+)
     2964                   (emit 'getstatic class name +lisp-symbol+)
    29632965                   (emit 'getstatic *this-class* (declare-symbol op) +lisp-symbol+)))))
    29642966      (process-args args)
     
    49224924           (emit 'iconst_1)
    49234925           (emit-move-from-stack target representation))
    4924           ((keywordp obj)
    4925            (let ((name (lookup-known-keyword obj)))
    4926               (if name
    4927                   (emit 'getstatic "org/armedbear/lisp/Keyword" name +lisp-symbol+)
    4928                   (emit 'getstatic *this-class* (declare-keyword obj) +lisp-symbol+)))
    4929             (emit-move-from-stack target representation))
    49304926          ((symbolp obj)
    4931            (let ((name (lookup-known-symbol obj)))
     4927           (multiple-value-bind
     4928                 (name class)
     4929               (lookup-known-symbol obj)
    49324930             (cond (name
    4933                     (emit 'getstatic +lisp-symbol-class+ name +lisp-symbol+))
     4931                    (emit 'getstatic class name +lisp-symbol+))
    49344932                   ((symbol-package (truly-the symbol obj))
    4935                     (emit 'getstatic *this-class* (declare-symbol obj) +lisp-symbol+))
     4933                    (emit 'getstatic *this-class* (declare-symbol obj)
     4934                          +lisp-symbol+))
    49364935                   (t
    49374936                    ;; An uninterned symbol.
     
    80098008                   (emit 'iconst_1))
    80108009                  ((nil)
    8011                    (let ((name (lookup-known-keyword form)))
     8010                   (multiple-value-bind
     8011                         (name class)
     8012                       (lookup-known-symbol form)
    80128013                     (if name
    8013                          (emit 'getstatic "org/armedbear/lisp/Keyword" name +lisp-symbol+)
    8014                          (emit 'getstatic *this-class* (declare-keyword form) +lisp-symbol+)))))
     8014                         (emit 'getstatic class name +lisp-symbol+)
     8015                         (emit 'getstatic *this-class* (declare-keyword form)
     8016                               +lisp-symbol+)))))
    80158017                (emit-move-from-stack target representation))
    80168018               (t
  • trunk/abcl/src/org/armedbear/lisp/known-symbols.lisp

    r11391 r11780  
    3232(in-package #:system)
    3333
    34 (export '(lookup-known-symbol lookup-known-keyword))
     34(export '(lookup-known-symbol))
    3535
    36 (let ((symbols (make-hash-table :test 'eq :size 1024))
    37       (keywords (make-hash-table :test 'eq :size 128)))
     36(let ((symbols (make-hash-table :test 'eq :size 2048)))
    3837  (defun initialize-known-symbols (source ht)
    39     (clrhash ht)
    4038    (let* ((source-class (java:jclass source))
     39           (class-designator (substitute #\/ #\. source))
    4140           (symbol-class (java:jclass "org.armedbear.lisp.Symbol"))
    4241           (fields (java:jclass-fields source-class :declared t :public t)))
     
    4746            (let* ((name (java:jfield-name field))
    4847                   (symbol (java:jfield source-class name)))
    49               (puthash symbol ht name))))))
     48              (puthash symbol ht (list name class-designator)))))))
    5049    (hash-table-count ht))
    5150
    5251  (initialize-known-symbols "org.armedbear.lisp.Symbol" symbols)
    53   (initialize-known-symbols "org.armedbear.lisp.Keyword" keywords)
     52  (initialize-known-symbols "org.armedbear.lisp.Keyword" symbols)
    5453
    5554  (defun lookup-known-symbol (symbol)
    56     (gethash1 symbol symbols))
     55    "Returns the name of the field and its class designator
     56which stores the Java object `symbol'."
     57    (values-list (gethash1 symbol symbols))))
    5758
    58   (defun lookup-known-keyword (keyword)
    59     (gethash1 keyword keywords)))
    6059
    6160(provide '#:known-symbols)
Note: See TracChangeset for help on using the changeset viewer.