pike.git / src / gc.c

version» Context lines:

pike.git/src/gc.c:1637:   PMOD_EXPORT void describe(void *x)   {    void *inblock;    int type = attempt_to_identify(x, &inblock);    describe_something(x, type, 0, 0, 0, inblock);   }      void debug_describe_svalue(struct svalue *s)   {    fprintf(stderr,"Svalue at %p is:\n",s); -  switch(s->type) +  switch(TYPEOF(*s))    {    case T_INT:    fprintf(stderr," %"PRINTPIKEINT"d (subtype %d)\n",s->u.integer, -  s->subtype); +  SUBTYPEOF(*s));    return;       case T_FLOAT:    fprintf(stderr," %"PRINTPIKEFLOAT"f\n",s->u.float_number);    return;       case T_FUNCTION: -  if(s->subtype == FUNCTION_BUILTIN) +  if(SUBTYPEOF(*s) == FUNCTION_BUILTIN)    {    fprintf(stderr," Builtin function: %s\n",s->u.efun->name->str);    }else{    if(!s->u.object->prog)    {    struct program *p=id_to_program(s->u.object->program_id);    if(p)    {    fprintf(stderr," Function in destructed object: %s\n", -  ID_FROM_INT(p,s->subtype)->name->str); +  ID_FROM_INT(p, SUBTYPEOF(*s))->name->str);    }else{    fprintf(stderr," Function in destructed object.\n");    }    }else{    fprintf(stderr," Function name: %s\n", -  ID_FROM_INT(s->u.object->prog,s->subtype)->name->str); +  ID_FROM_INT(s->u.object->prog, SUBTYPEOF(*s))->name->str);    }    }    } -  describe_something(s->u.refs,s->type,0,1,0,0); +  describe_something(s->u.refs, TYPEOF(*s), 0, 1, 0, 0);   }      void gc_watch(void *a)   {    struct marker *m;    init_gc();    m = get_marker(a);    if (!(m->flags & GC_WATCHED)) {    m->flags |= GC_WATCHED;    fprintf(stderr, "## Watching thing %p.\n", a);
pike.git/src/gc.c:4797:      static int mc_cycle_depth_from_obj (struct object *o)   {    struct program *p = o->prog;    struct svalue val;       if (!p) return 0; /* No need to look ahead in destructed objects. */       object_index_no_free2 (&val, o, 0, &pike_cycle_depth_str);    -  if (val.type != T_INT) { +  if (TYPEOF(val) != T_INT) {    int i = find_shared_string_identifier (pike_cycle_depth_str.u.string, p);    INT32 line;    struct pike_string *file = get_identifier_line (p, i, &line);    make_error ("Object got non-integer pike_cycle_depth %O at %S:%d.\n",    &val, file, line);    free_svalue (&val);    free_svalue (&throw_value);    move_svalue (&throw_value, --Pike_sp);    return -1;    }    -  if (val.subtype == NUMBER_UNDEFINED) +  if (SUBTYPEOF(val) == NUMBER_UNDEFINED)    return -1;       if (val.u.integer > (unsigned INT16) -1)    return (unsigned INT16) -1;       if (val.u.integer < 0) {    int i = find_shared_string_identifier (pike_cycle_depth_str.u.string, p);    INT32 line;    struct pike_string *file = get_identifier_line (p, i, &line);    make_error ("Object got negative pike_cycle_depth at %S:%d.\n",
pike.git/src/gc.c:5373:    unsigned count_visits, count_revisits, count_rounds;    int collect_stats = 0, return_count = 0;       if (args < 1)    SIMPLE_TOO_FEW_ARGS_ERROR ("count_memory", 1);       mc_block_lookahead = mc_block_lookahead_default;    mc_block_pike_cycle_depth = 0;    mc_block_strings = 0;    -  if (Pike_sp[-args].type == T_MAPPING) { +  if (TYPEOF(Pike_sp[-args]) == T_MAPPING) {    struct mapping *opts = Pike_sp[-args].u.mapping;    struct pike_string *ind;    struct svalue *val;       MAKE_CONST_STRING (ind, "lookahead");    if ((val = low_mapping_string_lookup (opts, ind))) { -  if (val->type != T_INT) +  if (TYPEOF(*val) != T_INT)    SIMPLE_ARG_ERROR ("count_memory", 1,    "\"lookahead\" must be an integer.");    mc_lookahead =    val->u.integer > (unsigned INT16) -1 ? (unsigned INT16) -1 :    val->u.integer < 0 ? -1 :    val->u.integer;    }    else    mc_lookahead = 0;   
pike.git/src/gc.c:5408:    } \    } while (0)    CHECK_BLOCK_FLAG ("block_arrays", BIT_ARRAY);    CHECK_BLOCK_FLAG ("block_mappings", BIT_MAPPING);    CHECK_BLOCK_FLAG ("block_multisets", BIT_MULTISET);    CHECK_BLOCK_FLAG ("block_objects", BIT_OBJECT);    CHECK_BLOCK_FLAG ("block_programs", BIT_PROGRAM);       MAKE_CONST_STRING (ind, "block_strings");    if ((val = low_mapping_string_lookup (opts, ind))) { -  if (val->type != T_INT) +  if (TYPEOF(*val) != T_INT)    SIMPLE_ARG_ERROR ("count_memory", 1,    "\"block_strings\" must be an integer.");    mc_block_strings = val->u.integer > 0 ? 1 : val->u.integer < 0 ? -1 : 0;    }       MAKE_CONST_STRING (ind, "block_pike_cycle_depth");    if ((val = low_mapping_string_lookup (opts, ind)) && !UNSAFE_IS_ZERO (val))    mc_block_pike_cycle_depth = 1;       MAKE_CONST_STRING (ind, "return_count");
pike.git/src/gc.c:5432:    MAKE_CONST_STRING (ind, "collect_internals");    if ((val = low_mapping_string_lookup (opts, ind)) && !UNSAFE_IS_ZERO (val))    collect_internal = Pike_sp; /* Value doesn't matter. */       MAKE_CONST_STRING (ind, "collect_stats");    if ((val = low_mapping_string_lookup (opts, ind)) && !UNSAFE_IS_ZERO (val))    collect_stats = 1;    }       else { -  if (Pike_sp[-args].type != T_INT) +  if (TYPEOF(Pike_sp[-args]) != T_INT)    SIMPLE_ARG_TYPE_ERROR ("count_memory", 1, "int|mapping(string:int)");    mc_lookahead =    Pike_sp[-args].u.integer > (unsigned INT16) -1 ? (unsigned INT16) -1 :    Pike_sp[-args].u.integer < 0 ? -1 :    Pike_sp[-args].u.integer;    }       init_mc_marker_hash();    -  if (pike_cycle_depth_str.type == PIKE_T_FREE) { -  pike_cycle_depth_str.type = T_STRING; +  if (TYPEOF(pike_cycle_depth_str) == PIKE_T_FREE) { +  SET_SVAL_TYPE(pike_cycle_depth_str, T_STRING);    MAKE_CONST_STRING (pike_cycle_depth_str.u.string, "pike_cycle_depth");    }       assert (mc_work_queue == NULL);    mc_work_queue = malloc (MC_WQ_START_SIZE * sizeof (mc_work_queue[0]));    if (!mc_work_queue) {    exit_mc_marker_hash();    SIMPLE_OUT_OF_MEMORY_ERROR ("Pike.count_memory",    MC_WQ_START_SIZE * sizeof (mc_work_queue[0]));    }
pike.git/src/gc.c:5469:    assert (visit_ref == NULL);       free_svalue (&throw_value);    mark_free_svalue (&throw_value);       {    int i;    for (i = -args + 1; i < 0; i++) {    struct svalue *s = Pike_sp + i;    -  if (s->type == T_INT) +  if (TYPEOF(*s) == T_INT)    continue;    -  else if (s->type > MAX_REF_TYPE) { +  else if (TYPEOF(*s) > MAX_REF_TYPE) {    exit_mc_marker_hash();    free (mc_work_queue + 1);    mc_work_queue = NULL;    SIMPLE_ARG_TYPE_ERROR (    "count_memory", i + args + 1,    "array|multiset|mapping|object|program|string|type|int");    }       else { -  if (s->type == T_FUNCTION) { +  if (TYPEOF(*s) == T_FUNCTION) {    struct svalue s2;    if (!(s2.u.program = program_from_function (s))) {    exit_mc_marker_hash();    free (mc_work_queue + 1);    mc_work_queue = NULL;    SIMPLE_ARG_TYPE_ERROR (    "count_memory", i + args + 1,    "array|multiset|mapping|object|program|string|type|int");    }    add_ref (s2.u.program); -  s2.type = T_PROGRAM; +  SET_SVAL_TYPE(s2, T_PROGRAM);    free_svalue (s);    move_svalue (s, &s2);    }       if (find_mc_marker (s->u.ptr)) {    /* The user passed the same thing several times. Ignore it. */    }       else {    struct mc_marker *m = -  my_make_mc_marker (s->u.ptr, visit_fn_from_type[s->type], NULL); +  my_make_mc_marker (s->u.ptr, visit_fn_from_type[TYPEOF(*s)], NULL);    m->flags |= MC_FLAG_INTERNAL; -  if (!mc_block_pike_cycle_depth && s->type == T_OBJECT) { +  if (!mc_block_pike_cycle_depth && TYPEOF(*s) == T_OBJECT) {    int cycle_depth = mc_cycle_depth_from_obj (s->u.object); -  if (throw_value.type != PIKE_T_FREE) { +  if (TYPEOF(throw_value) != PIKE_T_FREE) {    exit_mc_marker_hash();    free (mc_work_queue + 1);    mc_work_queue = NULL;    throw_severity = THROW_ERROR;    pike_throw();    }    m->la_count = cycle_depth >= 0 ? cycle_depth : mc_lookahead;    }    else    m->la_count = mc_lookahead;
pike.git/src/gc.c:5587:    MC_DEBUG_MSG (NULL, "leave");    }       mc_ref_from->flags |= MC_FLAG_INT_VISITED;       if (return_count || collect_stats || collect_internal) {    TYPE_T type = type_from_visit_fn (mc_ref_from->visit_fn);    if (type <= MAX_TYPE) {    count_internal++;    if (collect_internal) { -  Pike_sp->type = type; -  Pike_sp->subtype = 0; -  Pike_sp->u.ptr = mc_ref_from->thing; +  SET_SVAL(*Pike_sp, type, 0, ptr, mc_ref_from->thing);    add_ref ((struct ref_dummy *) mc_ref_from->thing);    dmalloc_touch_svalue (Pike_sp);    Pike_sp++;    AGGR_ARR_CHECK (collect_internal, 120);    }    }    }    }       else {
pike.git/src/gc.c:5633:    DL_ADD_LAST (mc_incomplete, mc_ref_from);    MC_DEBUG_MSG (NULL, "leave - added to incomplete list");    }    else {    DL_ADD_LAST (mc_complete, mc_ref_from);    MC_DEBUG_MSG (NULL, "leave - added to complete list");    }    }    }    -  if (throw_value.type != PIKE_T_FREE) { +  if (TYPEOF(throw_value) != PIKE_T_FREE) {    exit_mc_marker_hash();    free (mc_work_queue + 1);    mc_work_queue = NULL;    throw_severity = THROW_ERROR;    pike_throw();    }    }   #if defined (PIKE_DEBUG) || defined (MEMORY_COUNT_DEBUG)    mc_ref_from = (void *) (ptrdiff_t) -1;   #endif
pike.git/src/gc.c:5791:   #endif   #endif       if (collect_internal) {    struct pike_string *ind;    AGGR_ARR_EPILOGUE (collect_internal);    MAKE_CONST_STRING (ind, "collect_internals");    mapping_string_insert (Pike_sp[-args].u.mapping, ind, Pike_sp - 1);    }    -  if (Pike_sp[-args].type == T_MAPPING) { +  if (TYPEOF(Pike_sp[-args]) == T_MAPPING) {    struct mapping *opts = Pike_sp[-args].u.mapping;    struct pike_string *ind;    struct svalue *val;       MAKE_CONST_STRING (ind, "collect_stats");    if ((val = low_mapping_string_lookup (opts, ind)) &&    !UNSAFE_IS_ZERO (val)) {   #define INSERT_STAT(NAME, VALUE) do { \    struct pike_string *ind; \    push_ulongest (VALUE); \
pike.git/src/gc.c:5828:    !UNSAFE_IS_ZERO (val)) {    BEGIN_AGGREGATE_ARRAY (count_visited - count_internal) {    struct mc_marker *m, *list = &mc_incomplete;    while (1) {    /* Collect things from the mc_incomplete and mc_indirect lists. */    for (m = list->dl_next; m != list; m = m->dl_next) {    TYPE_T type = type_from_visit_fn (m->visit_fn);    assert (!(m->flags & MC_FLAG_INTERNAL));    assert (m->flags & MC_FLAG_LA_VISITED);    if (type <= MAX_TYPE) { -  Pike_sp->type = type; -  Pike_sp->subtype = 0; -  Pike_sp->u.ptr = m->thing; +  SET_SVAL(*Pike_sp, type, 0, ptr, m->thing);    add_ref ((struct ref_dummy *) m->thing);    dmalloc_touch_svalue (Pike_sp);    Pike_sp++;    DO_AGGREGATE_ARRAY (120);    }    }    if (list == &mc_incomplete) list = &mc_indirect;    else break;    }    } END_AGGREGATE_ARRAY;
pike.git/src/gc.c:5856:    if ((val = low_mapping_string_lookup (opts, ind)) &&    !UNSAFE_IS_ZERO (val)) {    BEGIN_AGGREGATE_ARRAY (count_visited - count_internal) {    /* Collect things from the mc_incomplete list. */    struct mc_marker *m;    for (m = mc_incomplete.dl_next; m != &mc_incomplete; m = m->dl_next) {    TYPE_T type = type_from_visit_fn (m->visit_fn);    assert (!(m->flags & MC_FLAG_INTERNAL));    assert (m->flags & MC_FLAG_LA_VISITED);    if (type <= MAX_TYPE) { -  Pike_sp->type = type; -  Pike_sp->subtype = 0; -  Pike_sp->u.ptr = m->thing; +  SET_SVAL(*Pike_sp, type, 0, ptr, m->thing);    add_ref ((struct ref_dummy *) m->thing);    dmalloc_touch_svalue (Pike_sp);    Pike_sp++;    DO_AGGREGATE_ARRAY (120);    }    }    } END_AGGREGATE_ARRAY;    args++;    mapping_string_insert (opts, ind, Pike_sp - 1);    }