pike.git / src / program.c

version» Context lines:

pike.git/src/program.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: program.c,v 1.496 2003/04/01 18:11:09 nilsson Exp $ + || $Id: program.c,v 1.497 2003/04/02 19:22:44 mast Exp $   */      #include "global.h" - RCSID("$Id: program.c,v 1.496 2003/04/01 18:11:09 nilsson Exp $"); + RCSID("$Id: program.c,v 1.497 2003/04/02 19:22:44 mast Exp $");   #include "program.h"   #include "object.h"   #include "dynamic_buffer.h"   #include "pike_types.h"   #include "stralloc.h"   #include "las.h"   #include "language.h"   #include "lex.h"   #include "pike_macros.h"   #include "fsort.h"
pike.git/src/program.c:921:   #define RELOCATE_linenumbers(ORIG,NEW)   #define RELOCATE_identifier_index(ORIG,NEW)   #define RELOCATE_variable_index(ORIG,NEW)   #define RELOCATE_identifier_references(ORIG,NEW)   #define RELOCATE_strings(ORIG,NEW)   #define RELOCATE_inherits(ORIG,NEW)   #define RELOCATE_identifiers(ORIG,NEW)   #define RELOCATE_constants(ORIG,NEW)   #define RELOCATE_relocations(ORIG,NEW)    - #define FOO(NUMTYPE,TYPE,NAME) \ + #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \   void PIKE_CONCAT(low_add_to_,NAME) (struct program_state *state, \    TYPE ARG) { \    if(state->malloc_size_program->PIKE_CONCAT(num_,NAME) == \    state->new_program->PIKE_CONCAT(num_,NAME)) { \    TYPE *tmp; \    state->malloc_size_program->PIKE_CONCAT(num_,NAME) *= 2; \    state->malloc_size_program->PIKE_CONCAT(num_,NAME)++; \    tmp = realloc((void *)state->new_program->NAME, \    sizeof(TYPE) * \    state->malloc_size_program-> \    PIKE_CONCAT(num_,NAME)); \    if(!tmp) Pike_fatal("Out of memory.\n"); \    PIKE_CONCAT(RELOCATE_,NAME)(state->new_program, tmp); \    state->new_program->NAME=tmp; \    } \    state->new_program-> \    NAME[state->new_program->PIKE_CONCAT(num_,NAME)++]=(ARG); \   } \ - void PIKE_CONCAT(add_to_,NAME) (TYPE ARG) { \ + void PIKE_CONCAT(add_to_,NAME) (ARGTYPE ARG) { \    CHECK_FOO(NUMTYPE,TYPE,NAME); \    PIKE_CONCAT(low_add_to_,NAME) ( Pike_compiler, ARG ); \   }         #include "program_areas.h"         #define add_to_program(ARG) do { \    debug_malloc_touch(Pike_compiler->new_program->program); \
pike.git/src/program.c:963:      void ins_int(INT32 i, void (*func)(char tmp))   {    int e;    unsigned char *p = (unsigned char *)&i;    for(e=0;e<(long)sizeof(i);e++) {    func(p[e]);    }   }    - void ins_short(INT16 i, void (*func)(char tmp)) + void ins_short(int i, void (*func)(char tmp))   {    int e;    unsigned char *p = (unsigned char *)&i;    for(e=0;e<(long)sizeof(i);e++) {    func(p[e]);    }   }      #ifdef PIKE_DEBUG   static void debug_add_to_identifiers (struct identifier id)
pike.git/src/program.c:1436:    * 3) localizes memory access (decreases paging)    */   void optimize_program(struct program *p)   {    size_t size=0;    char *data;       /* Already done (shouldn't happen, but who knows?) */    if(p->flags & PROGRAM_OPTIMIZED) return;    - #define FOO(NUMTYPE,TYPE,NAME) \ + #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \    size=DO_ALIGN(size, ALIGNOF(TYPE)); \    size+=p->PIKE_CONCAT(num_,NAME)*sizeof(p->NAME[0]);   #include "program_areas.h"       data=malloc(size);    if(!data)    {    make_program_executable(p);    return; /* We are out of memory, but we don't care! */    }       size=0;    - #define FOO(NUMTYPE,TYPE,NAME) \ + #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \    size=DO_ALIGN(size, ALIGNOF(TYPE)); \    MEMCPY(data+size,p->NAME,p->PIKE_CONCAT(num_,NAME)*sizeof(p->NAME[0])); \    PIKE_CONCAT(RELOCATE_,NAME)(p, (TYPE *)(data+size)); \    dmfree(p->NAME); \    p->NAME=(TYPE *)(data+size); \    size+=p->PIKE_CONCAT(num_,NAME)*sizeof(p->NAME[0]);   #include "program_areas.h"       p->total_size=size + sizeof(struct program);   
pike.git/src/program.c:1498: Inside #if defined(PIKE_DEBUG)
  struct pike_string *find_program_name(struct program *p, INT32 *line)   {    ptrdiff_t pos;    INT32 l;    if(!line) line=&l;      #ifdef DEBUG_MALLOC    {    char *tmp=dmalloc_find_name(p);    if (tmp) { -  char *p = strchr (tmp, ':'); +  char *p = STRCHR (tmp, ':');    if (p) {    char *pp; -  while ((pp = strchr (p + 1, ':'))) p = pp; +  while ((pp = STRCHR (p + 1, ':'))) p = pp;    *line = atoi (p + 1);    return make_shared_binary_string (tmp, p - tmp);    }    else {    *line=0;    return make_shared_string(tmp);    }    }    }   #endif
pike.git/src/program.c:1921:    }    }    }    }       debug_malloc_touch(Pike_compiler->fake_object);    debug_malloc_touch(Pike_compiler->fake_object->storage);       if(Pike_compiler->new_program->program)    { - #define FOO(NUMTYPE,TYPE,NAME) \ + #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \    Pike_compiler->malloc_size_program->PIKE_CONCAT(num_,NAME)=Pike_compiler->new_program->PIKE_CONCAT(num_,NAME);   #include "program_areas.h"          {    INT32 line=0, off=0;    size_t len = 0;    INT32 shift = 0;    char *file=0;    char *cnt=Pike_compiler->new_program->linenumbers;
pike.git/src/program.c:1964:    memcpy(str->str, file, len<<shift);    Pike_compiler->last_file = end_shared_string(str);    }    }       }else{    static struct pike_string *s;    struct inherit i;      #define START_SIZE 64 - #define FOO(NUMTYPE,TYPE,NAME) \ + #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \    if (Pike_compiler->new_program->NAME) { \    free (Pike_compiler->new_program->NAME); \    Pike_compiler->new_program->PIKE_CONCAT(num_,NAME) = 0; \    } \    Pike_compiler->malloc_size_program->PIKE_CONCAT(num_,NAME)=START_SIZE; \    Pike_compiler->new_program->NAME=(TYPE *)xalloc(sizeof(TYPE) * START_SIZE);   #include "program_areas.h"       i.prog=Pike_compiler->new_program;    i.identifier_level=0;
pike.git/src/program.c:2027:    debug_malloc_name(Pike_compiler->new_program, file, line);       free_string(lex.current_file);    lex.current_file = save_file;    lex.current_line = save_line;   }         static void exit_program_struct(struct program *p)   { -  unsigned INT16 e; +  unsigned e;      #ifdef PIKE_DEBUG    if (p->refs) {   #ifdef DEBUG_MALLOC    describe_something(p, T_PROGRAM, 0,2,0, NULL);   #endif    Pike_fatal("Program to be freed still got %d references.\n", p->refs);    }   #endif   
pike.git/src/program.c:2102:    {    if(p->program) {   #ifdef PIKE_USE_MACHINE_CODE   #ifdef VALGRIND_DISCARD_TRANSLATIONS    VALGRIND_DISCARD_TRANSLATIONS(p->program,    p->num_program*sizeof(p->program[0]));   #endif /* VALGRIND_DISCARD_TRANSLATIONS */   #endif /* PIKE_USE_MACHINE_CODE */    dmfree(p->program);    } - #define FOO(NUMTYPE,TYPE,NAME) p->NAME=0; + #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) p->NAME=0;   #include "program_areas.h"    }else{ - #define FOO(NUMTYPE,TYPE,NAME) \ + #define FOO(NUMTYPE,TYPE,ARGTYPE,NAME) \    if(p->NAME) { dmfree((char *)p->NAME); p->NAME=0; }   #include "program_areas.h"    }       EXIT_PIKE_MEMOBJ(p);       GC_FREE(p);   }      #ifdef PIKE_DEBUG
pike.git/src/program.c:4184:    INT32 ret;    struct svalue tmp;    tmp.type=T_OBJECT;    tmp.subtype=0;    tmp.u.object=o;    ret=simple_add_constant(name, &tmp, flags);    return ret;   }      PMOD_EXPORT int add_function_constant(const char *name, void (*cfun)(INT32), -  const char * type, INT16 flags) +  const char * type, int flags)   {    struct svalue s;    INT32 ret;       s.type=T_FUNCTION;    s.subtype=FUNCTION_BUILTIN;    s.u.efun=make_callable(cfun, name, type, flags, 0, 0);    ret=simple_add_constant(name, &s, 0);    free_svalue(&s);    return ret;
pike.git/src/program.c:4223:    free_svalue(&tmp);    return ret;   }      /*    * define a new function    * if func isn't given, it is supposed to be a prototype.    */   INT32 define_function(struct pike_string *name,    struct pike_type *type, -  unsigned INT16 flags, -  unsigned INT8 function_flags, +  unsigned flags, +  unsigned function_flags,    union idptr *func, -  unsigned INT16 opt_flags) +  unsigned opt_flags)   {    struct identifier *funp,fun;    struct reference ref;    struct svalue *lfun_type;    INT32 i;      #ifdef PROGRAM_BUILD_DEBUG    {    struct pike_string *d = describe_type (type);    fprintf (stderr, "%.*sdefining function (pass=%d): %s ",
pike.git/src/program.c:6202: Inside #if defined(PIKE_DEBUG)
   if (a_flag > 2) {    dump_program_tables(ret, 0);    }   #endif /* PIKE_DEBUG */    verify_supporters();    return ret;    }   }      PMOD_EXPORT int pike_add_function2(const char *name, void (*cfun)(INT32), -  const char *type, unsigned INT8 flags, -  unsigned INT16 opt_flags) +  const char *type, unsigned flags, +  unsigned opt_flags)   {    int ret;    struct pike_string *name_tmp;    struct pike_type *type_tmp;    union idptr tmp;       name_tmp=make_shared_string(name);    type_tmp=parse_type(type);       if(cfun)
pike.git/src/program.c:6240:    free_string(name_tmp);    free_type(type_tmp);    return ret;   }      PMOD_EXPORT int quick_add_function(const char *name,    int name_length,    void (*cfun)(INT32),    const char *type,    int type_length, -  unsigned INT8 flags, -  unsigned INT16 opt_flags) +  unsigned flags, +  unsigned opt_flags)   {    int ret;    struct pike_string *name_tmp;    struct pike_type *type_tmp;    union idptr tmp;   /* fprintf(stderr,"ADD_FUNC: %s\n",name); */    name_tmp = make_shared_binary_string(name, name_length);    type_tmp = make_pike_type(type);       if(cfun)