Ticket #860: inlined-checks.patch

File inlined-checks.patch, 4.8 KB (added by sjamaan, 9 years ago)

Inlined C_in_stackp and friends

  • chicken.h

    diff --git a/chicken.h b/chicken.h
    index 4b57313..0e536c0 100644
    a b typedef void (C_ccall *C_proc)(C_word, C_word *) C_noret; 
    10611061#else
    10621062# define C_stack_pointer ((C_word *)C_alloca(0))
    10631063#endif
    1064 #define C_stack_pointer_test       ((C_word *)C_alloca(1))
    10651064#define C_demand_2(n)              (((C_word *)C_fromspace_top + (n)) < (C_word *)C_fromspace_limit)
    10661065#define C_fix(n)                   ((C_word)((C_uword)(n) << C_FIXNUM_SHIFT) | C_FIXNUM_BIT)
    10671066#define C_unfix(x)                 C_CHECKp(x,C_fixnump(C_VAL1(x)),((C_VAL1(x)) >> C_FIXNUM_SHIFT))
    C_fctexport void C_fcall C_rereclaim2(C_uword size, int double_plus) C_regparm; 
    18231822C_fctexport void C_unbound_variable(C_word sym);
    18241823C_fctexport C_word C_fcall C_retrieve2(C_word val, char *name) C_regparm;
    18251824C_fctexport void *C_fcall C_retrieve2_symbol_proc(C_word val, char *name) C_regparm;
    1826 C_fctexport int C_in_stackp(C_word x) C_regparm;
    1827 C_fctexport int C_fcall C_in_heapp(C_word x) C_regparm;
    1828 C_fctexport int C_fcall C_in_fromspacep(C_word x) C_regparm;
    1829 C_fctexport int C_fcall C_in_scratchspacep(C_word x) C_regparm;
     1825C_fctexport C_word C_permanentp(C_word x) C_regparm;
    18301826C_fctexport void C_fcall C_trace(C_char *name) C_regparm;
    18311827C_fctexport C_word C_fcall C_emit_trace_info2(char *raw, C_word x, C_word y, C_word t) C_regparm;
    18321828C_fctexport C_word C_fcall C_u_i_string_hash(C_word str, C_word rnd) C_regparm;
    C_mutate2(C_word *slot, C_word val) /* OBSOLETE */ 
    21922188  else return *slot = val;
    21932189}
    21942190
    2195 C_inline C_word C_permanentp(C_word x)
    2196 {
    2197   return C_mk_bool(!C_immediatep(x) && !C_in_stackp(x) && !C_in_heapp(x));
    2198 }
    2199 
    2200 
    22012191C_inline C_word C_flonum(C_word **ptr, double n)
    22022192{
    22032193  C_word
  • runtime.c

    diff --git a/runtime.c b/runtime.c
    index c9c9d94..2f5bb71 100644
    a b static void C_fcall really_mark(C_word *x) C_regparm; 
    506506static WEAK_TABLE_ENTRY *C_fcall lookup_weak_table_entry(C_word item, C_word container) C_regparm;
    507507static C_cpsproc(values_continuation) C_noret;
    508508static C_word add_symbol(C_word **ptr, C_word key, C_word string, C_SYMBOL_TABLE *stable);
    509 static C_regparm int C_fcall C_in_new_heapp(C_word x);
    510509static C_regparm C_word bignum_times_bignum_unsigned(C_word **ptr, C_word x, C_word y, C_word negp);
    511510static C_regparm C_word bignum_extract_digits(C_word **ptr, C_word n, C_word x, C_word start, C_word end);
    512511
    C_word C_dbg_hook(C_word dummy) 
    19401939  return dummy;
    19411940}
    19421941
     1942/* Inlineable memory region predicates */
     1943
     1944C_inline int C_in_stackp(C_word x)
     1945{
     1946  C_word *ptr = (C_word *)(C_uword)x;
     1947
     1948#if C_STACK_GROWS_DOWNWARD
     1949  return ptr >= C_stack_pointer && ptr <= stack_bottom;
     1950#else
     1951  return ptr < C_stack_pointer && ptr >= stack_bottom;
     1952#endif
     1953}
     1954
     1955C_inline int C_fcall C_in_heapp(C_word x)
     1956{
     1957  C_byte *ptr = (C_byte *)(C_uword)x;
     1958  return (ptr >= fromspace_start && ptr < C_fromspace_limit) ||
     1959         (ptr >= tospace_start && ptr < tospace_limit);
     1960}
     1961
     1962/* Only used during major GC (heap realloc) */
     1963C_inline int C_fcall C_in_new_heapp(C_word x)
     1964{
     1965  C_byte *ptr = (C_byte *)(C_uword)x;
     1966  return (ptr >= new_tospace_start && ptr < new_tospace_limit);
     1967}
     1968
     1969C_inline int C_fcall C_in_fromspacep(C_word x)
     1970{
     1971  C_byte *ptr = (C_byte *)(C_uword)x;
     1972  return (ptr >= fromspace_start && ptr < C_fromspace_limit);
     1973}
     1974
     1975C_inline int C_fcall C_in_scratchspacep(C_word x)
     1976{
     1977  C_word *ptr = (C_word *)(C_uword)x;
     1978  return (ptr >= C_scratchspace_start && ptr < C_scratchspace_limit);
     1979}
     1980
     1981C_regparm C_word C_permanentp(C_word x)
     1982{
     1983  return C_mk_bool(!C_immediatep(x) && !C_in_stackp(x) && !C_in_heapp(x));
     1984}
    19431985
    19441986/* Timing routines: */
    19451987
    C_word add_symbol(C_word **ptr, C_word key, C_word string, C_SYMBOL_TABLE *stabl 
    23852427  return sym;
    23862428}
    23872429
    2388 
    2389 C_regparm int C_in_stackp(C_word x)
    2390 {
    2391   C_word *ptr = (C_word *)(C_uword)x;
    2392 
    2393 #if C_STACK_GROWS_DOWNWARD
    2394   return ptr >= C_stack_pointer_test && ptr <= stack_bottom;
    2395 #else
    2396   return ptr < C_stack_pointer_test && ptr >= stack_bottom;
    2397 #endif
    2398 }
    2399 
    2400 
    2401 C_regparm int C_fcall C_in_heapp(C_word x)
    2402 {
    2403   C_byte *ptr = (C_byte *)(C_uword)x;
    2404   return (ptr >= fromspace_start && ptr < C_fromspace_limit) ||
    2405          (ptr >= tospace_start && ptr < tospace_limit);
    2406 }
    2407 
    2408 /* Only used during major GC (heap realloc) */
    2409 static C_regparm int C_fcall C_in_new_heapp(C_word x)
    2410 {
    2411   C_byte *ptr = (C_byte *)(C_uword)x;
    2412   return (ptr >= new_tospace_start && ptr < new_tospace_limit);
    2413 }
    2414 
    2415 C_regparm int C_fcall C_in_fromspacep(C_word x)
    2416 {
    2417   C_byte *ptr = (C_byte *)(C_uword)x;
    2418   return (ptr >= fromspace_start && ptr < C_fromspace_limit);
    2419 }
    2420 
    2421 C_regparm int C_fcall C_in_scratchspacep(C_word x)
    2422 {
    2423   C_word *ptr = (C_word *)(C_uword)x;
    2424   return (ptr >= C_scratchspace_start && ptr < C_scratchspace_limit);
    2425 }
    2426 
    24272430/* Cons the rest-aguments together: */
    24282431
    24292432C_regparm C_word C_fcall C_build_rest(C_word **ptr, C_word c, C_word n, C_word *av)