Branch: Tag:

2003-11-19

2003-11-19 17:19:29 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Various assemble()-related cleanups:
Moved the global variable store_linenumbers to an argument of assemble().
assemble() and docode() now return the entrypoint of the generated code.
Support for ALIGN_PIKE_FUNCTION_BEGINNINGS has moved to assemble().
Some lowlevel opcode stuff has been moved from eval_low() to docode().
Moved call of ADD_COMPILED() from the individual files in code/ to assemble().
Added pseudo opcodes F_FILENAME and F_LINE for the benefit of PIKE_PORTABLE_BYTECODE.
assemble() now has some support for PIKE_PORTABLE_BYTECODE.

Rev: src/code/bytecode.c:1.7
Rev: src/code/computedgoto.c:1.4
Rev: src/code/ia32.c:1.36
Rev: src/code/ppc32.c:1.33
Rev: src/code/sparc.c:1.38
Rev: src/docode.c:1.173
Rev: src/docode.h:1.19
Rev: src/las.c:1.343
Rev: src/opcodes.c:1.161
Rev: src/opcodes.h:1.38
Rev: src/peep.c:1.93
Rev: src/peep.h:1.14

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: docode.c,v 1.172 2003/11/07 21:29:47 mast Exp $ + || $Id: docode.c,v 1.173 2003/11/19 17:19:29 grubba Exp $   */      #include "global.h" - RCSID("$Id: docode.c,v 1.172 2003/11/07 21:29:47 mast Exp $"); + RCSID("$Id: docode.c,v 1.173 2003/11/19 17:19:29 grubba Exp $");   #include "las.h"   #include "program.h"   #include "pike_types.h"
184:    return EXTRACT_INT(Pike_compiler->new_program->program+offset);   }    - int store_linenumbers=1; +    static int label_no=0;      int alloc_label(void) { return ++label_no; }
2261:    }   }    + /* Used to generate code for functions. */   INT32 do_code_block(node *n)   { -  INT32 ret; +  INT32 entry_point;   #ifdef PIKE_DEBUG    if (current_stack_depth != -4711) Pike_fatal("Reentrance in do_code_block().\n");    current_stack_depth = 0;
2272:    init_bytecode();    label_no=1;    - #ifdef ALIGN_PIKE_FUNCTION_BEGINNINGS -  while( ( (((INT32) PIKE_PC)+2) & (ALIGN_PIKE_JUMPS-1))) -  ins_byte(0); - #endif -  -  ret=PIKE_PC; +     /* NOTE: This is no ordinary label... */    low_insert_label(0);    emit1(F_BYTE,Pike_compiler->compiler_frame->max_number_of_locals);
2315:    emit0(F_START_FUNCTION);    DO_CODE_BLOCK(n);    } -  assemble(); +  entry_point = assemble(1);      #ifdef PIKE_DEBUG    current_stack_depth = -4711;   #endif -  return ret; +  return entry_point;   }    - int docode(node *n) + /* Used by eval_low() to build code for constant expressions. */ + INT32 docode(node *n)   { -  int tmp; +  INT32 entry_point;    int label_no_save = label_no;    dynamic_buffer instrbuf_save = instrbuf;    int stack_depth_save = current_stack_depth;
2339:    top_statement_label_dummy.cleanups = 0; /* please F_PUSH_ARRAY. */    init_bytecode();    -  tmp=do_docode(n,0); -  assemble(); +  insert_opcode0(F_ENTRY, n->line_number, n->current_file); +  /* FIXME: Should we check that do_docode() returns 1? */ +  do_docode(n,0); +  insert_opcode0(F_DUMB_RETURN, n->line_number, n->current_file); +  entry_point = assemble(0); /* Don't store linenumbers. */       instrbuf=instrbuf_save;    label_no = label_no_save;    current_stack_depth = stack_depth_save;    current_label = label_save;    top_statement_label_dummy.cleanups = top_cleanups_save; -  return tmp; +  return entry_point;   }