Raymond Toy pushed to branch native-image at cmucl / cmucl

Commits:

2 changed files:

Changes:

  • src/compiler/generic/new-genesis.lisp
    ... ... @@ -2448,7 +2448,7 @@
    2448 2448
       (and (>= (length string) (length head))
    
    2449 2449
            (string= string head :end1 (length head))))
    
    2450 2450
     
    
    2451
    -(defun emit-c-header-aux ()
    
    2451
    +(defun emit-c-header-aux (assembler-routines)
    
    2452 2452
       (format t "/*~% * Machine generated header file.  Do not edit.~% */~2%")
    
    2453 2453
       (format t "#ifndef _INTERNALS_H_~%#define _INTERNALS_H_~2%")
    
    2454 2454
       ;; Write out various constants
    
    ... ... @@ -2602,6 +2602,17 @@
    2602 2602
     			   (remove-if #'(lambda (char)
    
    2603 2603
     					  (member char '(#\% #\* #\.)))
    
    2604 2604
     				      (symbol-name feature))))))
    
    2605
    +
    
    2606
    +  (format t "~2%#if defined(DEFINE_ASM)~%")
    
    2607
    +  (format t "/* Assembly routines */~%")
    
    2608
    +  (format t "unsigned long lisp_asm_routines[] = {~%")
    
    2609
    +  (dolist (routine (sort (copy-list *cold-assembler-routines*)
    
    2610
    +			 #'< :key #'cdr))
    
    2611
    +    (format t "  0x~8,'0x, /* ~S */~%"
    
    2612
    +	    (cdr routine) (car routine)))
    
    2613
    +  (format t "  0x~8,'0x, /* End marker */~%" 0)
    
    2614
    +  (format t "};~%")
    
    2615
    +  (format t "#endif~%")
    
    2605 2616
       ;;
    
    2606 2617
       (format t "~%#endif~%"))
    
    2607 2618
     
    
    ... ... @@ -2622,14 +2633,14 @@
    2622 2633
     		      (string/= line1 line2))
    
    2623 2634
     	      (return t)))))))
    
    2624 2635
     
    
    2625
    -(defun emit-c-header (name)
    
    2636
    +(defun emit-c-header (name assembler-routines)
    
    2626 2637
       (let* ((new-name (concatenate 'string (namestring name) ".NEW"))
    
    2627 2638
     	 (unix-newname (unix-namestring new-name nil)))
    
    2628 2639
         (with-open-file
    
    2629 2640
     	(*standard-output* new-name
    
    2630 2641
     			   :direction :output
    
    2631 2642
     			   :if-exists :supersede)
    
    2632
    -      (emit-c-header-aux))
    
    2643
    +      (emit-c-header-aux assembler-routines))
    
    2633 2644
         (cond ((not (probe-file name))
    
    2634 2645
     	   (unix:unix-chmod unix-newname #o444)
    
    2635 2646
     	   (rename-file new-name name)
    
    ... ... @@ -2755,13 +2766,15 @@
    2755 2766
     				     :if-exists :supersede)
    
    2756 2767
     		(write-map-file)))
    
    2757 2768
     	    (when header-name
    
    2769
    +	      (format t "cold-assembler ~S~%" *cold-assembler-routines*)
    
    2758 2770
     	      (emit-c-header
    
    2759 2771
     	       (merge-pathnames (if (eq header-name t)
    
    2760 2772
     				    "internals.h"
    
    2761 2773
     				    (merge-pathnames
    
    2762 2774
     				     header-name
    
    2763 2775
     				     (make-pathname :type "h")))
    
    2764
    -				core-name))
    
    2776
    +				core-name)
    
    2777
    +	       *cold-assembler-routines*)
    
    2765 2778
     	      (emit-makefile-header
    
    2766 2779
     	       (merge-pathnames (if (eq header-name t)
    
    2767 2780
     				    "internals.inc"
    

  • src/lisp/save.c
    ... ... @@ -13,6 +13,8 @@
    13 13
     #include <limits.h>
    
    14 14
     #include <math.h>
    
    15 15
     
    
    16
    +/* Get the lisp assembly routines because we need them */
    
    17
    +#define DEFINE_ASM
    
    16 18
     #include "lisp.h"
    
    17 19
     #include "os.h"
    
    18 20
     #include "internals.h"
    
    ... ... @@ -394,6 +396,8 @@ save_executable(char *filename, lispobj init_function)
    394 396
         fflush(stdout);
    
    395 397
         
    
    396 398
         printf("Linking executable...\n");
    
    399
    +    printf("  init_function 0x%08lx\n", init_function);
    
    400
    +    
    
    397 401
         fflush(stdout);
    
    398 402
         rc = obj_run_linker(init_function, filename);
    
    399 403
         printf("done.\n");
    
    ... ... @@ -415,7 +419,8 @@ static char* asmtab_types[256];
    415 419
     void
    
    416 420
     asm_label(lispobj* ptr, lispobj object, FILE* f) 
    
    417 421
     {
    
    418
    -    fprintf(f, "L%lx:\n", (unsigned long) ptr);
    
    422
    +    fprintf(f, "\t.global\tL%08lx\n", (unsigned long) ptr);
    
    423
    +    fprintf(f, "L%08lx:\n", (unsigned long) ptr);
    
    419 424
     }
    
    420 425
     
    
    421 426
     void
    
    ... ... @@ -1356,6 +1361,7 @@ write_asm_object(const char *dir, int id, os_vm_address_t start, os_vm_address_t
    1356 1361
     {
    
    1357 1362
         char asm_file[PATH_MAX];
    
    1358 1363
         FILE* f;
    
    1364
    +    int k;
    
    1359 1365
         
    
    1360 1366
         printf("write_asm_object space %d start %p end %p\n",
    
    1361 1367
                id, start, end);
    
    ... ... @@ -1365,14 +1371,25 @@ write_asm_object(const char *dir, int id, os_vm_address_t start, os_vm_address_t
    1365 1371
     
    
    1366 1372
         lispobj* ptr = (lispobj*) start;
    
    1367 1373
         lispobj* end_ptr = (lispobj*) end;
    
    1374
    +
    
    1375
    +    /* Set the section name */
    
    1376
    +    fprintf(f, "\t.section\t\"space%d\", \"wx\"\n", id);
    
    1368 1377
         
    
    1378
    +    /* Print the assembly routines */
    
    1379
    +    k = 0;
    
    1380
    +    while (lisp_asm_routines[k] != 0) {
    
    1381
    +        fprintf(f, "\t.set\tL%08lx, 0x%08lx\n",
    
    1382
    +                lisp_asm_routines[k],
    
    1383
    +                lisp_asm_routines[k]);
    
    1384
    +        ++k;
    
    1385
    +    }
    
    1386
    +
    
    1369 1387
         /*
    
    1370 1388
          * If the id is the static space, we need special handling for
    
    1371 1389
          * beginning which has NIL in a funny way to make NIL a symbol and
    
    1372 1390
          * list.
    
    1373 1391
          */
    
    1374 1392
         if (id == STATIC_SPACE_ID) {
    
    1375
    -        int k;
    
    1376 1393
             
    
    1377 1394
             /* Output the first word */
    
    1378 1395
             asm_header_word(ptr, *ptr, f, NULL);