Changeset 15217 for trunk


Ignore:
Timestamp:
Feb 16, 2012, 10:25:12 AM (7 years ago)
Author:
gb
Message:

Define a ref_nrs_function macro.
Alternate entrypoint startup stuff for Android. Needs testing.

Location:
trunk/source/lisp-kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/arm-macros.s

    r15111 r15217  
    172172')
    173173
     174define(`ref_nrs_function',`
     175        __(mov $1,#nil_value)
     176        __(ldr $1,[$1,#((nrs.$2)+(symbol.fcell))])
     177')
     178       
    174179define(`ref_nrs_symbol',`
    175180        __(movc16($3,nrs.$2))
  • trunk/source/lisp-kernel/arm-spentry.s

    r15205 r15217  
    43774377        __(bl _SPfuncall)
    43784378        __(mov arg_z,#nil_value)
    4379         __(mov imm0,fixnum_one)
     4379        __(mov imm0,#fixnum_one)
    43804380        __(bl _SPnthrow1value)
    43814381local_label(test):
     
    44324432        __(ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr})
    44334433        __(bx lr)
     4434_endfn
     4435       
    44344436        .align 3
    443544371:
    44364438        .long 0
    44374439        .long 0
     4440
     4441/* This gets called with r0 = the current thread's TCR.  Should
     4442   call RESTORE-LISP-POINTERS and return 0 if it returns normally
     4443   and non-0 if it throws. */
     4444       
     4445_exportfn(C(init_lisp))
     4446        new_local_labels()
     4447        new_macro_labels()
     4448        __(stmdb sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr})
     4449        __(mov rcontext,r0)
     4450        __(mov r0,sp)
     4451        __(tst sp,#4)
     4452        __(strne r0,[sp,#-4]!)
     4453        __(streq r0,[sp,#-8]!)
     4454        __(mov arg_z,#0)
     4455        __(mov arg_y,#0)
     4456        __(mov arg_x,#0)
     4457        __(mov temp0,#0)
     4458        __(mov temp1,#0)
     4459        __(mov temp2,#0)
     4460        __(mov allocptr,#VOID_ALLOCPTR)
     4461        __(mov fn,#0)
     4462        __(ldr vsp,[rcontext,#tcr.save_vsp])
     4463        __(ldr imm2,[rcontext,#tcr.last_lisp_frame])
     4464        __(sub imm0,imm2,sp)
     4465        __(add imm0,imm0,#node_size)
     4466        __(mov imm0,imm0,lsl #num_subtag_bits-word_shift)
     4467        __(orr imm0,imm0,#subtag_u32_vector)
     4468        __(stmdb sp!,{imm0,imm2})
     4469        __(push_foreign_fprs())
     4470        __(adr imm0,1b)
     4471        __(fldd double_float_zero,[imm0])
     4472        __(mov imm0,#TCR_STATE_LISP)
     4473        __(str imm0,[rcontext,#tcr.valence])
     4474        __(ldr allocptr,[rcontext,#tcr.save_allocptr])
     4475        __(ref_nrs_function(nfn,restore_lisp_pointers))
     4476        __(extract_fulltag(imm0,nfn))
     4477        __(cmp imm0,#subtag_function)
     4478        __(bne local_label(fail))
     4479        __(ref_nrs_value(arg_z,toplcatch))
     4480        __(bl _SPmkcatch1v)
     4481        __(b local_label(fail)) /* cleanup address */
     4482        __(set_nargs(0))
     4483        __(bl _SPfuncall)
     4484        __(mov arg_z,#0)
     4485        __(mov imm0,#fixnum_one)
     4486        __(bl _SPnthrow1value)
     4487        __(b local_label(done))
     4488local_label(fail):     
     4489        __(mov arg_z,#fixnum_one)
     4490local_label(done):                     
     4491        __(ldr imm1,[sp,#(9*8)+4])
     4492        __(mov imm0,#TCR_STATE_FOREIGN)
     4493        __(str imm1,[rcontext,#tcr.last_lisp_frame])
     4494        __(str imm0,[rcontext,#tcr.valence])
     4495        __(pop_foreign_fprs())
     4496        __(add sp,sp,#2*node_size)
     4497        __(unbox_fixnum(imm0,arg_z))
     4498        __(ldr sp,[sp])
     4499        __(ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr})
     4500        __(bx lr)
     4501_endfn
     4502
     4503/* Called (on something other than the initial thread) with r0=tcr,
     4504   r1 = a (void *) arg.  Returns a null pointer/0, but declared to return
     4505   void.
     4506*/               
     4507_exportfn(C(os_main))
     4508        new_local_labels()
     4509        new_macro_labels()
     4510        __(stmdb sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr})
     4511        __(mov rcontext,r0)
     4512        __(mov r0,sp)
     4513        __(tst sp,#4)
     4514        __(strne r0,[sp,#-4]!)
     4515        __(streq r0,[sp,#-8]!)
     4516        __(mov arg_z,#0)
     4517        __(mov arg_y,#0)
     4518        __(mov arg_x,#0)
     4519        __(mov temp0,#0)
     4520        __(mov temp1,#0)
     4521        __(mov temp2,#0)
     4522        __(mov allocptr,#VOID_ALLOCPTR)
     4523        __(mov fn,#0)
     4524        __(ldr vsp,[rcontext,#tcr.save_vsp])
     4525        __(ldr imm2,[rcontext,#tcr.last_lisp_frame])
     4526        __(sub imm0,imm2,sp)
     4527        __(add imm0,imm0,#node_size)
     4528        __(mov imm0,imm0,lsl #num_subtag_bits-word_shift)
     4529        __(orr imm0,imm0,#subtag_u32_vector)
     4530        __(stmdb sp!,{imm0,imm2})
     4531        __(push_foreign_fprs())
     4532        __(adr imm0,1b)
     4533        __(fldd double_float_zero,[imm0])
     4534        __(mov imm0,#TCR_STATE_LISP)
     4535        __(str imm0,[rcontext,#tcr.valence])
     4536        __(ldr allocptr,[rcontext,#tcr.save_allocptr])
     4537        __(movc16(imm0,make_header(macptr.element_count,subtag_macptr)))
     4538        __(stmdb sp!,{imm0,imm1,arg_z,arg_y})
     4539        __(add arg_z,sp,#fulltag_misc)
     4540        __(ref_nrs_function(nfn,os_init_function))
     4541        __(set_nargs(1))
     4542        __(bl _SPfuncall)
     4543        __(add sp,sp,#16)
     4544        __(ldr imm1,[sp,#(9*8)+4])
     4545        __(mov imm0,#TCR_STATE_FOREIGN)
     4546        __(str imm1,[rcontext,#tcr.last_lisp_frame])
     4547        __(str imm0,[rcontext,#tcr.valence])
     4548        __(pop_foreign_fprs())
     4549        __(add sp,sp,#2*node_size)
     4550        __(mov imm0,#nil_value)
     4551        __(ldr sp,[sp])
     4552        __(ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr})
     4553        __(bx lr)
     4554_endfn
     4555                               
    44384556        .data
    44394557        .globl C(sptab)
  • trunk/source/lisp-kernel/pmcl-kernel.c

    r15205 r15217  
    17481748#endif
    17491749
    1750 
    1751 
    1752 
    1753 int
    1754 #ifdef CCLSHARED
    1755 cclmain
    1756 #else
    1757 main
    1758 #endif
    1759 (int argc, char *argv[]
    1760 #if defined(PPC) && defined(LINUX)
    1761 , char *envp[], void *aux
    1762 #endif
    1763 )
    1764 {
    1765   extern int page_size;
    1766   natural default_g0_threshold = G0_AREA_THRESHOLD,
    1767     default_g1_threshold = G1_AREA_THRESHOLD,
    1768     default_g2_threshold = G2_AREA_THRESHOLD,
    1769     lisp_heap_threshold_from_image = 0;
    1770   Boolean egc_enabled =
    1771 #ifdef DISABLE_EGC
    1772     false
    1773 #else
    1774     true
    1775 #endif
    1776     ;
    1777   Boolean lisp_heap_threshold_set_from_command_line = false;
    1778   wchar_t **utf_16_argv = NULL;
    1779 
    1780 #ifdef PPC
    1781   extern int altivec_present;
    1782 #endif
    1783 #ifdef WINDOWS
    1784   extern LispObj load_image(wchar_t *);
    1785 #else
    1786   extern LispObj load_image(char *);
    1787 #endif
     1750natural default_g0_threshold = G0_AREA_THRESHOLD;
     1751natural default_g1_threshold = G1_AREA_THRESHOLD;
     1752natural default_g2_threshold = G2_AREA_THRESHOLD;
     1753natural lisp_heap_threshold_from_image = 0;
     1754
     1755void
     1756init_consing_areas()
     1757{
    17881758  area *a;
    1789   BytePtr stack_base, current_sp = (BytePtr) current_stack_pointer();
    1790   TCR *tcr;
    1791 
    1792   dbgout = stderr;
    1793 
    1794 #ifdef WINDOWS
    1795   {
    1796     int wide_argc;
    1797     extern void init_winsock(void);
    1798     extern void init_windows_io(void);
    1799     extern void reserve_tls_slots(void);
    1800 
    1801     _fmode = O_BINARY;
    1802     _setmode(1, O_BINARY);
    1803     _setmode(2, O_BINARY);
    1804     setvbuf(dbgout, NULL, _IONBF, 0);
    1805     init_winsock();
    1806     init_windows_io();
    1807     reserve_tls_slots();
    1808     utf_16_argv = CommandLineToArgvW(GetCommandLineW(),&wide_argc);
    1809   }
    1810 #endif
    1811 
    1812   check_os_version(argv[0]);
    1813 #ifdef WINDOWS
    1814   real_executable_name = determine_executable_name();
    1815 #else
    1816   real_executable_name = determine_executable_name(argv[0]);
    1817 #endif
    1818   page_size = getpagesize(); /* Implement with GetSystemInfo on Windows w/o MinGW */
    1819 
    1820   check_bogus_fp_exceptions();
    1821 #ifdef LINUX
    1822 #ifdef X8664
    1823   ensure_gs_available(real_executable_name);
    1824 #endif
    1825 #endif
    1826 #if (defined(DARWIN) && defined(PPC64)) || (defined(LINUX) && defined(PPC))|| defined(X8664) || (defined(X8632) && !defined(DARWIN))
    1827   remap_spjump();
    1828 #endif
    1829 
    1830 #ifdef PPC
    1831 #ifdef LINUX
    1832   {
    1833     ElfW(auxv_t) *av = aux;
    1834     int hwcap, done = false;
    1835    
    1836     if (av) {
    1837       do {
    1838         switch (av->a_type) {
    1839         case AT_DCACHEBSIZE:
    1840           cache_block_size = av->a_un.a_val;
    1841           break;
    1842 
    1843         case AT_HWCAP:
    1844           hwcap = av->a_un.a_val;
    1845           altivec_present = ((hwcap & PPC_FEATURE_HAS_ALTIVEC) != 0);
    1846           break;
    1847 
    1848         case AT_NULL:
    1849           done = true;
    1850           break;
    1851         }
    1852         av++;
    1853       } while (!done);
    1854     }
    1855   }
    1856 #endif
    1857 #ifdef DARWIN
    1858   {
    1859     unsigned value = 0;
    1860     size_t len = sizeof(value);
    1861     int mib[2];
    1862    
    1863     mib[0] = CTL_HW;
    1864     mib[1] = HW_CACHELINE;
    1865     if (sysctl(mib,2,&value,&len, NULL, 0) != -1) {
    1866       if (len == sizeof(value)) {
    1867         cache_block_size = value;
    1868       }
    1869     }
    1870     mib[1] = HW_VECTORUNIT;
    1871     value = 0;
    1872     len = sizeof(value);
    1873     if (sysctl(mib,2,&value,&len, NULL, 0) != -1) {
    1874       if (len == sizeof(value)) {
    1875         altivec_present = value;
    1876       }
    1877     }
    1878   }
    1879 #endif
    1880 #endif
    1881 
    1882 #ifdef X86
    1883   if (!check_x86_cpu()) {
    1884     fprintf(dbgout, "CPU doesn't support required features\n");
    1885     exit(1);
    1886   }
    1887 #endif
    1888 
    1889 #ifdef ARM
    1890   if (!check_arm_cpu()) {
    1891     fprintf(dbgout, "CPU doesn't support required features\n");
    1892     exit(1);
    1893   }
    1894 #endif
    1895 
    1896 #ifdef SOLARIS
    1897 #ifdef X8632
    1898   {
    1899     extern void solaris_ldt_init(void);
    1900     solaris_ldt_init();
    1901   }
    1902 #endif
    1903 #endif
    1904 
    1905 #ifndef WINDOWS
    1906   main_thread_pid = getpid();
    1907 #endif
    1908   tcr_area_lock = (void *)new_recursive_lock();
    1909 
    1910   program_name = argv[0];
    1911 #ifdef SINGLE_ARG_SHORTHAND
    1912   if ((argc == 2) && (*argv[1] != '-')) {
    1913 #ifdef WINDOWS
    1914     image_name = utf_16_argv[1];
    1915 #else
    1916     image_name = argv[1];
    1917 #endif
    1918     argv[1] = NULL;
    1919 #ifdef WINDOWS
    1920     utf_16_argv[1] = NULL;
    1921 #endif
    1922   } else {
    1923 #endif  /* SINGLE_ARG_SHORTHAND */
    1924     process_options(argc,argv,utf_16_argv);
    1925 #ifdef SINGLE_ARG_SHORTHAND
    1926   }
    1927 #endif
    1928   if (lisp_heap_gc_threshold != DEFAULT_LISP_HEAP_GC_THRESHOLD) {
    1929     lisp_heap_threshold_set_from_command_line = true;
    1930   }
    1931 
    1932   initial_stack_size = ensure_stack_limit(initial_stack_size);
    1933   if (image_name == NULL) {
    1934     if (check_for_embedded_image(real_executable_name)) {
    1935       image_name = real_executable_name;
    1936     } else {
    1937       image_name = default_image_name(real_executable_name);
    1938 #ifdef DARWIN
    1939       if (!probe_file(image_name)) {
    1940         image_name = bundle_image_name(real_executable_name);
    1941       }
    1942 #endif
    1943     }
    1944   }
    1945 
    1946   while (1) {
    1947     if (create_reserved_area(reserved_area_size)) {
    1948       break;
    1949     }
    1950     reserved_area_size = reserved_area_size *.9;
    1951   }
    1952 
    1953   gc_init();
    1954 
    1955   set_nil(load_image(image_name));
    1956   lisp_heap_notify_threshold = GC_NOTIFY_THRESHOLD;
    1957   lisp_heap_threshold_from_image = lisp_global(LISP_HEAP_THRESHOLD);
    1958  
    1959   if (lisp_heap_threshold_from_image) {
    1960     if ((!lisp_heap_threshold_set_from_command_line) &&
    1961         (lisp_heap_threshold_from_image != lisp_heap_gc_threshold)) {
    1962       lisp_heap_gc_threshold = lisp_heap_threshold_from_image;
    1963       resize_dynamic_heap(active_dynamic_area->active,lisp_heap_gc_threshold);
    1964     }
    1965     /* If lisp_heap_threshold_from_image was set, other image params are
    1966        valid. */
    1967     default_g0_threshold = lisp_global(G0_THRESHOLD);
    1968     default_g1_threshold = lisp_global(G1_THRESHOLD);
    1969     default_g2_threshold = lisp_global(G2_THRESHOLD);
    1970     egc_enabled = lisp_global(EGC_ENABLED);
    1971   }
    1972 
    1973   lisp_global(TCR_AREA_LOCK) = ptr_to_lispobj(tcr_area_lock);
    1974 
    1975 #ifdef X86
    1976   lisp_global(SUBPRIMS_BASE) = (LispObj)((1<<16)+(5<<10));
    1977 #endif
    1978 #ifdef PPC
    1979   lisp_global(SUBPRIMS_BASE) = (LispObj)(5<<10);
    1980 #endif
    1981 #ifdef ARM
    1982   lisp_global(SUBPRIMS_BASE) = (LispObj)(9<<12);
    1983 #endif
    1984 
    1985   lisp_global(RET1VALN) = (LispObj)&ret1valn;
    1986   lisp_global(LEXPR_RETURN) = (LispObj)&nvalret;
    1987   lisp_global(LEXPR_RETURN1V) = (LispObj)&popj;
    1988   lisp_global(ALL_AREAS) = ptr_to_lispobj(all_areas);
    1989   lisp_global(DEFAULT_ALLOCATION_QUANTUM) = log2_heap_segment_size << fixnumshift;
    1990   lisp_global(STACK_SIZE) = thread_stack_size<<fixnumshift;
    1991 
    1992 
    1993   exception_init();
    1994 
    1995  
    1996 
    1997 #ifdef WINDOWS
    1998   lisp_global(IMAGE_NAME) = ptr_to_lispobj(utf_16_to_utf_8(ensure_real_path(image_name)));
    1999   lisp_global(KERNEL_PATH) = ptr_to_lispobj(utf_16_to_utf_8(real_executable_name));
    2000   lisp_global(ARGV) = ptr_to_lispobj(wide_argv_to_utf_8(utf_16_argv, argc));
    2001 #else
    2002   lisp_global(IMAGE_NAME) = ptr_to_lispobj(ensure_real_path(image_name));
    2003   lisp_global(KERNEL_PATH) = ptr_to_lispobj(real_executable_name);
    2004   lisp_global(ARGV) = ptr_to_lispobj(argv);
    2005 #endif
    2006   lisp_global(KERNEL_IMPORTS) = (LispObj)import_ptrs_base;
    2007 
    2008   lisp_global(GET_TCR) = (LispObj) get_tcr;
    2009   *(double *) &(lisp_global(DOUBLE_FLOAT_ONE)) = (double) 1.0;
    2010 
    2011   lisp_global(HOST_PLATFORM) = (LispObj) PLATFORM << fixnumshift;
    2012 
    2013   lisp_global(BATCH_FLAG) = (batch_flag << fixnumshift);
    2014 
    20151759  a = active_dynamic_area;
    20161760
     
    20501794    a->threshold = default_g0_threshold;
    20511795  }
    2052 
     1796}
     1797
     1798int
     1799#ifdef CCLSHARED
     1800cclmain
     1801#else
     1802main
     1803#endif
     1804(int argc, char *argv[]
     1805#if defined(PPC) && defined(LINUX)
     1806, char *envp[], void *aux
     1807#endif
     1808)
     1809{
     1810  extern int page_size;
     1811  Boolean egc_enabled =
     1812#ifdef DISABLE_EGC
     1813    false
     1814#else
     1815    true
     1816#endif
     1817    ;
     1818  Boolean lisp_heap_threshold_set_from_command_line = false;
     1819  wchar_t **utf_16_argv = NULL;
     1820
     1821#ifdef PPC
     1822  extern int altivec_present;
     1823#endif
     1824#ifdef WINDOWS
     1825  extern LispObj load_image(wchar_t *);
     1826#else
     1827  extern LispObj load_image(char *);
     1828#endif
     1829  area *a;
     1830  BytePtr stack_base, current_sp = (BytePtr) current_stack_pointer();
     1831  TCR *tcr;
     1832
     1833  dbgout = stderr;
     1834
     1835#ifdef WINDOWS
     1836  {
     1837    int wide_argc;
     1838    extern void init_winsock(void);
     1839    extern void init_windows_io(void);
     1840    extern void reserve_tls_slots(void);
     1841
     1842    _fmode = O_BINARY;
     1843    _setmode(1, O_BINARY);
     1844    _setmode(2, O_BINARY);
     1845    setvbuf(dbgout, NULL, _IONBF, 0);
     1846    init_winsock();
     1847    init_windows_io();
     1848    reserve_tls_slots();
     1849    utf_16_argv = CommandLineToArgvW(GetCommandLineW(),&wide_argc);
     1850  }
     1851#endif
     1852
     1853  check_os_version(argv[0]);
     1854#ifdef WINDOWS
     1855  real_executable_name = determine_executable_name();
     1856#else
     1857  real_executable_name = determine_executable_name(argv[0]);
     1858#endif
     1859  page_size = getpagesize(); /* Implement with GetSystemInfo on Windows w/o MinGW */
     1860
     1861  check_bogus_fp_exceptions();
     1862#ifdef LINUX
     1863#ifdef X8664
     1864  ensure_gs_available(real_executable_name);
     1865#endif
     1866#endif
     1867#if (defined(DARWIN) && defined(PPC64)) || (defined(LINUX) && defined(PPC))|| defined(X8664) || (defined(X8632) && !defined(DARWIN))
     1868  remap_spjump();
     1869#endif
     1870
     1871#ifdef PPC
     1872#ifdef LINUX
     1873  {
     1874    ElfW(auxv_t) *av = aux;
     1875    int hwcap, done = false;
     1876   
     1877    if (av) {
     1878      do {
     1879        switch (av->a_type) {
     1880        case AT_DCACHEBSIZE:
     1881          cache_block_size = av->a_un.a_val;
     1882          break;
     1883
     1884        case AT_HWCAP:
     1885          hwcap = av->a_un.a_val;
     1886          altivec_present = ((hwcap & PPC_FEATURE_HAS_ALTIVEC) != 0);
     1887          break;
     1888
     1889        case AT_NULL:
     1890          done = true;
     1891          break;
     1892        }
     1893        av++;
     1894      } while (!done);
     1895    }
     1896  }
     1897#endif
     1898#ifdef DARWIN
     1899  {
     1900    unsigned value = 0;
     1901    size_t len = sizeof(value);
     1902    int mib[2];
     1903   
     1904    mib[0] = CTL_HW;
     1905    mib[1] = HW_CACHELINE;
     1906    if (sysctl(mib,2,&value,&len, NULL, 0) != -1) {
     1907      if (len == sizeof(value)) {
     1908        cache_block_size = value;
     1909      }
     1910    }
     1911    mib[1] = HW_VECTORUNIT;
     1912    value = 0;
     1913    len = sizeof(value);
     1914    if (sysctl(mib,2,&value,&len, NULL, 0) != -1) {
     1915      if (len == sizeof(value)) {
     1916        altivec_present = value;
     1917      }
     1918    }
     1919  }
     1920#endif
     1921#endif
     1922
     1923#ifdef X86
     1924  if (!check_x86_cpu()) {
     1925    fprintf(dbgout, "CPU doesn't support required features\n");
     1926    exit(1);
     1927  }
     1928#endif
     1929
     1930#ifdef ARM
     1931  if (!check_arm_cpu()) {
     1932    fprintf(dbgout, "CPU doesn't support required features\n");
     1933    exit(1);
     1934  }
     1935#endif
     1936
     1937#ifdef SOLARIS
     1938#ifdef X8632
     1939  {
     1940    extern void solaris_ldt_init(void);
     1941    solaris_ldt_init();
     1942  }
     1943#endif
     1944#endif
     1945
     1946#ifndef WINDOWS
     1947  main_thread_pid = getpid();
     1948#endif
     1949  tcr_area_lock = (void *)new_recursive_lock();
     1950
     1951  program_name = argv[0];
     1952#ifdef SINGLE_ARG_SHORTHAND
     1953  if ((argc == 2) && (*argv[1] != '-')) {
     1954#ifdef WINDOWS
     1955    image_name = utf_16_argv[1];
     1956#else
     1957    image_name = argv[1];
     1958#endif
     1959    argv[1] = NULL;
     1960#ifdef WINDOWS
     1961    utf_16_argv[1] = NULL;
     1962#endif
     1963  } else {
     1964#endif  /* SINGLE_ARG_SHORTHAND */
     1965    process_options(argc,argv,utf_16_argv);
     1966#ifdef SINGLE_ARG_SHORTHAND
     1967  }
     1968#endif
     1969  if (lisp_heap_gc_threshold != DEFAULT_LISP_HEAP_GC_THRESHOLD) {
     1970    lisp_heap_threshold_set_from_command_line = true;
     1971  }
     1972
     1973  initial_stack_size = ensure_stack_limit(initial_stack_size);
     1974  if (image_name == NULL) {
     1975    if (check_for_embedded_image(real_executable_name)) {
     1976      image_name = real_executable_name;
     1977    } else {
     1978      image_name = default_image_name(real_executable_name);
     1979#ifdef DARWIN
     1980      if (!probe_file(image_name)) {
     1981        image_name = bundle_image_name(real_executable_name);
     1982      }
     1983#endif
     1984    }
     1985  }
     1986
     1987  while (1) {
     1988    if (create_reserved_area(reserved_area_size)) {
     1989      break;
     1990    }
     1991    reserved_area_size = reserved_area_size *.9;
     1992  }
     1993
     1994  gc_init();
     1995
     1996  set_nil(load_image(image_name));
     1997  lisp_heap_notify_threshold = GC_NOTIFY_THRESHOLD;
     1998  lisp_heap_threshold_from_image = lisp_global(LISP_HEAP_THRESHOLD);
     1999 
     2000  if (lisp_heap_threshold_from_image) {
     2001    if ((!lisp_heap_threshold_set_from_command_line) &&
     2002        (lisp_heap_threshold_from_image != lisp_heap_gc_threshold)) {
     2003      lisp_heap_gc_threshold = lisp_heap_threshold_from_image;
     2004      resize_dynamic_heap(active_dynamic_area->active,lisp_heap_gc_threshold);
     2005    }
     2006    /* If lisp_heap_threshold_from_image was set, other image params are
     2007       valid. */
     2008    default_g0_threshold = lisp_global(G0_THRESHOLD);
     2009    default_g1_threshold = lisp_global(G1_THRESHOLD);
     2010    default_g2_threshold = lisp_global(G2_THRESHOLD);
     2011    egc_enabled = lisp_global(EGC_ENABLED);
     2012  }
     2013
     2014  lisp_global(TCR_AREA_LOCK) = ptr_to_lispobj(tcr_area_lock);
     2015
     2016#ifdef X86
     2017  lisp_global(SUBPRIMS_BASE) = (LispObj)((1<<16)+(5<<10));
     2018#endif
     2019#ifdef PPC
     2020  lisp_global(SUBPRIMS_BASE) = (LispObj)(5<<10);
     2021#endif
     2022#ifdef ARM
     2023  lisp_global(SUBPRIMS_BASE) = (LispObj)(9<<12);
     2024#endif
     2025
     2026  lisp_global(RET1VALN) = (LispObj)&ret1valn;
     2027  lisp_global(LEXPR_RETURN) = (LispObj)&nvalret;
     2028  lisp_global(LEXPR_RETURN1V) = (LispObj)&popj;
     2029  lisp_global(ALL_AREAS) = ptr_to_lispobj(all_areas);
     2030  lisp_global(DEFAULT_ALLOCATION_QUANTUM) = log2_heap_segment_size << fixnumshift;
     2031  lisp_global(STACK_SIZE) = thread_stack_size<<fixnumshift;
     2032
     2033
     2034  exception_init();
     2035
     2036 
     2037
     2038#ifdef WINDOWS
     2039  lisp_global(IMAGE_NAME) = ptr_to_lispobj(utf_16_to_utf_8(ensure_real_path(image_name)));
     2040  lisp_global(KERNEL_PATH) = ptr_to_lispobj(utf_16_to_utf_8(real_executable_name));
     2041  lisp_global(ARGV) = ptr_to_lispobj(wide_argv_to_utf_8(utf_16_argv, argc));
     2042#else
     2043  lisp_global(IMAGE_NAME) = ptr_to_lispobj(ensure_real_path(image_name));
     2044  lisp_global(KERNEL_PATH) = ptr_to_lispobj(real_executable_name);
     2045  lisp_global(ARGV) = ptr_to_lispobj(argv);
     2046#endif
     2047  lisp_global(KERNEL_IMPORTS) = (LispObj)import_ptrs_base;
     2048
     2049  lisp_global(GET_TCR) = (LispObj) get_tcr;
     2050  *(double *) &(lisp_global(DOUBLE_FLOAT_ONE)) = (double) 1.0;
     2051
     2052  lisp_global(HOST_PLATFORM) = (LispObj) PLATFORM << fixnumshift;
     2053
     2054  lisp_global(BATCH_FLAG) = (batch_flag << fixnumshift);
     2055
     2056  init_consing_areas();
    20532057  tcr = new_tcr(initial_stack_size, MIN_TSTACK_SIZE);
    20542058  stack_base = initial_stack_bottom()-xStackSpace();
     
    25912595#ifdef ANDROID
    25922596#include <jni.h>
     2597#include <android/log.h>
    25932598#include "android_native_app_glue.h"
     2599
     2600extern int init_lisp(TCR *);
     2601
     2602JavaVM *android_vm = NULL;
    25942603
    25952604jint
    25962605JNI_OnLoad(JavaVM *vm, void *unused)
    25972606{
     2607  extern int page_size;
     2608  Boolean egc_enabled =
     2609#ifdef DISABLE_EGC
     2610    false
     2611#else
     2612    true
     2613#endif
     2614    ;
     2615  TCR *tcr;
     2616  BytePtr stack_base, current_sp = (BytePtr) current_stack_pointer();
     2617 
     2618#if 1
     2619  sleep(100);
     2620#endif
     2621  android_vm = vm;
     2622
     2623  page_size = getpagesize();
     2624 
     2625  if (!check_arm_cpu()) {
     2626    __android_log_print(ANDROID_LOG_FATAL,"nativeCCL","CPU doesn't support required features");
     2627      return -1;
     2628  }
     2629  main_thread_pid = getpid();
     2630  tcr_area_lock = (void *)new_recursive_lock();
     2631  image_name = "/data/local/ccl/android.image"; /* need something better. */
     2632  while (1) {
     2633    if (create_reserved_area(reserved_area_size)) {
     2634      break;
     2635    }
     2636    reserved_area_size = reserved_area_size *.9;
     2637  }
     2638
     2639  gc_init();
     2640
     2641  set_nil(load_image(image_name));
     2642  lisp_heap_notify_threshold = GC_NOTIFY_THRESHOLD;
     2643  lisp_heap_threshold_from_image = lisp_global(LISP_HEAP_THRESHOLD);
     2644 
     2645  if (lisp_heap_threshold_from_image) {
     2646    if (lisp_heap_threshold_from_image != lisp_heap_gc_threshold) {
     2647      lisp_heap_gc_threshold = lisp_heap_threshold_from_image;
     2648      resize_dynamic_heap(active_dynamic_area->active,lisp_heap_gc_threshold);
     2649    }
     2650    /* If lisp_heap_threshold_from_image was set, other image params are
     2651       valid. */
     2652    default_g0_threshold = lisp_global(G0_THRESHOLD);
     2653    default_g1_threshold = lisp_global(G1_THRESHOLD);
     2654    default_g2_threshold = lisp_global(G2_THRESHOLD);
     2655    egc_enabled = lisp_global(EGC_ENABLED);
     2656  }
     2657  lisp_global(TCR_AREA_LOCK) = ptr_to_lispobj(tcr_area_lock);
     2658#ifdef ARM
     2659  lisp_global(SUBPRIMS_BASE) = (LispObj)(9<<12);
     2660#endif
     2661  lisp_global(RET1VALN) = (LispObj)&ret1valn;
     2662  lisp_global(LEXPR_RETURN) = (LispObj)&nvalret;
     2663  lisp_global(LEXPR_RETURN1V) = (LispObj)&popj;
     2664  lisp_global(ALL_AREAS) = ptr_to_lispobj(all_areas);
     2665  lisp_global(DEFAULT_ALLOCATION_QUANTUM) = log2_heap_segment_size << fixnumshift;
     2666  lisp_global(STACK_SIZE) = thread_stack_size<<fixnumshift;
     2667
     2668
     2669  exception_init();
     2670
     2671  lisp_global(IMAGE_NAME) = ptr_to_lispobj(ensure_real_path(image_name));
     2672  lisp_global(KERNEL_PATH) = ptr_to_lispobj(real_executable_name);
     2673  lisp_global(ARGV) = (LispObj)NULL;
     2674  lisp_global(KERNEL_IMPORTS) = (LispObj)import_ptrs_base;
     2675
     2676  lisp_global(GET_TCR) = (LispObj) get_tcr;
     2677  *(double *) &(lisp_global(DOUBLE_FLOAT_ONE)) = (double) 1.0;
     2678
     2679  lisp_global(HOST_PLATFORM) = (LispObj) PLATFORM << fixnumshift;
     2680
     2681  lisp_global(BATCH_FLAG) = (batch_flag << fixnumshift);
     2682
     2683  init_consing_areas();
     2684  tcr = new_tcr(initial_stack_size, MIN_TSTACK_SIZE);
     2685  stack_base = initial_stack_bottom()-xStackSpace();
     2686  init_threads((void *)(stack_base), tcr);
     2687  thread_init_tcr(tcr, current_sp, current_sp-stack_base);
     2688
     2689  if (lisp_global(STATIC_CONSES) == 0) {
     2690    lisp_global(STATIC_CONSES) = lisp_nil;
     2691  }
     2692
     2693
     2694  lisp_global(EXCEPTION_LOCK) = ptr_to_lispobj(new_recursive_lock());
     2695  enable_fp_exceptions();
     2696  register_user_signal_handler();
     2697  TCR_AUX(tcr)->prev = TCR_AUX(tcr)->next = tcr;
     2698  lisp_global(INTERRUPT_SIGNAL) = (LispObj) box_fixnum(SIGNAL_FOR_PROCESS_INTERRUPT);
     2699#ifdef GC_INTEGRITY_CHECKING
     2700  (nrs_GC_EVENT_STATUS_BITS.vcell |= gc_integrity_check_bit);
     2701#endif
     2702  if (egc_enabled) {
     2703    egc_control(true, NULL);
     2704  } else {
     2705    lisp_global(OLDSPACE_DNODE_COUNT) = area_dnode(managed_static_area->active,managed_static_area->low);
     2706  }
     2707
     2708  if (init_lisp(TCR_TO_TSD(tcr)) == 0) {
     2709    return JNI_VERSION_1_6;
     2710  }
    25982711  return -1;
    25992712}
     
    26112724android_main(struct android_app* state)
    26122725{
    2613 }
    2614 #endif
    2615 
     2726  TCR *tcr = new_tcr(DEFAULT_INITIAL_STACK_SIZE, MIN_TSTACK_SIZE);
     2727  JNIEnv *env;
     2728
     2729  thread_init_tcr(tcr, current_stack_pointer,DEFAULT_INITIAL_STACK_SIZE);
     2730  (*android_vm)->AttachCurrentThread(android_vm, &env, NULL);
     2731
     2732  os_main(tcr, state);
     2733  (*android_vm)->DetachCurrentThread(android_vm);
     2734}
     2735#endif
     2736
Note: See TracChangeset for help on using the changeset viewer.