Changeset 16472


Ignore:
Timestamp:
Jul 14, 2015, 8:46:08 AM (4 years ago)
Author:
gb
Message:

Self-calls again, or at least some cases.
Merge EGC changes from trunk.

Location:
branches/lscan/source/lisp-kernel
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/lscan/source/lisp-kernel/image.c

    r15842 r16472  
    312312  case AREA_STATIC_CONS:
    313313    addr = (char *) lisp_global(HEAP_START);
     314    tenured_area = new_area(addr, addr, AREA_STATIC);
     315
    314316    a = new_area(addr-align_to_power_of_2(mem_size,log2_page_size), addr, AREA_STATIC_CONS);
    315317    if (mem_size) {     
     
    325327    sect->area = a;
    326328    static_cons_area = a;
     329    /* not yet
     330    lower_heap_start(a->low,tenured_area);
     331    */
    327332    break;
    328333
     
    421426        break;
    422427      case AREA_STATIC_CONS:
     428        /* not yet
     429 lower_heap_start(static_cons_area->low,tenured_area);
     430        */
    423431        break;
    424432      case AREA_DYNAMIC:
    425         lower_heap_start(static_cons_area->low,a);
    426433        if (bias) {
    427434          relocate_area_contents(a, bias);
  • branches/lscan/source/lisp-kernel/lisp-debug.c

    r16403 r16472  
    2828#include <errno.h>
    2929#include <stdio.h>
    30 
    31 #ifdef WINDOWS
     30#include <sys/stat.h>
     31
     32
    3233#include <fcntl.h>
    33 #else
     34#ifndef WINDOWS
    3435#include <sys/socket.h>
    3536#include <dlfcn.h>
    3637#endif
    37 #include <sys/stat.h>
    38 
    39 FILE *dbgout = NULL;
     38
     39
     40FILE *dbgout = NULL, *dbgin=NULL;
    4041
    4142typedef enum {
     
    7576
    7677
     78#ifndef ANDROID
    7779struct user_vfp {
    7880        unsigned long long fpregs[32];
    7981        unsigned long fpscr;
    8082};
     83#endif
    8184
    8285struct user_vfp *
     
    217220#endif
    218221
     222void
     223redirect_debugger_io()
     224{
     225#ifndef WINDOWS
     226  if (1 || !isatty(fileno(dbgin))) {
     227    int fd = open("/dev/tty", O_RDWR);
     228    if (fd >=0) {
     229      dbgin=fdopen(fd,"r");
     230      open_debug_output(fd);
     231    }
     232  }
     233#endif
     234}
     235     
    219236int
    220237readc()
     
    224241
    225242  while (tries) {
    226     c = getchar();
     243    c = fgetc(dbgin);
    227244    switch(c) {
    228245    case '\n':
     
    871888    fprintf(dbgout, "\n %s :",prompt);
    872889    buf[0] = 0;
    873     res = fgets(buf, sizeof(buf), stdin);
     890    res = fgets(buf, sizeof(buf),dbgin);
    874891  } while (0);
    875892  p = strchr(res, '\n');
     
    891908    fprintf(dbgout, "\n  %s :", prompt);
    892909    s[0]=0;
    893     res = fgets(s, 24, stdin);
     910    res = fgets(s, 24, dbgin);
    894911    val = strtoul(res,&endptr,0);
    895912  } while (*endptr);
     
    907924    fpurge(stdin);
    908925    fprintf(dbgout, "\n  %s :", prompt);
    909     res = fgets(s, 24, stdin);
     926    res = fgets(s, 24, dbgin);
    910927    n = sscanf(res, "%i", &val);
    911928  } while ((n != 1) || (val > 31));
  • branches/lscan/source/lisp-kernel/lisp.h

    r16135 r16472  
    9292void ensure_static_conses(ExceptionInformation *, TCR *,natural);
    9393
    94 extern FILE *dbgout;
     94void ensure_gc_structures_writable(void);
     95
     96extern FILE *dbgout,*dbgin;
     97
     98extern void redirect_debugger_io(void);
    9599
    96100#define RESERVE_FOR_LISP 1
     
    105109extern void lower_heap_start(BytePtr, area*);
    106110
     111
     112extern natural os_major_version;
     113extern Boolean copy_exception_avx_state;
     114
    107115#endif /* __lisp__ */
  • branches/lscan/source/lisp-kernel/memory.c

    r16110 r16472  
    708708untenure_from_area(area *from)
    709709{
    710   if (lisp_global(OLDEST_EPHEMERAL) != 0) {
     710  if ((lisp_global(OLDEST_EPHEMERAL) != 0)) {
    711711    area *a = active_dynamic_area, *child;
    712712    BytePtr curlow = from->low;
     
    714714   
    715715    for (child = from; child != a; child = child->younger) {
    716       child->low = child->active = child->high = curlow;
    717       child->ndnodes = 0;
     716      child->low = from->low;
     717
     718     child->active = child->high = curlow;
     719     child->ndnodes = area_dnode(child->high, child->low);
    718720    }
    719721   
  • branches/lscan/source/lisp-kernel/memprotect.h

    r15842 r16472  
    2626#include <sys/ucontext.h>
    2727#else
     28#ifndef ANDROID
    2829#include <ucontext.h>
     30#endif
    2931#endif
    3032#endif
  • branches/lscan/source/lisp-kernel/pmcl-kernel.c

    r16164 r16472  
    703703    CommitMemory(new_markbits,n);
    704704    dynamic_mark_ref_bits = (bitvector)new_markbits;
    705     if (a->refbits) {
     705    if (a) {
     706      if (a->refbits) {
    706707      a->refbits= dynamic_mark_ref_bits;
    707     }
    708     a->static_dnodes += new_dnodes;
    709     a->ndnodes += new_dnodes;
    710     a->low = new_low;
    711     a->refidx -= nidx;
     708      }
     709      a->static_dnodes += new_dnodes;
     710      a->ndnodes += new_dnodes;
     711      a->low = new_low;
     712      a->refidx -= nidx;
     713    }
    712714    low_markable_address = new_low;
    713715    lisp_global(HEAP_START) = (LispObj)new_low;
    714716    static_cons_area->ndnodes = area_dnode(static_cons_area->high,new_low);
     717    ensure_gc_structures_writable();
    715718  }
    716719}
     
    720723{
    721724  natural
    722     ndnodes = area_dnode(lisp_global(HEAP_END),low_relocatable_address),
     725    ndnodes = area_dnode(lisp_global(HEAP_END),tenured_area->low),
    723726    markbits_size = (3*sizeof(LispObj))+((ndnodes+7)>>3),
    724727    reloctab_size = (sizeof(LispObj)*(((ndnodes+((1<<bitmap_shift)-1))>>bitmap_shift)+1)),
     
    11661169  fprintf(dbgout, "\t-b, --batch: exit when EOF on *STANDARD-INPUT*\n");
    11671170  fprintf(dbgout, "\t--no-sigtrap : obscure option for running under GDB\n");
     1171  fprintf(dbgout, "\t--debug : try to ensure that kernel debugger uses a TTY for I/O\n");
     1172#ifdef LINUX
     1173#ifdef X86
     1174#if WORD_SIZE==64
     1175  fprintf(dbgout,  "\t--avx :signal handlers preserve AVX(YMM) registers on x8664 Linux.  This the default on Linux >=3.0\n");
     1176 fprintf(dbgout,  "\t--no-avx :signal handler don't preserve AVX(YMM) registers on x8664 Linux, This the default on Linux <3.0\n");
     1177#endif
     1178#endif
     1179#endif
    11681180  fprintf(dbgout, "\t-I, --image-name <image-name>\n");
    11691181#ifndef WINDOWS
     
    12301242   remaining args will be processed by lisp code.
    12311243*/
     1244Boolean copy_exception_avx_state = false;
    12321245
    12331246void
     
    12401253  extern int NXArgc;
    12411254#endif
    1242 
     1255  dbgin = stdin;
    12431256  for (i = 1; i < argc;) {
    12441257    arg = argv[i];
     
    13691382        batch_flag = 1;
    13701383        num_elide = 1;
     1384      } else if ((strcmp (arg, "-d") == 0) ||
     1385                 (strcmp (arg, "--debug")  == 0)) {
     1386        redirect_debugger_io();
     1387        num_elide=1;
     1388      } else if (strcmp (arg,"--avx") == 0) {
     1389        copy_exception_avx_state =1;
     1390        num_elide = 1;
     1391      } else if (strcmp (arg,"--no-avx") == 0) {
     1392        copy_exception_avx_state =0;
     1393        num_elide = 1;
     1394
     1395   
    13711396      } else if (strcmp(arg,"--") == 0) {
     1397                     
    13721398        break;
    13731399      } else {
     
    13951421    }
    13961422  }
     1423#if 0
     1424  redirect_debugger_io();
     1425  fprintf(dbgout,"ccl pid = %d", getpid());
     1426  sleep(20);
     1427#endif
     1428
     1429
    13971430}
    13981431
     
    15281561
    15291562
     1563natural os_major_version = 0;
     1564
    15301565void
    15311566check_os_version(char *progname)
     
    15421577  uname(&uts);
    15431578  got = strtoul(uts.release,&got_end,10);
     1579  os_major_version = got;
    15441580#if defined(X8632) && defined(FREEBSD)
    15451581  if (!strcmp(uts.machine,"amd64")) {
     
    17731809    g1_area = new_area(lowptr, lowptr, AREA_STATIC);
    17741810    g2_area = new_area(lowptr, lowptr, AREA_STATIC);
    1775     tenured_area = new_area(lowptr, lowptr, AREA_STATIC);
    1776     add_area_holding_area_lock(tenured_area);
    17771811    add_area_holding_area_lock(g2_area);
    17781812    add_area_holding_area_lock(g1_area);
    1779 
     1813    add_area_holding_area_lock(tenured_area);
    17801814    g1_area->code = AREA_DYNAMIC;
    17811815    g2_area->code = AREA_DYNAMIC;
     
    18041838    g1_area->threshold = default_g1_threshold;
    18051839    a->threshold = default_g0_threshold;
     1840    if (static_cons_area && static_cons_area->ndnodes) {
     1841      lower_heap_start(static_cons_area->low, tenured_area);
     1842    }
    18061843  }
    18071844}
     
    18631900
    18641901  check_os_version(argv[0]);
    1865 #ifdef WINDOWS
     1902#ifdef LINUX
     1903#if WORD_SIZE==64
     1904  if (os_major_version >= 3) {
     1905    copy_exception_avx_state = true;
     1906  }
     1907#endif
     1908#endif
     1909#ifdef WINDOXS
    18661910  real_executable_name = determine_executable_name();
    18671911#else
     
    21032147  (nrs_GC_EVENT_STATUS_BITS.vcell |= gc_integrity_check_bit);
    21042148#endif
    2105   if (egc_enabled) {
    2106     egc_control(true, NULL);
    2107   } else {
     2149
     2150  egc_control(true, NULL);
     2151  if (!egc_enabled) {
     2152    egc_control(false,NULL);
    21082153    lisp_global(OLDSPACE_DNODE_COUNT) = 0;
    21092154  }
     
    24062451#endif
    24072452
     2453#ifdef ANDROID
     2454extern Elf_Dyn_thing *android_executable_dynamic_section = NULL;
     2455#endif
     2456
     2457
    24082458Elf_Dyn_thing *
    24092459get_executable_dynamic_entries()
     
    24142464#else
    24152465#ifdef ANDROID
    2416   /* Deep, dark secret: the "handle" returned by dlopen() is
    2417      a pointer to an soinfo structure, as defined in linker.h.
    2418      We can get the link map from there ...
    2419   */
    2420  
    2421 
    2422  
    2423   /* Woe unto us - and lots of it - if the executable is mapped
    2424      at an address other than 0x8000.  Todo: parse /proc/self/maps. */
    2425   char *p;
    2426   Elf_Ehdr_thing *elf_header;
    2427   Elf_Shdr_thing *section_header;
    2428   int i,fd;
    2429   struct stat _stat;
    2430   Elf_Dyn_thing *result = NULL;
    2431  
    2432   fd = open("/proc/self/exe",O_RDONLY);
    2433   if (fd >= 0) {
    2434     if (fstat(fd,&_stat) == 0) {
    2435       p = (char *)mmap(NULL,_stat.st_size,PROT_READ,MAP_PRIVATE,fd,0);
    2436       if (p != MAP_FAILED) {
    2437         elf_header = (Elf_Ehdr_thing *)p;
    2438         for (section_header = (Elf_Shdr_thing *)(p+elf_header->e_shoff),
    2439                i = 0;
    2440              i < elf_header->e_shnum;
    2441              i++,section_header++) {
    2442           if (section_header->sh_type == SHT_DYNAMIC) {
    2443             result = (Elf_Dyn_thing *)section_header->sh_addr;
    2444             break;
    2445           }
    2446         }
    2447         munmap(p,_stat.st_size);
    2448       }
    2449     }
    2450     close(fd);
    2451   }
     2466  extern Elf_Dyn_thing *android_executable_dynamic_section;
     2467
     2468  Elf_Dyn_thing *result = android_executable_dynamic_section;
    24522469  return result;
    24532470#else
     
    25652582ensure_static_conses(ExceptionInformation *xp, TCR *tcr, natural nconses)
    25662583{
    2567   area *a = active_dynamic_area;
    2568   natural nbytes = nconses>>dnode_shift, have;
    2569   BytePtr p = a->high-nbytes;
    2570 #ifdef USE_GC_NOTIFICATION
    2571   Boolean crossed_notify_threshold = false;
    2572   LispObj before_shrink, after_shrink;
    2573 #endif
    2574 
    2575   if (p < a->active) {
    2576     untenure_from_area(tenured_area);
    2577     gc_from_xp(xp, 0L);
    2578 #ifdef USE_GC_NOTIFICATION
    2579     did_gc_notification_since_last_full_gc = false;
    2580 #endif
    2581   }
    2582 
    2583   have = unbox_fixnum(lisp_global(FREE_STATIC_CONSES));
    2584   if (have < nconses) {
    2585 #ifdef USE_GC_NOTIFICATION
    2586     before_shrink = a->high-a->active;
    2587     if (before_shrink>nbytes) {
    2588       shrink_dynamic_area(nbytes);
    2589       after_shrink = a->high-a->active;
    2590       if ((before_shrink >= lisp_heap_notify_threshold) &&
    2591           (after_shrink < lisp_heap_notify_threshold)) {
    2592         crossed_notify_threshold = true;
    2593       }
    2594     }
    2595 #endif
    2596     allocate_static_conses(nconses);
    2597     TCR_AUX(tcr)->bytes_allocated += nbytes;
    2598   }
    2599 #ifdef USE_GC_NOTIFICATION
    2600   if (crossed_notify_threshold && !did_gc_notification_since_last_full_gc) {
    2601     callback_for_gc_notification(xp,tcr);
    2602   }
    2603 #endif
     2584  natural nbytes = nconses<<dnode_shift;
     2585  allocate_static_conses(nconses);
     2586  TCR_AUX(tcr)->bytes_allocated += nbytes;
     2587
    26042588}
    26052589     
  • branches/lscan/source/lisp-kernel/x86-asmutils64.s

    r16072 r16472  
    127127        __(ret)
    128128_endfn
     129
     130_exportfn(C(ensure_safe_for_string_operations))
     131        __(cld)
     132        __(ret)
     133_endfn                                       
    129134
    130135
     
    271276        __(hlt)
    272277_endfn         
    273 _exportfn(C(ensure_safe_for_string_operations))
    274         __(cld)
    275         __(ret)
    276 _endfn                                       
     278
    277279        __endif
    278280
  • branches/lscan/source/lisp-kernel/x86-exceptions.c

    r16138 r16472  
    1414   http://opensource.franz.com/preamble.html
    1515*/
    16 
     16 
    1717#include "lisp.h"
    1818#include "lisp-exceptions.h"
Note: See TracChangeset for help on using the changeset viewer.