Changeset 14608


Ignore:
Timestamp:
Jan 29, 2011, 6:38:14 PM (14 years ago)
Author:
Gary Byers
Message:

dumplisp.lisp: support :native argument to SAVE-APPLICATION; only

implemented on x86[32,64] Darwin.

mach-o-image.c: declare victory.

Location:
trunk/source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lib/dumplisp.lisp

    r13225 r14608  
    7575                         (mode #o644)
    7676                         prepend-kernel
    77                          #+windows-target (application-type :console))
     77                         #+windows-target (application-type :console)
     78                         native)
    7879  (declare (ignore toplevel-function error-handler application-class
    7980                   clear-clos-caches init-file impurify))
     
    8990      (cerror "Un-watch them." "There are watched objects.")
    9091      (mapc #'unwatch watched)))
     92  (when (and native prepend-kernel)
     93    (error "~S and ~S can't both be specified (yet)." :native :prepend-kernel))
    9194  (let* ((ip *initial-process*)
    9295         (cp *current-process*))
     
    97100                                     #+windows-target  #+windows-target
    98101                                     :application-type application-type)))
     102        (when native
     103          #+(or darwinx8632-target darwin-x8664-target) (setq fd (- fd))
     104          #-(or darwinx8632-target darwin-x8664-target)
     105          (progn
     106            (warn "native image support not available, ignoring ~s option." :native)))
     107           
    99108        (process-interrupt ip
    100109                           #'(lambda ()
     
    119128                                      (clear-clos-caches t)
    120129                                      prepend-kernel
    121                                       #+windows-target application-type)
    122   (declare (ignore mode prepend-kernel #+windows-target application-type))
     130                                      #+windows-target application-type
     131                                      native)
     132  (declare (ignore mode prepend-kernel #+windows-target application-type native))
    123133  (when (and application-class (neq  (class-of *application*)
    124134                                     (if (symbolp application-class)
  • trunk/source/lisp-kernel/mach-o-image.c

    r14605 r14608  
    2727#include "lisp.h"
    2828#include "gc.h"
     29#include "lisp_globals.h"
    2930
    3031#if WORD_SIZE==64
     
    483484
    484485  seg = add_macho_segment(p,
    485                           "__TEXT",
     486                          "READONLY",
    486487                          (natural)(readonly_area->low-4096),
    487488                          4096+align_to_power_of_2(readonly_area->active-readonly_area->low,12),
     
    491492                          VM_PROT_READ|VM_PROT_EXECUTE,
    492493                          1,
    493                           "text");
     494                          "purespace");
    494495  init_macho_section(seg,
    495496                     0,
     
    505506 
    506507  if (managed_static_area->active != managed_static_area->low) {
    507     nrefbytes = (((area_dnode(managed_static_area->active,managed_static_area->low)>>dnode_shift)+7)>>3);
     508    nrefbytes = ((area_dnode(managed_static_area->active,managed_static_area->low)+7)>>3);
    508509
    509510    prepare_to_write_dynamic_space(managed_static_area);
     
    698699load_native_library(char *path)
    699700{
     701  extern BytePtr allocate_from_reserved_area(natural);
    700702  void *lib;
    701703  LispObj image_nil = 0;
     
    749751  } else {
    750752    area *a;
    751     char *p, *q;
    752 
    753     p = (BytePtr)dlsym(lib,"DYNAMIC_HEAP_END");
    754     if (p == NULL) {
     753    natural initsize,totalsize,nrefbytes;
     754    char
     755      *ro_start = dlsym(lib,"READONLY_START"),
     756      *ro_end   = dlsym(lib,"READONLY_END"),
     757      *ms_start = dlsym(lib,"MANAGED_STATIC_START"),
     758      *ms_end   = dlsym(lib,"MANAGED_STATIC_END"),
     759      *msr_end  = dlsym(lib,"MANAGED_STATIC_REFMAP_END"),
     760      *sc_start = dlsym(lib,"STATIC_CONS_START"),
     761      *sc_end   = dlsym(lib,"STATIC_CONS_START"),
     762      *dh_end   = dlsym(lib,"DYNAMIC_HEAP_END"),
     763      *p,
     764      *q;
     765
     766    if ((dh_end == NULL) ||
     767        (ro_start != pure_space_active)) {
    755768      dlclose(lib);
    756769      return 0;
    757770    }
    758     p = (BytePtr)align_to_power_of_2(p,12);
     771    p = (BytePtr)align_to_power_of_2(dh_end,12);
    759772    q = static_space_active;
    760773    mprotect(q,8192,PROT_READ|PROT_WRITE|PROT_EXEC);
    761774    memcpy(q,p,8192);
     775    memset(p,0,8192);
    762776
    763777    a = nilreg_area = new_area(q,q+8192,AREA_STATIC);
     
    781795#endif
    782796    set_nil(image_nil);
    783      
    784        
    785  
    786 
     797    add_area_holding_area_lock(a);
    787798   
     799    a = new_area(pure_space_active,pure_space_limit,AREA_READONLY);
     800    readonly_area = a;
     801    add_area_holding_area_lock(a);
     802    pure_space_active = a->active = ro_end;
    788803   
    789     if ((BytePtr)dlsym(lib,"READONLY_START") == pure_space_active) {
    790       a = new_area(pure_space_active,pure_space_limit,AREA_READONLY);
    791       readonly_area = a;
    792       add_area_holding_area_lock(a);
    793       pure_space_active = a->active = (BytePtr)dlsym(lib,"READONLY_END");
    794 
    795  
    796  
    797        
    798     }
    799   }
    800 }
     804    initsize = dh_end - sc_end;
     805    totalsize = align_to_power_of_2(initsize, log2_heap_segment_size);
     806   
     807    p = allocate_from_reserved_area(totalsize);
     808    q = p+totalsize;
     809    a = new_area(p,q,AREA_DYNAMIC);
     810    a->active = dh_end;
     811    a->h = p;
     812    CommitMemory((char *)(align_to_power_of_2(dh_end,12)),
     813                 q-(char *)align_to_power_of_2(dh_end,12));
     814    map_initial_reloctab(p, q);
     815    map_initial_markbits(p, q);
     816    lisp_global(HEAP_START) = (LispObj)p;
     817    lisp_global(HEAP_END) = (LispObj)q;
     818    add_area_holding_area_lock(a);
     819    resize_dynamic_heap(dh_end, lisp_heap_gc_threshold);
     820    xMakeDataExecutable(a->low, a->active - a->low);
     821
     822    static_cons_area = new_area(sc_start, sc_end, AREA_STATIC_CONS);
     823    static_cons_area->active = sc_start;
     824    lower_heap_start(sc_start,a);
     825    a->static_dnodes = area_dnode(sc_end,sc_start);
     826   
     827    managed_static_area = new_area(ms_start,ms_end,AREA_MANAGED_STATIC);
     828    managed_static_area->active = ms_end;
     829    lisp_global(REF_BASE) = (LispObj) ms_start;
     830   
     831    nrefbytes = msr_end - ms_end;
     832    CommitMemory(global_mark_ref_bits,align_to_power_of_2(nrefbytes, 12));
     833    memcpy(global_mark_ref_bits,ms_end,nrefbytes);
     834    memset(ms_end,0,nrefbytes);
     835   
     836    return image_nil;
     837  }
     838}
Note: See TracChangeset for help on using the changeset viewer.