Raymond Toy pushed to branch issue-86-save-fpu-state-on-entry-to-alloc at cmucl / cmucl

Commits:

3 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -12,7 +12,7 @@ linux-runner:
    12 12
         - mkdir snapshot
    
    13 13
         - (cd snapshot; tar xjf ../cmucl-$version-linux.tar.bz2; tar xjf ../cmucl-$version-linux.extra.tar.bz2)
    
    14 14
       script:
    
    15
    -    - bin/build.sh $bootstrap -C "" -o snapshot/bin/lisp
    
    15
    +    - bin/build.sh $bootstrap -R -C "" -o snapshot/bin/lisp
    
    16 16
         - bin/make-dist.sh -I dist linux-4
    
    17 17
         - bin/run-tests.sh -l dist/bin/lisp 2>&1 | tee test.log
    
    18 18
     
    
    ... ... @@ -24,6 +24,6 @@ osx-runner:
    24 24
         - mkdir snapshot
    
    25 25
         - (cd snapshot; tar xjf ../cmucl-$version-darwin.tar.bz2)
    
    26 26
       script:
    
    27
    -    - bin/build.sh $bootstrap -C "" -o snapshot/bin/lisp
    
    27
    +    - bin/build.sh $bootstrap -R -C "" -o snapshot/bin/lisp
    
    28 28
         - bin/make-dist.sh -I dist darwin-4
    
    29 29
         - bin/run-tests.sh -l dist/bin/lisp 2>&1 | tee test.log

  • src/lisp/gencgc.c
    ... ... @@ -8416,10 +8416,13 @@ void do_pending_interrupt(void);
    8416 8416
     char *
    
    8417 8417
     alloc(int nbytes)
    
    8418 8418
     {
    
    8419
    -#if 0 && (defined(i386) || defined(__x86_64))
    
    8419
    +#if (defined(i386) || defined(__x86_64))
    
    8420 8420
         /*
    
    8421 8421
          * Need to save and restore the FPU registers on x86, but only for
    
    8422
    -     * sse2.  See Ticket #61.
    
    8422
    +     * sse2.  See Trac ticket #61
    
    8423
    +     * (https://trac.common-lisp.net/cmucl/ticket/61) and gitlab
    
    8424
    +     * ticket #86
    
    8425
    +     * (https://gitlab.common-lisp.net/cmucl/cmucl/-/issues/86).
    
    8423 8426
          *
    
    8424 8427
          * Not needed by sparc or ppc because we never call alloc from
    
    8425 8428
          * Lisp directly to do allocation.
    
    ... ... @@ -8457,20 +8460,6 @@ alloc(int nbytes)
    8457 8460
     	    set_current_region_free((lispobj) new_free_pointer);
    
    8458 8461
                 break;
    
    8459 8462
     	} else if (bytes_allocated <= auto_gc_trigger) {
    
    8460
    -#if 1 && (defined(i386) || defined(__x86_64))
    
    8461
    -    /*
    
    8462
    -     * Need to save and restore the FPU registers on x86, but only for
    
    8463
    -     * sse2.  See Ticket #61.
    
    8464
    -     *
    
    8465
    -     * Not needed by sparc or ppc because we never call alloc from
    
    8466
    -     * Lisp directly to do allocation.
    
    8467
    -     */
    
    8468
    -    FPU_STATE(fpu_state);
    
    8469
    -
    
    8470
    -    if (fpu_mode == SSE2) {
    
    8471
    -        save_fpu_state(fpu_state);
    
    8472
    -    }
    
    8473
    -#endif
    
    8474 8463
     	    /* Call gc_alloc.  */
    
    8475 8464
     	    boxed_region.free_pointer = (void *) get_current_region_free();
    
    8476 8465
     	    boxed_region.end_addr =
    
    ... ... @@ -8481,11 +8470,6 @@ alloc(int nbytes)
    8481 8470
     	    set_current_region_free((lispobj) boxed_region.free_pointer);
    
    8482 8471
     	    set_current_region_end((lispobj) boxed_region.end_addr);
    
    8483 8472
     
    
    8484
    -#if 1 && (defined(i386) || defined(__x86_64))
    
    8485
    -    if (fpu_mode == SSE2) {
    
    8486
    -        restore_fpu_state(fpu_state);
    
    8487
    -    }
    
    8488
    -#endif
    
    8489 8473
                 break;
    
    8490 8474
     	} else {
    
    8491 8475
     	    /* Run GC and try again.  */
    
    ... ... @@ -8499,7 +8483,7 @@ alloc(int nbytes)
    8499 8483
     	}
    
    8500 8484
         }
    
    8501 8485
     
    
    8502
    -#if 0 && (defined(i386) || defined(__x86_64))
    
    8486
    +#if (defined(i386) || defined(__x86_64))
    
    8503 8487
         if (fpu_mode == SSE2) {
    
    8504 8488
             restore_fpu_state(fpu_state);
    
    8505 8489
         }
    

  • src/lisp/x86-arch.h
    ... ... @@ -17,15 +17,13 @@ extern boolean os_support_sse2(void);
    17 17
     #define FPU_STATE_SIZE 27
    
    18 18
     
    
    19 19
     /* 
    
    20
    - * Need 512 byte area, aligned on a 16-byte boundary.  So allocate
    
    21
    - * 512+16 bytes of space and let the routine adjust the appropriate
    
    22
    - * alignment.
    
    20
    + * Need 512 byte area, aligned on a 16-byte boundary.
    
    23 21
      */
    
    24 22
     #define SSE_STATE_SIZE 512
    
    25 23
     
    
    26 24
     /*
    
    27 25
      * Just use the SSE size for both x87 and sse2 since the SSE size is
    
    28
    - * enough for either.
    
    26
    + * enough for either.  Make sure it's on a 16-byte boundary.
    
    29 27
      */
    
    30 28
     #define FPU_STATE(name)    u_int8_t name[SSE_STATE_SIZE] __attribute__((aligned(16)))
    
    31 29