Changeset 12297
- Timestamp:
- 12/08/09 21:46:36 (13 years ago)
- Location:
- branches/fast-boot-preloading/abcl/src/org/armedbear/lisp
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Autoload.java
r12288 r12297 665 665 autoload(PACKAGE_SYS, "zip", "zip", true); 666 666 667 autoload(PACKAGE_SYS, "proxy-preloaded-function", 668 "AutoloadedFunctionProxy", false); 669 autoload(PACKAGE_SYS, "make-function-preloading-context", 670 "AutoloadedFunctionProxy", false); 671 autoload(PACKAGE_SYS, "function-preload", 672 "AutoloadedFunctionProxy", false); 673 667 674 autoload(Symbol.COPY_LIST, "copy_list"); 668 675 -
branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/CompiledClosure.java
r12288 r12297 220 220 else if (arg instanceof AbstractString) 221 221 namestring = arg.getStringValue(); 222 if (namestring != null) 223 return loadCompiledFunction(namestring); 222 if (namestring != null) { 223 // Debug.trace("autoloading preloaded ... " + namestring); 224 return AutoloadedFunctionProxy.loadPreloadedFunction(namestring); 225 } 224 226 if(arg instanceof JavaObject) { 225 227 try { 226 return loadC ompiledFunction((byte[]) arg.javaInstance(byte[].class));228 return loadClassBytes((byte[]) arg.javaInstance(byte[].class)); 227 229 } catch(Throwable t) { 228 230 Debug.trace(t); -
branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Lisp.java
r12288 r12297 1225 1225 1226 1226 { 1227 try { 1228 byte[] bytes = readFunctionBytes(namestring); 1229 if (bytes != null) 1230 return loadClassBytes(bytes); 1231 } 1232 catch (VerifyError e) 1233 { 1234 return error(new LispError("Class verification failed: " + 1235 e.getMessage())); 1236 } 1237 catch (Throwable t) 1238 { 1239 Debug.trace(t); 1240 } 1241 return error(new FileError("File not found: " + namestring, 1242 new Pathname(namestring))); 1243 } 1244 1245 public static final byte[] readFunctionBytes(final String namestring) 1246 { 1227 1247 final LispThread thread = LispThread.currentThread(); 1228 1248 final boolean absolute = Utilities.isFilenameAbsolute(namestring); … … 1297 1317 long size = entry.getSize(); 1298 1318 InputStream in = zipFile.getInputStream(entry); 1299 LispObject obj = loadCompiledFunction(in, (int) size); 1300 return obj != null ? obj : NIL; 1319 return readFunctionBytes(in, (int) size); 1301 1320 } 1302 1321 else … … 1306 1325 = defaultPathname.name.getStringValue() 1307 1326 + "." + "abcl";//defaultPathname.type.getStringValue(); 1308 byte in[] 1309 = Utilities 1310 .getZippedZipEntryAsByteArray(zipFile, 1327 return Utilities 1328 .getZippedZipEntryAsByteArray(zipFile, 1311 1329 entryName, 1312 1330 namestring); 1313 LispObject o = loadCompiledFunction(in);1314 return o != null ? o : NIL;1315 1331 } 1316 1332 } … … 1324 1340 catch (VerifyError e) 1325 1341 { 1326 return error(new LispError("Class verification failed: " + 1327 e.getMessage())); 1342 error(new LispError("Class verification failed: " + 1343 e.getMessage())); 1344 return null; // not reached 1328 1345 } 1329 1346 catch (IOException e) … … 1336 1353 } 1337 1354 } 1338 return error(new LispError("Unable to load " + namestring)); 1355 error(new LispError("Unable to load " + namestring)); 1356 return null; // not reached 1339 1357 } 1340 1358 Pathname pathname = new Pathname(namestring); … … 1345 1363 try 1346 1364 { 1347 LispObject obj = loadCompiledFunction(new FileInputStream(file),1348 1365 byte[] bytes = readFunctionBytes(new FileInputStream(file), 1366 (int) file.length()); 1349 1367 // FIXME close stream! 1350 if ( obj!= null)1351 return obj;1368 if (bytes != null) 1369 return bytes; 1352 1370 } 1353 1371 catch (VerifyError e) 1354 1372 { 1355 return error(new LispError("Class verification failed: " + 1356 e.getMessage())); 1373 error(new LispError("Class verification failed: " + 1374 e.getMessage())); 1375 return null; // not reached 1357 1376 } 1358 1377 catch (Throwable t) … … 1360 1379 Debug.trace(t); 1361 1380 } 1362 return error(new LispError("Unable to load " +1363 pathname.writeToString()));1381 error(new LispError("Unable to load " + pathname.writeToString())); 1382 return null; // not reached 1364 1383 } 1365 1384 try … … 1373 1392 if (entry != null) 1374 1393 { 1375 LispObject obj = loadCompiledFunction(zipFile.getInputStream(entry),1376 1377 if ( obj!= null)1378 return obj;1394 byte[] bytes = readFunctionBytes(zipFile.getInputStream(entry), 1395 (int) entry.getSize()); 1396 if (bytes != null) 1397 return bytes; 1379 1398 Debug.trace("Unable to load " + namestring); 1380 return error(new LispError("Unable to load " + namestring)); 1399 error(new LispError("Unable to load " + namestring)); 1400 return null; // not reached 1381 1401 } 1382 1402 } … … 1390 1410 Debug.trace(t); 1391 1411 } 1392 return error(new FileError("File not found: " + namestring, 1393 new Pathname(namestring))); 1394 } 1395 1396 public static final LispObject makeCompiledFunctionFromClass(Class<?> c) 1397 throws Exception { 1412 error(new FileError("File not found: " + namestring, 1413 new Pathname(namestring))); 1414 return null; // not reached 1415 } 1416 1417 public static final Function makeCompiledFunctionFromClass(Class<?> c) { 1418 try { 1398 1419 if (c != null) { 1399 LispObject obj = (LispObject)c.newInstance();1420 Function obj = (Function)c.newInstance(); 1400 1421 return obj; 1401 1422 } else { 1402 1423 return null; 1403 1424 } 1425 } 1426 catch (InstantiationException e) {} // ### FIXME 1427 catch (IllegalAccessException e) {} // ### FIXME 1428 1429 return null; 1404 1430 } 1405 1431 1406 private static final LispObject loadCompiledFunction(InputStream in, int size) 1432 1433 public static final LispObject loadCompiledFunction(InputStream in, int size) 1434 { 1435 try { 1436 byte[] bytes = readFunctionBytes(in, size); 1437 if (bytes != null) 1438 return loadClassBytes(bytes); 1439 } 1440 catch (VerifyError e) 1441 { 1442 return error(new LispError("Class verification failed: " + 1443 e.getMessage())); 1444 } 1445 catch (Throwable t) 1446 { 1447 Debug.trace(t); 1448 } 1449 return error(new FileError("Can't read file off stream.")); 1450 } 1451 1452 1453 1454 private static final byte[] readFunctionBytes(InputStream in, int size) 1407 1455 { 1408 1456 try … … 1423 1471 Debug.trace("bytesRemaining = " + bytesRemaining); 1424 1472 1425 return loadCompiledFunction(bytes);1473 return bytes; 1426 1474 } 1427 1475 catch (Throwable t) … … 1432 1480 } 1433 1481 1434 public static final LispObject loadCompiledFunction(byte[] bytes) throws Throwable { 1435 return loadCompiledFunction(bytes, new JavaClassLoader()); 1482 public static final Function loadClassBytes(byte[] bytes) 1483 throws Throwable 1484 { 1485 return loadClassBytes(bytes, new JavaClassLoader()); 1436 1486 } 1437 1487 1438 public static final LispObject loadCompiledFunction(byte[] bytes, JavaClassLoader cl) throws Throwable { 1488 public static final Function loadClassBytes(byte[] bytes, 1489 JavaClassLoader cl) 1490 throws Throwable 1491 { 1439 1492 Class<?> c = cl.loadClassFromByteArray(null, bytes, 0, bytes.length); 1440 LispObjectobj = makeCompiledFunctionFromClass(c);1441 if (obj instanceof Function) {1442 ((Function)obj).setClassBytes(bytes);1493 Function obj = makeCompiledFunctionFromClass(c); 1494 if (obj != null) { 1495 obj.setClassBytes(bytes); 1443 1496 } 1444 1497 return obj; … … 2472 2525 exportSpecial("*AUTOLOAD-VERBOSE*", PACKAGE_EXT, NIL); 2473 2526 2527 // ### *preloading-cache* 2528 public static final Symbol AUTOLOADING_CACHE = 2529 internSpecial("*AUTOLOADING-CACHE*", PACKAGE_SYS, NIL); 2530 2474 2531 // ### *compile-file-type* 2475 2532 public static final String COMPILE_FILE_TYPE = "abcl"; -
branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Load.java
r12290 r12297 45 45 import java.net.URL; 46 46 import java.net.URLDecoder; 47 import java.util.Hashtable; 47 48 import java.util.zip.ZipEntry; 48 49 import java.util.zip.ZipException; … … 609 610 try { 610 611 thread.bindSpecial(_FASL_ANONYMOUS_PACKAGE_, new Package()); 612 thread.bindSpecial(AUTOLOADING_CACHE, 613 AutoloadedFunctionProxy.makePreloadingContext()); 611 614 while (true) { 612 615 LispObject obj = in.faslRead(false, EOF, true, thread); -
branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/Symbol.java
r12288 r12297 3031 3031 public static final Symbol FSET = 3032 3032 PACKAGE_SYS.addInternalSymbol("FSET"); 3033 public static final Symbol FUNCTION_PRELOAD = 3034 PACKAGE_SYS.addInternalSymbol("FUNCTION-PRELOAD"); 3033 3035 public static final Symbol INSTANCE = 3034 3036 PACKAGE_SYS.addInternalSymbol("INSTANCE"); 3035 3037 public static final Symbol MACROEXPAND_MACRO = 3036 3038 PACKAGE_SYS.addInternalSymbol("MACROEXPAND-MACRO"); 3039 public static final Symbol MAKE_FUNCTION_PRELOADING_CONTEXT = 3040 PACKAGE_SYS.addInternalSymbol("MAKE-FUNCTION-PRELOADING-CONTEXT"); 3037 3041 public static final Symbol NAME = 3038 3042 PACKAGE_SYS.addInternalSymbol("NAME"); … … 3043 3047 public static final Symbol OPERATION = 3044 3048 PACKAGE_SYS.addInternalSymbol("OPERATION"); 3049 public static final Symbol PROXY_PRELOADED_FUNCTION = 3050 PACKAGE_SYS.addInternalSymbol("PROXY-PRELOADED-FUNCTION"); 3045 3051 public static final Symbol _SOURCE = 3046 3052 PACKAGE_SYS.addInternalSymbol("%SOURCE"); -
branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/compile-file.lisp
r12229 r12297 161 161 (setf form 162 162 `(fset ',name 163 ( load-compiled-function,(file-namestring classfile))163 (proxy-preloaded-function ',name ,(file-namestring classfile)) 164 164 ,*source-position* 165 165 ',lambda-list … … 485 485 (temp-file (merge-pathnames (make-pathname :type (concatenate 'string type "-tmp")) 486 486 output-file)) 487 (temp-file2 (merge-pathnames (make-pathname :type (concatenate 'string type "-tmp2")) 488 output-file)) 487 489 (warnings-p nil) 488 490 (failure-p nil)) … … 511 513 (jvm::with-saved-compiler-policy 512 514 (jvm::with-file-compilation 513 (write "; -*- Mode: Lisp -*-" :escape nil :stream out)514 (%stream-terpri out)515 (let ((*package* (find-package '#:cl)))516 (write (list 'init-fasl :version *fasl-version*)517 :stream out)518 (%stream-terpri out)519 (write (list 'setq '*source* *compile-file-truename*)520 :stream out)521 (%stream-terpri out))522 515 (handler-bind ((style-warning #'(lambda (c) 523 516 (setf warnings-p t) … … 545 538 (dolist (name *fbound-names*) 546 539 (fmakunbound name))))))) 547 (rename-file temp-file output-file) 540 (with-open-file (in temp-file :direction :input) 541 (with-open-file (out temp-file2 :direction :output 542 :if-does-not-exist :create 543 :if-exists :supersede) 544 ;; write header 545 (write "; -*- Mode: Lisp -*-" :escape nil :stream out) 546 (%stream-terpri out) 547 (let ((*package* (find-package '#:cl)) 548 (count-sym (gensym))) 549 (write (list 'init-fasl :version *fasl-version*) 550 :stream out) 551 (%stream-terpri out) 552 (write (list 'setq '*source* *compile-file-truename*) 553 :stream out) 554 (%stream-terpri out) 555 (dump-form `(dotimes (,count-sym ,*class-number*) 556 (function-preload 557 (%format nil "~A-~D.cls" ,(pathname-name output-file) 558 (1+ ,count-sym)))) out) 559 (%stream-terpri out)) 560 561 562 ;; copy remaining content 563 (loop for line = (read-line in nil :eof) 564 while (not (eq line :eof)) 565 do (write-line line out)))) 566 (delete-file temp-file) 567 (rename-file temp-file2 output-file) 548 568 549 569 (when *compile-file-zip* -
branches/fast-boot-preloading/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r12272 r12297 2071 2071 (declare-field g +lisp-object+ +field-access-default+) 2072 2072 (emit 'ldc (pool-string (file-namestring pathname))) 2073 (emit-invokestatic +lisp-class+ "loadCompiledFunction"2073 (emit-invokestatic "org/armedbear/lisp/AutoloadedFunctionProxy" "loadPreloadedFunction" 2074 2074 (list +java-string+) +lisp-object+) 2075 2075 (emit 'putstatic *this-class* g +lisp-object+)
Note: See TracChangeset
for help on using the changeset viewer.