Branch: Tag:

2014-04-20

2014-04-20 15:15:25 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler: __INIT() has side effects...

Make sure that __INIT gets marked as having side effects,
or calls to it may get optimized away...

Also renames an internal variable.

3922:    struct compilation *c = THIS_COMPILATION;    int e;    struct program *prog = Pike_compiler->new_program; -  struct pike_string *s; +  struct pike_string *init_name;    int num_refs = prog->num_identifier_references;    union idptr dispatch_fun;   
3991:    debug_malloc_touch(Pike_compiler->fake_object);    debug_malloc_touch(Pike_compiler->fake_object->storage);    -  MAKE_CONST_STRING(s,"__INIT"); +  init_name = lfun_strings[LFUN___INIT];    -  +     /* Collect references to inherited __INIT functions */    if (!(Pike_compiler->new_program->flags & PROGRAM_AVOID_CHECK)) {    for(e=Pike_compiler->new_program->num_inherits-1;e;e--)
4019:    /* Make sure that the __INIT symbol exists, so that    * we won't get a fatal when we add the actual code    * further down when we have entered pass 2. +  * +  * Also make sure that it is marked as having side effects, +  * or it will be optimized away when inherited...    */ -  define_function(s, function_type_string, ID_PROTECTED, -  IDENTIFIER_PIKE_FUNCTION, NULL, 0); +  define_function(init_name, function_type_string, ID_PROTECTED, +  IDENTIFIER_PIKE_FUNCTION, NULL, +  OPT_SIDE_EFFECT|OPT_EXTERNAL_DEPEND);    }    }    Pike_compiler->compiler_pass = 2;
4034:       if(Pike_compiler->init_node)    { +  /* Inhibit this_function. */    Pike_compiler->compiler_frame->current_function_number = -2; -  e=dooptcode(s, +  +  e=dooptcode(init_name,    mknode(F_COMMA_EXPR,    Pike_compiler->init_node,    mknode(F_RETURN,mkintnode(0),0)),