Changeset 12699 for trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
- Timestamp:
- 05/17/10 20:33:29 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r12692 r12699 2073 2073 ;; This way, the serialize-* functions can be used to depend on 2074 2074 ;; each other to serialize nested constructs. They are also the 2075 ;; building blocks of the E XTERNALIZE-OBJECT function, which is2076 ;; called from the compiler.2075 ;; building blocks of the EMIT-LOAD-EXTERNALIZED-OBJECT function, 2076 ;; which is called from the compiler. 2077 2077 2078 2078 (defun serialize-integer (n) … … 2181 2181 5. The type of the field to save the serialized result to") 2182 2182 2183 (defknown e xternalize-object (t) string)2184 (defun e xternalize-object (object)2183 (defknown emit-load-externalized-object (t) string) 2184 (defun emit-load-externalized-object (object &optional cast) 2185 2185 "Externalizes `object' for use in a FASL. 2186 2186 … … 2206 2206 (let ((existing (assoc object *externalized-objects* :test similarity-fn))) 2207 2207 (when existing 2208 (return-from externalize-object (cdr existing)))) 2208 (emit 'getstatic *this-class* (cdr existing) field-type) 2209 (when cast 2210 (emit 'checkcast cast)) 2211 (return-from emit-load-externalized-object field-type))) 2209 2212 2210 2213 ;; We need to set up the serialized value … … 2222 2225 (setf *static-code* *code*))) 2223 2226 2224 field-name))) 2225 2226 (defknown declare-symbol (symbol) string) 2227 (defun declare-symbol (symbol) 2228 (cond 2229 ((and (not *file-compilation*) 2230 (null (symbol-package symbol))) 2231 (declare-object symbol +lisp-symbol+ +lisp-symbol-class+)) 2232 (t (externalize-object symbol)))) 2227 (emit 'getstatic *this-class* field-name field-type) 2228 (when cast 2229 (emit 'checkcast cast)) 2230 field-type))) 2233 2231 2234 2232 (defun emit-load-symbol (symbol) … … 2239 2237 (if name 2240 2238 (emit 'getstatic class name +lisp-symbol+) 2241 (emit 'getstatic *this-class* (declare-symbol symbol) +lisp-symbol+))))2239 (emit-load-externalized-object symbol)))) 2242 2240 2243 2241 (defknown declare-function (symbol &optional setf) string) … … 2260 2258 ;; EMIT-LOAD-SYMBOL wants to modify those specials too 2261 2259 (unless name 2262 (setf name (declare-symbol symbol) 2260 (setf name (if *file-compilation* 2261 (declare-object-as-string symbol) 2262 (declare-object symbol)) 2263 2263 class *this-class*)) 2264 2264 (let (saved-code) 2265 2265 (let ((*code* (if *declare-inline* *code* *static-code*))) 2266 (emit 'getstatic class name +lisp-symbol+) 2266 (if (eq class *this-class*) 2267 (progn ;; generated by the DECLARE-OBJECT*'s above 2268 (emit 'getstatic class name +lisp-object+) 2269 (emit 'checkcast +lisp-symbol-class+)) 2270 (emit 'getstatic class name +lisp-symbol+)) 2267 2271 (emit-invokevirtual +lisp-symbol-class+ 2268 2272 (if setf … … 2307 2311 (defknown declare-object-as-string (t) string) 2308 2312 (defun declare-object-as-string (obj) 2309 ;; TODO: replace with e xternalize-object2313 ;; TODO: replace with emit-load-externalized-object 2310 2314 ;; just replacing won't work however: 2311 2315 ;; field identification in Java includes the field type 2312 2316 ;; and we're not letting the caller know about the type of 2313 ;; field we're creating in e xternalize-object.2314 ;; The solution is t erewrite externalize-object to2317 ;; field we're creating in emit-load-externalized-object. 2318 ;; The solution is to rewrite externalize-object to 2315 2319 ;; EMIT-LOAD-EXTERNALIZED-OBJECT, which serializes *and* 2316 2320 ;; emits the right loading code (not just de-serialization anymore) … … 2433 2437 (emit-push-constant-int form)) 2434 2438 ((integerp form) 2435 (emit 'getstatic *this-class* (externalize-object form) 2436 +lisp-integer+) 2439 (emit-load-externalized-object form) 2437 2440 (emit-invokevirtual +lisp-object-class+ "intValue" nil "I")) 2438 2441 (t … … 2445 2448 (emit-push-constant-long form)) 2446 2449 ((integerp form) 2447 (emit 'getstatic *this-class* (externalize-object form) 2448 +lisp-integer+) 2450 (emit-load-externalized-object form) 2449 2451 (emit-invokevirtual +lisp-object-class+ "longValue" nil "J")) 2450 2452 (t … … 2490 2492 (return-from compile-constant)) 2491 2493 ((NIL))) 2492 (cond ((integerp form) 2493 (emit 'getstatic *this-class* (externalize-object form) 2494 +lisp-integer+)) 2495 ((typep form 'single-float) 2496 (emit 'getstatic *this-class* 2497 (externalize-object form) +lisp-single-float+)) 2498 ((typep form 'double-float) 2499 (emit 'getstatic *this-class* 2500 (externalize-object form) +lisp-double-float+)) 2501 ((numberp form) 2502 ;; A number, but not a fixnum. 2503 (emit 'getstatic *this-class* 2504 (declare-object-as-string form) +lisp-object+)) 2505 ((stringp form) 2494 (cond ((or (numberp form) 2495 (typep form 'single-float) 2496 (typep form 'double-float) 2497 (characterp form)) 2498 (emit-load-externalized-object form)) 2499 ((or (stringp form) 2500 (packagep form) 2501 (pathnamep form) 2502 (vectorp form)) 2506 2503 (if *file-compilation* 2507 (emit 'getstatic *this-class* 2508 (externalize-object form) +lisp-simple-string+) 2504 (emit-load-externalized-object form) 2509 2505 (emit 'getstatic *this-class* 2510 2506 (declare-object form) +lisp-object+))) 2511 ((vectorp form) 2512 (if *file-compilation* 2513 (emit 'getstatic *this-class* 2514 (declare-object-as-string form) +lisp-object+) 2515 (emit 'getstatic *this-class* 2516 (declare-object form) +lisp-object+))) 2517 ((characterp form) 2518 (emit 'getstatic *this-class* 2519 (externalize-object form) +lisp-character+)) 2520 ((or (hash-table-p form) (typep form 'generic-function)) 2507 ((or (hash-table-p form) 2508 (typep form 'generic-function)) 2521 2509 (emit 'getstatic *this-class* 2522 2510 (declare-object form) +lisp-object+)) 2523 ((pathnamep form)2524 (let ((g (if *file-compilation*2525 (declare-object-as-string form)2526 (declare-object form))))2527 (emit 'getstatic *this-class* g +lisp-object+)))2528 ((packagep form)2529 (let ((g (if *file-compilation*2530 (externalize-object form)2531 (declare-object form))))2532 (emit 'getstatic *this-class* g +lisp-object+)))2533 2511 ((or (structure-object-p form) 2534 2512 (standard-object-p form)
Note: See TracChangeset
for help on using the changeset viewer.