Branch: Tag:

2009-11-20

2009-11-20 10:58:09 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Avoid generating unnecessary parent pointers for inherits and types.
Fixes [bug 2672].

Rev: src/docode.c:1.206
Rev: src/las.c:1.442
Rev: src/program.c:1.772

2:   || 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.771 2009/09/12 13:31:37 grubba Exp $ + || $Id: program.c,v 1.772 2009/11/20 10:58:09 grubba Exp $   */      #include "global.h"
4383:    "compiler cannot handle.)");    }    +  +  if(p->flags & PROGRAM_NEEDS_PARENT) +  { +  struct program_state *state=Pike_compiler; +  +  if(!parent && !parent_offset) +  { +  yyerror("Parent pointer lost, cannot inherit!"); +  /* We've inherited it anyway, to avoid causing more errors */ +  } +  + #if 0 +  /* FIXME: we don't really need to set this flag on ALL +  * previous compilations, but I'm too lazy to figure out +  * exactly how deep down we need to go... +  */ +  for(e=0;e<c->compilation_depth;e++,state=state->previous) +  state->new_program->flags |= PROGRAM_USES_PARENT; + #endif +  } +     return;    }   
4404:    return;    }    -  if(p->flags & PROGRAM_NEEDS_PARENT) -  { -  struct program_state *state=Pike_compiler; -  -  if(!parent && !parent_offset) -  { -  yyerror("Parent pointer lost, cannot inherit!"); -  /* We inherit it anyway, to avoid causing more errors */ -  } -  - #if 0 -  /* FIXME: we don't really need to set this flag on ALL -  * previous compilations, but I'm too lazy to figure out -  * exactly how deep down we need to go... -  */ -  for(e=0;e<c->compilation_depth;e++,state=state->previous) -  state->new_program->flags |= PROGRAM_USES_PARENT; - #endif -  } -  +     /* parent offset was increased by 42 for above test.. */    if(parent_offset)    parent_offset-=42;
4675:    flags,    name);    } +  if (n->token == F_EXTERNAL) { +  struct program *p=program_from_svalue(s); +  if (p->flags & (PROGRAM_NEEDS_PARENT|PROGRAM_NEEDS_PARENT)) { +  /* We'll need the parent pointer as well... */ +  struct program_state *state = Pike_compiler; +  +  while (state && (state->new_program->id != n->u.integer.a)) { +  state->new_program->flags |= PROGRAM_NEEDS_PARENT|PROGRAM_USES_PARENT; +  state = state->previous; +  } +  } +  }    }else{    yyerror("Inherit identifier is not a constant program");    return;