Changeset 22281 for v6

Show
Ignore:
Timestamp:
09/18/08 19:46:04 (2 months ago)
Author:
ruoso
Message:

[smop] fixed two memory leaks. changed a bit the SMOP_LOWLEVEL_MEM_DEBUG code and added SMOP_MOLD_DEBUG and SMOP_SLIME_DEBUG that prints when it is evaluating some call both the name of the method as well as the type

Location:
v6/smop
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • v6/smop/CMakeLists.txt

    r22275 r22281  
    11project (smop) 
    22SET( CMAKE_C_FLAGS "-O0 -g3 -DSMOP_LOWLEVEL_MEM_TRACE" ) 
     3#SET( CMAKE_C_FLAGS "-O0 -g3 -DSMOP_LOWLEVEL_MEM_TRACE -DSMOP_LOWLEVEL_MEM_DEBUG -DSMOP_MOLD_DEBUG -DSMOP_SLIME_DEBUG" ) 
    34SET( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE ) 
    45cmake_minimum_required (VERSION 2.6) 
  • v6/smop/include/smop_base.h

    r22274 r22281  
    8585#ifdef SMOP_LOWLEVEL_MEM_DEBUG 
    8686#define SMOP_REFERENCE(interpreter, object) \ 
    87       (fprintf(stderr,"SMOP_REFERENCE(%p) at %s line %d file %s\n",object,__func__,__LINE__,__FILE__),\ 
     87      (fprintf(stderr,"[SMOP_LOWLEVEL_MEM_DEBUG] ++ (%p) %s:%d (%s)\n",object,__FILE__,__LINE__,__func__),\ 
    8888      (((SMOP__ResponderInterface*)(((SMOP__Object*)object)->RI)?(((SMOP__Object*)object)->RI):((SMOP__ResponderInterface*)object))->REFERENCE( (SMOP__Object*)interpreter, \ 
    8989          ((SMOP__ResponderInterface*)(((SMOP__Object*)object)->RI)?(((SMOP__Object*)object)->RI):((SMOP__ResponderInterface*)object)), \ 
     
    9292 
    9393#define SMOP_RELEASE(interpreter, object) \ 
    94       (fprintf(stderr,"SMOP_RELEASE(%p) at %s line %d file %s\n",object,__func__,__LINE__,__FILE__), \ 
     94      (fprintf(stderr,"[SMOP_LOWLEVEL_MEM_DEBUG] -- (%p) %s:%d (%s)\n",object,__FILE__,__LINE__,__func__),\ 
    9595      (((SMOP__ResponderInterface*)(((SMOP__Object*)object)->RI)?(((SMOP__Object*)object)->RI):((SMOP__ResponderInterface*)object))->RELEASE( (SMOP__Object*)interpreter, \ 
    9696          ((SMOP__ResponderInterface*)(((SMOP__Object*)object)->RI)?(((SMOP__Object*)object)->RI):((SMOP__ResponderInterface*)object)), \ 
  • v6/smop/src/smop_lowlevel.sm0p

    r22230 r22281  
    162162 
    163163SMOP__Object* smop_lowlevel_refcnt_inc(SMOP__Object* interpreter, SMOP__ResponderInterface* ri, SMOP__Object* value) { 
    164 #ifdef SMOP_LOWLEVEL_MEM_DEBUG 
    165   fprintf(stderr,"[SMOP_LOWLEVEL_MEM_DEBUG] refcont_inc: %p\n",value); 
    166 #endif 
    167164  smop_lowlevel_wrlock(value); 
    168165  ((SMOP_LOWLEVEL_INTERNAL*)value->data)->ref_cnt++; 
     
    172169 
    173170SMOP__Object* smop_lowlevel_refcnt_dec(SMOP__Object* interpreter, SMOP__ResponderInterface* ri, SMOP__Object* value) { 
    174 #ifdef SMOP_LOWLEVEL_MEM_DEBUG 
    175   fprintf(stderr,"[SMOP_LOWLEVEL_MEM_DEBUG] refcont_dec: %p\n",value); 
    176 #endif 
    177171  smop_lowlevel_wrlock(value); 
    178172  ((SMOP_LOWLEVEL_INTERNAL*)value->data)->ref_cnt--; 
  • v6/smop/src/smop_mold.c

    r22198 r22281  
    258258        free(call_named); 
    259259        free(call_pos); 
     260 
     261#ifdef SMOP_MOLD_DEBUG 
     262        if (identifier && SMOP_RI(identifier) == SMOP_RI(SMOP__ID__new)) { 
     263          int u; 
     264          char* external = SMOP__NATIVE__idconst_fetch(call_identifier, &u); 
     265          char* local = malloc(u+1); 
     266          memcpy(local, external, u); 
     267          local[u] = 0; 
     268          fprintf(stderr, "[SMOP_MOLD_DEBUG] eval \"%s\" on \"%s\".\n", local, SMOP_RI(call_invocant)->id); 
     269          free(local); 
     270        } else { 
     271          fprintf(stderr, "[SMOP_MOLD_DEBUG] eval on \"%s\".\n", SMOP_RI(call_invocant)->id); 
     272        } 
     273#endif 
     274         
    260275 
    261276        SMOP__Object* ret = SMOP_DISPATCH(interpreter,SMOP_RI(call_invocant),call_identifier,capture); 
     
    292307        SMOP__Object* call_capture = get_register(interpreter,frame); 
    293308 
     309#ifdef SMOP_MOLD_DEBUG 
     310        if (identifier && SMOP_RI(identifier) == SMOP_RI(SMOP__ID__new)) { 
     311          int u; 
     312          char* external = SMOP__NATIVE__idconst_fetch(call_identifier, &u); 
     313          char* local = malloc(u+1); 
     314          memcpy(local, external, u); 
     315          local[u] = 0; 
     316          fprintf(stderr, "[SMOP_MOLD_DEBUG] eval \"%s\" on \"%s\".\n", local, ((SMOP__ResponderInterface*)call_responder)->id); 
     317          free(local); 
     318        } else { 
     319          fprintf(stderr, "[SMOP_MOLD_DEBUG] eval on \"%s\".\n", ((SMOP__ResponderInterface*)call_responder)->id); 
     320        } 
     321#endif 
     322 
    294323        SMOP__Object* ret = SMOP_DISPATCH(interpreter,SMOP_RI(call_responder),call_identifier,call_capture); 
    295324        SMOP_RELEASE(interpreter,call_responder); 
  • v6/smop/src/smop_s1p_array_iterator.sm0p

    r22272 r22281  
    4646    mold_reg_set(interpreter,frame,0,SMOP_REFERENCE(interpreter,interpreter)); 
    4747    mold_reg_set(interpreter,frame,1,SMOP_REFERENCE(interpreter,capture)); 
    48     mold_reg_set(interpreter,frame,2,SMOP_REFERENCE(interpreter,back)); 
     48    mold_reg_set(interpreter,frame,2,back); 
    4949 
    5050    SMOP_DISPATCH(interpreter,SMOP_RI(interpreter),SMOP__ID__goto,frame); 
  • v6/smop/src/smop_s1p_root_namespace.c

    r22230 r22281  
    2424void smop_s1p_root_namespace_init() { 
    2525  SMOP__S1P__RootNamespace = SMOP__S1P__Hash_create(); 
    26   smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Hash",SMOP__S1P__Hash_create()); 
    27   smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Array",SMOP__S1P__Array_create()); 
    28   smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"$*OUT",SMOP__S1P__IO_create(SMOP__GlobalInterpreter)); 
    29   //smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Code",SMOP__S1P__Code_create(SMOP__NATIVE__bool_false)); 
    30   SMOP__Object* mold = SMOP__Mold_create(0,(SMOP__Object*[]) { NULL },1,(int[]) { 0 }); 
    31   smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Mold",SMOP_REFERENCE(SMOP__GlobalInterpreter,mold)); 
    32   smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::MoldFrame",SMOP__Mold__Frame_create(SMOP__GlobalInterpreter,mold)); 
    33   smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Code",SMOP__S1P__Code_create()); 
     26  smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Hash", SMOP__S1P__Hash); 
     27  smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Array", SMOP__S1P__Array); 
     28  smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"$*OUT", SMOP__S1P__IO_create(SMOP__GlobalInterpreter)); 
     29  smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Mold", SMOP__Mold); 
     30  smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::MoldFrame", SMOP__Mold__Frame); 
     31  smop_s1p_root_namespace_insert(SMOP__GlobalInterpreter,"::Code", SMOP__S1P__Code); 
    3432} 
    3533 
  • v6/smop/src/smop_slime_node.c

    r22017 r22281  
    181181      memcpy(local, external, u); 
    182182      local[u] = 0; 
    183       fprintf(stderr, "[node] eval \"%s\".\n", local); 
     183      fprintf(stderr, "[SMOP_SLIME_DEBUG] eval \"%s\" on \"%s\".\n", local, ((SMOP__ResponderInterface*)responder)); 
    184184      free(local); 
    185185    } else { 
    186       fprintf(stderr, "[node] eval.\n"); 
     186      fprintf(stderr, "[SMOP_SLIME_DEBUG] eval on \"%s\".\n", ((SMOP__ResponderInterface*)responder)); 
    187187    } 
    188188#endif 
  • v6/smop/tools/ri

    r22270 r22281  
    9696  } 
    9797 
     98  if (invocant) SMOP_RELEASE(interpreter,invocant); 
    9899  SMOP_RELEASE(interpreter,capture); 
    99100  return ret;