From 4ea54f5a83c325a905b73ffb5af3f047edb14121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Sat, 29 May 2004 20:13:42 +0200 Subject: [PATCH] Removed the field "name" from struct program_constant since it was only used for debug (the real constant name is in the corresponding struct identifier). Replaced it with an offset to be used to locate the initialization function. Rev: src/encode.c:1.216 Rev: src/gc.c:1.255 Rev: src/las.c:1.346 Rev: src/program.c:1.564 Rev: src/program.h:1.205 --- src/encode.c | 38 +++++++++++++++++++++++++++++++++----- src/gc.c | 9 +++++++-- src/las.c | 7 ++++--- src/program.c | 28 +++++++++++++++++++++++----- src/program.h | 6 +++--- 5 files changed, 70 insertions(+), 18 deletions(-) diff --git a/src/encode.c b/src/encode.c index 09ec882daa..401d16ee13 100644 --- a/src/encode.c +++ b/src/encode.c @@ -2,7 +2,7 @@ || 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: encode.c,v 1.215 2004/05/19 09:19:13 grubba Exp $ +|| $Id: encode.c,v 1.216 2004/05/29 18:13:41 grubba Exp $ */ #include "global.h" @@ -31,7 +31,7 @@ #include "opcodes.h" #include "peep.h" -RCSID("$Id: encode.c,v 1.215 2004/05/19 09:19:13 grubba Exp $"); +RCSID("$Id: encode.c,v 1.216 2004/05/29 18:13:41 grubba Exp $"); /* #define ENCODE_DEBUG */ @@ -1136,7 +1136,7 @@ static void encode_value2(struct svalue *val, struct encode_data *data, int forc for(d=0;d<p->num_constants;d++) { encode_value2(& p->constants[d].sval, data, 0); - adddata3(p->constants[d].name); + adddata3(NULL /* p->constants[d].name */); } #else /* !OLD_PIKE_ENCODE_PROGRAM */ @@ -1262,15 +1262,19 @@ static void encode_value2(struct svalue *val, struct encode_data *data, int forc encode_value2(&p->constants[d].sval, data, 0); /* name */ +#if 0 if (p->constants[d].name) { str_sval.u.string = p->constants[d].name; encode_value2(&str_sval, data, 0); } else { +#endif /* 0 */ push_int(0); encode_value2(Pike_sp-1, data, 0); dmalloc_touch_svalue(Pike_sp-1); Pike_sp--; +#if 0 } +#endif /* 0 */ } } #endif /* PIKE_PORTABLE_BYTECODE */ @@ -1578,15 +1582,19 @@ static void encode_value2(struct svalue *val, struct encode_data *data, int forc encode_value2(&p->constants[d].sval, data, 0); /* name */ +#if 0 if (p->constants[d].name) { str_sval.u.string = p->constants[d].name; encode_value2(&str_sval, data, 0); } else { +#endif /* 0 */ push_int(0); encode_value2(Pike_sp-1, data, 0); dmalloc_touch_svalue(Pike_sp-1); Pike_sp--; +#if 0 } +#endif /* 0 */ } } #endif /* OLD_PIKE_ENCODE_PROGRAM */ @@ -3131,7 +3139,11 @@ static void decode_value2(struct decode_data *data) p->constants[d].sval=*--Pike_sp; } dmalloc_touch_svalue(Pike_sp); - getdata3(p->constants[d].name); + { + struct pike_string *dummy = NULL; + getdata3(dummy /*p->constants[d].name*/); + if (dummy) free_string(dummy); + } } #ifdef PIKE_DEBUG @@ -3561,10 +3573,10 @@ static void decode_value2(struct decode_data *data) */ { struct program_constant constant; - constant.name = NULL; constant.sval.type = T_INT; constant.sval.subtype = NUMBER_UNDEFINED; constant.sval.u.integer = 0; + constant.offset = -1; for(e=0;e<local_num_constants;e++) { add_to_constants(constant); @@ -3619,6 +3631,7 @@ static void decode_value2(struct decode_data *data) } /* name */ decode_value2(data); +#if 0 if (Pike_sp[-1].type == T_STRING) { constant->name = Pike_sp[-1].u.string; } else if ((Pike_sp[-1].type == T_INT) && @@ -3633,6 +3646,13 @@ static void decode_value2(struct decode_data *data) dmalloc_touch_svalue(Pike_sp-1); dmalloc_touch_svalue(Pike_sp-2); Pike_sp -= 2; +#else /* !0 */ + constant->offset = -1; + pop_stack(); + constant->sval = Pike_sp[-1]; + dmalloc_touch_svalue(Pike_sp-1); + Pike_sp -= 1; +#endif /* 0 */ decode_number(entry_type, data); } while (entry_type != ID_ENTRY_EOT) { @@ -4070,6 +4090,7 @@ static void decode_value2(struct decode_data *data) decode_value2(data); /* name */ decode_value2(data); +#if 0 if (Pike_sp[-1].type == T_STRING) { constant->name = Pike_sp[-1].u.string; } else if ((Pike_sp[-1].type == T_INT) && @@ -4084,6 +4105,13 @@ static void decode_value2(struct decode_data *data) dmalloc_touch_svalue(Pike_sp-1); dmalloc_touch_svalue(Pike_sp-2); Pike_sp -= 2; +#else /* !0 */ + constant->offset = -1; + pop_stack(); + constant->sval = Pike_sp[-1]; + dmalloc_touch_svalue(Pike_sp-1); + Pike_sp -= 1; +#endif /* 0 */ EDB(5, fprintf(stderr, "%*sDecoded constant %d to a %s\n", data->depth, "", diff --git a/src/gc.c b/src/gc.c index ee64a8ce08..1df59955ac 100644 --- a/src/gc.c +++ b/src/gc.c @@ -2,7 +2,7 @@ || 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: gc.c,v 1.254 2004/05/23 00:44:34 nilsson Exp $ +|| $Id: gc.c,v 1.255 2004/05/29 18:13:41 grubba Exp $ */ #include "global.h" @@ -33,7 +33,7 @@ struct callback *gc_evaluator_callback=0; #include "block_alloc.h" -RCSID("$Id: gc.c,v 1.254 2004/05/23 00:44:34 nilsson Exp $"); +RCSID("$Id: gc.c,v 1.255 2004/05/29 18:13:41 grubba Exp $"); int gc_enabled = 1; @@ -440,8 +440,13 @@ void describe_location(void *real_memblock, { e = ((char *)ptr - (char *)(p->constants)) / sizeof(struct program_constant); +#if 0 fprintf(stderr,"%*s **In p->constants[%"PRINTPTRDIFFT"d] (%s)\n",indent,"", e, p->constants[e].name ? p->constants[e].name->str : "no name"); +#else /* !0 */ + fprintf(stderr,"%*s **In p->constants[%"PRINTPTRDIFFT"d] (%d)\n",indent,"", + e, p->constants[e].offset); +#endif /* 0 */ break; } diff --git a/src/las.c b/src/las.c index 2357747db0..a2b22d835e 100644 --- a/src/las.c +++ b/src/las.c @@ -2,13 +2,12 @@ || 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: las.c,v 1.345 2004/03/16 13:42:30 grubba Exp $ +|| $Id: las.c,v 1.346 2004/05/29 18:13:41 grubba Exp $ */ #include "global.h" -RCSID("$Id: las.c,v 1.345 2004/03/16 13:42:30 grubba Exp $"); +RCSID("$Id: las.c,v 1.346 2004/05/29 18:13:41 grubba Exp $"); -#include "language.h" #include "interpret.h" #include "las.h" #include "array.h" @@ -5470,10 +5469,12 @@ ptrdiff_t eval_low(node *n,int print_error) p_const = prog->constants + prog->num_constants; free_svalue(&p_const->sval); +#if 0 if (p_const->name) { free_string(p_const->name); p_const->name = NULL; } +#endif /* 0 */ } #ifdef PIKE_USE_MACHINE_CODE diff --git a/src/program.c b/src/program.c index e5967e378a..0899901af6 100644 --- a/src/program.c +++ b/src/program.c @@ -2,18 +2,17 @@ || 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.563 2004/04/18 02:16:06 mast Exp $ +|| $Id: program.c,v 1.564 2004/05/29 18:13:41 grubba Exp $ */ #include "global.h" -RCSID("$Id: program.c,v 1.563 2004/04/18 02:16:06 mast Exp $"); +RCSID("$Id: program.c,v 1.564 2004/05/29 18:13:41 grubba 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" @@ -2380,7 +2379,9 @@ static void exit_program_struct(struct program *p) for(e=0;e<p->num_constants;e++) { free_svalue(& p->constants[e].sval); +#if 0 if(p->constants[e].name) free_string(p->constants[e].name); +#endif /* 0 */ } } @@ -2673,10 +2674,17 @@ void dump_program_tables (struct program *p, int indent) indent, "", indent, ""); for (d = 0; d < p->num_constants; d++) { struct program_constant *c = p->constants + d; +#if 0 fprintf(stderr, "%*s %4d: %-15s %s%s%s\n", indent, "", d, get_name_of_type (c->sval.type), c->name?"\"":"",c->name?c->name->str:"NULL",c->name?"\"":""); +#else /* !0 */ + fprintf(stderr, "%*s %4d: %-15s %d\n", + indent, "", + d, get_name_of_type (c->sval.type), + c->offset); +#endif /* 0 */ } fprintf(stderr, "\n" @@ -2756,7 +2764,14 @@ void check_program(struct program *p) if (p->flags & PROGRAM_FINISHED && s->type == T_OBJECT && s->u.object->next == s->u.object) Pike_fatal ("Got fake object in constant in finished program.\n"); +#if 0 if(p->constants[e].name) check_string(p->constants[e].name); +#else /* ! 0 */ + if (p->constants[e].offset >= p->num_identifiers) { + Pike_fatal("Constant initializer outside num_identifiers (%d >= %d).\n", + p->constants[e].offset, p->num_identifiers); + } +#endif /* 0 */ } for(e=0;e<p->num_strings;e++) @@ -5206,8 +5221,7 @@ int store_constant(struct svalue *foo, } else { struct program_constant *c= Pike_compiler->new_program->constants+e; - if(c->name == constant_name && - (equal ? is_equal(& c->sval,foo) : is_eq(& c->sval,foo))) + if((equal ? is_equal(& c->sval,foo) : is_eq(& c->sval,foo))) { UNSETJMP(jmp); return e; @@ -5216,7 +5230,11 @@ int store_constant(struct svalue *foo, UNSETJMP(jmp); } assign_svalue_no_free(&tmp.sval,foo); +#if 0 if((tmp.name=constant_name)) add_ref(constant_name); +#else /* !0 */ + tmp.offset = -1; +#endif /* 0 */ add_to_constants(tmp); diff --git a/src/program.h b/src/program.h index 7601b5402c..ed7eea850a 100644 --- a/src/program.h +++ b/src/program.h @@ -2,7 +2,7 @@ || 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.h,v 1.204 2004/05/23 00:45:11 nilsson Exp $ +|| $Id: program.h,v 1.205 2004/05/29 18:13:42 grubba Exp $ */ #ifndef PROGRAM_H @@ -246,8 +246,8 @@ struct identifier */ struct program_constant { - struct svalue sval; - struct pike_string *name; + struct svalue sval; /* Value. */ + ptrdiff_t offset; /* Offset in identifiers to initialization function. */ }; /* -- GitLab