[Tinyos-commits] CVS: tinyos-1.x/tos/lib/VM/languages/motlle/standalone alloc.c, 1.2, 1.3 alloc.h, 1.2, 1.3 compile.c, 1.8, 1.9 global.c, 1.4, 1.5 interpret.c, 1.3, 1.4 memory.c, 1.2, 1.3 motlle.c, 1.5, 1.6 scheme.c, 1.16, 1.17 types.c, 1.3, 1.4

David Gay idgay at users.sourceforge.net
Tue Nov 22 13:52:07 PST 2005


Update of /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10804

Modified Files:
	alloc.c alloc.h compile.c global.c interpret.c memory.c 
	motlle.c scheme.c types.c 
Log Message:
gcpro bugs


Index: alloc.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/alloc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** alloc.c	30 Nov 2004 18:52:44 -0000	1.2
--- alloc.c	22 Nov 2005 21:52:04 -0000	1.3
***************
*** 258,262 ****
  {
  #ifndef TINY
!   fprintf(stderr, "GC ..."); fflush(stderr);
  #endif
    MDBG8(dbg_gc);
--- 258,262 ----
  {
  #ifndef TINY
!   //fprintf(stderr, "GC ..."); fflush(stderr);
  #endif
    MDBG8(dbg_gc);
***************
*** 290,294 ****
  
  #ifndef TINY
!   fprintf(stderr, "\n"); fflush(stderr);
  #endif
  }
--- 290,294 ----
  
  #ifndef TINY
!   //fprintf(stderr, "\n"); fflush(stderr);
  #endif
  }

Index: alloc.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/alloc.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** alloc.h	30 Nov 2004 18:52:44 -0000	1.2
--- alloc.h	22 Nov 2005 21:52:04 -0000	1.3
***************
*** 106,114 ****
  extern uvalue localpro_size;
  void increase_localpro(void);
! #define GCPRO_CHECK ((gcpro - localpro) == localpro_size ? increase_localpro() : 0), 
  #endif
  
! #define GCPRO1(var) (GCPRO_CHECK *gcpro++ = (value *)&(var))
! #define GCPRO2(var1, var2) (GCPRO1(var1), GCPRO1(var2))
  #define GCPOP(n) (gcpro -= (n))
  
--- 106,114 ----
  extern uvalue localpro_size;
  void increase_localpro(void);
! #define GCPRO_CHECK ((gcpro - localpro) == localpro_size ? increase_localpro() : 0)
  #endif
  
! #define GCPRO1(var) do { GCPRO_CHECK; GCCHECK(var); *gcpro++ = (value *)&(var); } while (0)
! #define GCPRO2(var1, var2) do { GCPRO1(var1); GCPRO1(var2); } while (0)
  #define GCPOP(n) (gcpro -= (n))
  

Index: compile.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/compile.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** compile.c	19 Nov 2005 00:42:09 -0000	1.8
--- compile.c	22 Nov 2005 21:52:04 -0000	1.9
***************
*** 995,1002 ****
  		   bool dontrun)
  {
!   struct compile_and_run_frame *frame =
!     push_frame(compile_and_run_action, sizeof(struct compile_and_run_frame));
!   struct compile_context *ccontext =
!     (struct compile_context *)allocate_record(type_vector, 2);
  
    frame->dontrun = dontrun;
--- 995,1004 ----
  		   bool dontrun)
  {
!   struct compile_and_run_frame *frame;
!   struct compile_context *ccontext;
! 
!   GCPRO1(gstate);
!   frame = push_frame(compile_and_run_action, sizeof(struct compile_and_run_frame));
!   ccontext = (struct compile_context *)allocate_record(type_vector, 2);
  
    frame->dontrun = dontrun;
***************
*** 1004,1007 ****
--- 1006,1010 ----
    ccontext->gstate = gstate;
    /* no evaluation_state yet */
+   GCPOP(1);
  
    frame->state = init;

Index: global.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/global.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** global.c	14 Oct 2005 00:20:31 -0000	1.4
--- global.c	22 Nov 2005 21:52:04 -0000	1.5
***************
*** 35,49 ****
  {
    struct global_state *gstate;
  
    GCPRO1(machine);
    gstate = (struct global_state *)allocate_record(type_vector, 8);
    GCPRO1(gstate);
!   gstate->modules = alloc_table(DEF_TABLE_SIZE);
!   gstate->mvars = alloc_vector(GLOBAL_SIZE);
!   gstate->types = alloc_vector(GLOBAL_SIZE);
!   gstate->names = alloc_vector(GLOBAL_SIZE);
!   gstate->global = alloc_table(GLOBAL_SIZE);
!   gstate->gsymbols = alloc_table(DEF_TABLE_SIZE);
!   gstate->environment = alloc_env(GLOBAL_SIZE);
    gstate->machine = machine;
    GCPOP(2);
--- 35,50 ----
  {
    struct global_state *gstate;
+   value tmp;
  
    GCPRO1(machine);
    gstate = (struct global_state *)allocate_record(type_vector, 8);
    GCPRO1(gstate);
!   tmp = alloc_table(DEF_TABLE_SIZE); gstate->modules = tmp;
!   tmp = alloc_vector(GLOBAL_SIZE); gstate->mvars = tmp;
!   tmp = alloc_vector(GLOBAL_SIZE); gstate->types = tmp;
!   tmp = alloc_vector(GLOBAL_SIZE); gstate->names = tmp;
!   tmp = alloc_table(GLOBAL_SIZE); gstate->global = tmp;
!   tmp = alloc_table(DEF_TABLE_SIZE); gstate->gsymbols = tmp;
!   tmp = alloc_env(GLOBAL_SIZE); gstate->environment = tmp;
    gstate->machine = machine;
    GCPOP(2);

Index: interpret.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/interpret.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** interpret.c	18 Nov 2005 18:47:41 -0000	1.3
--- interpret.c	22 Nov 2005 21:52:04 -0000	1.4
***************
*** 753,762 ****
  CC push_closure(struct closure *fn, u8 nargs)
  {
-   struct code *code = fn->code;
    struct interpret_frame *frame;
!   u8 nb_nonargs = code->nb_locals - code->nargs;
    int frame_size;
    u16 i;
!   i8 fnargs = code->nargs;
    value *args = (value *)sp;
    struct vector *vargs = NULL;
--- 753,761 ----
  CC push_closure(struct closure *fn, u8 nargs)
  {
    struct interpret_frame *frame;
!   u8 nb_nonargs, nb_locals = fn->code->nb_locals;
    int frame_size;
    u16 i;
!   i8 fnargs = fn->code->nargs;
    value *args = (value *)sp;
    struct vector *vargs = NULL;
***************
*** 764,770 ****
  
    MDBG8(dbg_push_closure);
-   MDBG16(code);
    MDBG16(sp);
  
    if (fnargs < 0)
      {
--- 763,769 ----
  
    MDBG8(dbg_push_closure);
    MDBG16(sp);
  
+   GCPRO2(fn, vargs);
    if (fnargs < 0)
      {
***************
*** 779,794 ****
        /* Pop args from stack and reserve space for vargs */
        sp += nargs * sizeof(value);
!       nb_nonargs = code->nb_locals;
      }
    else
!     nb_nonargs = code->nb_locals - code->nargs;
  
-   frame_size = offsetof(struct interpret_frame, locals) +
-     nb_nonargs * sizeof(value);
-   GCPRO1(fn);
    frame = push_frame(interpret_action, frame_size);
!   GCPOP(1);
  
-   code = fn->code;
    frame->ins = 0;
    frame->fn = fn;
--- 778,795 ----
        /* Pop args from stack and reserve space for vargs */
        sp += nargs * sizeof(value);
!       nb_nonargs = nb_locals - 1;
!       frame_size = offsetof(struct interpret_frame, locals) +
! 	nb_locals * sizeof(value);
      }
    else
!     {
!       nb_nonargs = nb_locals - fnargs;
!       frame_size = offsetof(struct interpret_frame, locals) +
! 	nb_nonargs * sizeof(value);
!     }
  
    frame = push_frame(interpret_action, frame_size);
!   GCPOP(2);
  
    frame->ins = 0;
    frame->fn = fn;
***************
*** 798,802 ****
  #ifndef TINY
    /* Profiling */
!   code->call_count++;
    frame->start_ins = instruction_number;
  #endif
--- 799,803 ----
  #ifndef TINY
    /* Profiling */
!   fn->code->call_count++;
    frame->start_ins = instruction_number;
  #endif
***************
*** 804,808 ****
    if (fnargs < 0)
      /* Save vargs in the right place */
!     frame->locals[code->nb_locals - 1] = (value)vargs;
    else
      {
--- 805,809 ----
    if (fnargs < 0)
      /* Save vargs in the right place */
!     frame->locals[nb_locals - 1] = (value)vargs;
    else
      {
***************
*** 819,823 ****
  
    /* Make local variables */
!   allocate_locals(frame->locals, code->nb_locals);
  
    /* We don't check for infinite loops through function calls because
--- 820,824 ----
  
    /* Make local variables */
!   allocate_locals(frame->locals, nb_locals);
  
    /* We don't check for infinite loops through function calls because

Index: memory.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/memory.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** memory.c	30 Nov 2004 18:52:44 -0000	1.2
--- memory.c	22 Nov 2005 21:52:04 -0000	1.3
***************
*** 24,28 ****
      }
  #else
!   if (sp - n < splimit)
      {
        garbage_collect();
--- 24,28 ----
      }
  #else
!   if (sp - n < splimit || debug_lvl >= 5)
      {
        garbage_collect();
***************
*** 35,39 ****
  bool try_gc_reserve(uvalue n)
  {
!   if (!CANGC(n, 0))
      {
        garbage_collect();
--- 35,39 ----
  bool try_gc_reserve(uvalue n)
  {
!   if (!CANGC(n, 0) || debug_lvl >= 4)
      {
        garbage_collect();

Index: motlle.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/motlle.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** motlle.c	25 Oct 2005 22:33:21 -0000	1.5
--- motlle.c	22 Nov 2005 21:52:04 -0000	1.6
***************
*** 201,205 ****
        {
        case 'd':
! 	debug_lvl = 2;
  	break;
        case '?':
--- 201,205 ----
        {
        case 'd':
! 	debug_lvl++;
  	break;
        case '?':

Index: scheme.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/scheme.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** scheme.c	22 Nov 2005 18:33:11 -0000	1.16
--- scheme.c	22 Nov 2005 21:52:04 -0000	1.17
***************
*** 9,15 ****
  #include "scheme.h"
  
! /* MAYGC
!    env_lookup
!    generate_fncode
  */
  
--- 9,14 ----
  #include "scheme.h"
  
! /* mgc stands for may cause garbage collection (=> must protect gcable
!    variables)
  */
  
***************
*** 599,603 ****
  }
  
! static void define_of(location l, vlist var, fncode fn)
  {
    /* in-block declarations are handled by compile_block */
--- 598,602 ----
  }
  
! static void define_of_mgc(location l, vlist var, fncode fn)
  {
    /* in-block declarations are handled by compile_block */
***************
*** 611,618 ****
    int toplevel = fntoplevel(fn);
  
    if (TYPE(args->car, type_symbol) && list_length(args) == 2)
      {
        vfn = sym2vlist(fnmemory(fn), l, args->car);
!       define_of(l, vfn, fn);
        scheme_compile_mgc(l, nth(args, 2), FALSE, fn);
      }
--- 610,618 ----
    int toplevel = fntoplevel(fn);
  
+   GCPRO1(args);
    if (TYPE(args->car, type_symbol) && list_length(args) == 2)
      {
        vfn = sym2vlist(fnmemory(fn), l, args->car);
!       define_of_mgc(l, vfn, fn);
        scheme_compile_mgc(l, nth(args, 2), FALSE, fn);
      }
***************
*** 626,630 ****
  
  	  vfn = sym2vlist(fnmemory(fn), l, name);
! 	  define_of(l, vfn, fn);
  	  sgen_function_mgc(l, name->name, fndecl->cdr, args->cdr, FALSE, fn);
  	}
--- 626,632 ----
  
  	  vfn = sym2vlist(fnmemory(fn), l, name);
! 	  GCPRO2(fndecl, name);
! 	  define_of_mgc(l, vfn, fn);
! 	  GCPOP(2);
  	  sgen_function_mgc(l, name->name, fndecl->cdr, args->cdr, FALSE, fn);
  	}
***************
*** 634,637 ****
--- 636,640 ----
    else
      sgen_assign_mgc(l, vfn->var, discard, fn);
+   GCPOP(1);
  }
  

Index: types.c
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/tos/lib/VM/languages/motlle/standalone/types.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** types.c	25 Oct 2005 23:08:52 -0000	1.3
--- types.c	22 Nov 2005 21:52:04 -0000	1.4
***************
*** 33,37 ****
    /* This could (should?) be optimised to avoid the need for
       GCPRO1/stack_reserve/GCPOP */
!   struct closure *newp = (struct closure *)unsafe_allocate_record(type_function, nb_variables + 1);
  
    SET_READONLY(newp);
--- 33,37 ----
    /* This could (should?) be optimised to avoid the need for
       GCPRO1/stack_reserve/GCPOP */
!   struct closure *newp = (struct closure *)allocate_record(type_function, nb_variables + 1);
  
    SET_READONLY(newp);



More information about the Tinyos-commits mailing list