+2003-02-25 Tim Josling <tej@melbpc.org.au>
+
+ * treetests.exp (run3): set options to force aggressive GC, to
+ ensure GC is all set up correct,
+
2002-05-07 Tim Josling <tej@melbpc.org.au>
* Makefile.in: Fix copyright
#
#set X "x"
set X ""
- run3 "${sourcedir}" "${testdir}" " -g -O3 " 01 01 0 3 0 1 0
+run3 "${sourcedir}" "${testdir}" " -g -O3 --param ggc-min-heapsize=0 --param ggc-min-expand=0 " 01 01 0 3 0 1 0
set X ""
}
+2003-02-24 Tim Josling <tej@melbpc.org.au>
+
+ * parse.y (my_yylex): New - ensure lexer time is charged to
+ TV_LEX.
+ (yylex): redefine as invocation of my_yylex which then calls
+ flex-generated yylex.
+ (timevar.h): include.
+
+2003-02-23 Tim Josling <tej@melbpc.org.au>
+
+ Fix garbage collection, add more error checking, force GC always.
+
+ * Make-lang.in (treelang/tree1.o): Depend on treelang/treetree.h
+ (treelang/treetree.o): Depend on treelang/parse.h
+
+ * lex.l: include "treetree.h"
+
+ * lex.l (update_yylval): Allocate string using get_string so GC
+ works.
+
+ * parse.y (function_prototype): Set category correctly so GC works.
+ (function): Set category in search so checking works.
+ (function_invocation): Ditto.
+ (variable_ref): Ditto.
+
+ * tree1.c (lookup_tree_name): Call sanity_check for passed
+ production and associated token and for symbol table entries.
+
+ * tree1.c (sanity_check): New, basic check that struct is valid.
+
+ * treelang.h: Prototype for sanity_check.
+
+2003-01-27 Tim Josling <tej@melbpc.org.au>
+
+ * treetree.c (treelang_init_decl_processing): Change memory
+ allocation to use GC.
+
2003-02-04 Joseph S. Myers <jsm@polyomino.org.uk>
* treelang.texi: Update to GFDL 1.2.
treelang/tree1.o: treelang/tree1.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
flags.h toplev.h $(GGC_H) $(TREE_H) diagnostic.h treelang/treelang.h \
+ treelang/treetree.h \
treelang/treetree.h gt-treelang-tree1.h gtype-treelang.h
treelang/treetree.o: treelang/treetree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(TREE_H) flags.h output.h $(C_TREE_H) $(RTL_H) $(GGC_H) toplev.h \
varray.h $(LANGHOOKS_DEF_H) langhooks.h treelang/treelang.h \
- treelang/treetree.h
+ treelang/treetree.h treelang/parse.h
treelang/parse.o: treelang/parse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) diagnostic.h treelang/treelang.h treelang/treetree.h
---------------------------------------------------------------------
- Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002
+ Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
/* Token defs. */
#include "treelang.h"
#include "parse.h"
+#include "treetree.h"
extern int option_lexer_trace;
tok->tp.tok.length = yyleng;
/* Have to copy yytext as it is just a ptr into the buffer at the
moment. */
- tok->tp.tok.chars = my_malloc (yyleng + 1);
- memcpy (tok->tp.tok.chars, yytext, yyleng);
+ tok->tp.tok.chars = (unsigned char*) get_string (yytext, yyleng);
}
/* Trace the value LEXRET and the position and token details being
---------------------------------------------------------------------
- Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
#include "coretypes.h"
#include "tm.h"
#include "diagnostic.h"
+#include "timevar.h"
#include "treelang.h"
#include "treetree.h"
#define YYPRINT(file, type, value) print_token (file, type, value)
#define YYERROR_VERBOSE YES
+/* My yylex routine used to intercept calls to flex generated code, to
+ record lex time. */
+int yylex (void);
+static inline int my_yylex(void);
+/* Call lex, but ensure time is charged to TV_LEX. */
+static inline int my_yylex ()
+{
+ int res;
+ timevar_push (TV_LEX);
+ res = yylex ();
+ timevar_pop (TV_LEX);
+ return res;
+}
+#define yylex my_yylex
extern int option_parser_trace;
/* Local prototypes. */
static void yyerror (const char *error_message);
-int yylex (void);
int yyparse (void);
void print_token (FILE * file, unsigned int type ATTRIBUTE_UNUSED, YYSTYPE value);
static struct prod_token_parm_item *reverse_prod_list (struct prod_token_parm_item *old_first);
if (!this_parm_var->tp.pro.main_token)
abort ();
this_parms->tp.par.variable_name = this_parm_var->tp.pro.main_token->tp.tok.chars;
+ this_parms->category = parameter_category;
this_parms->type = NUMERIC_TYPE (( (struct prod_token_parm_item*)EXPRESSION_TYPE (this_parm_var)));
if (last_parms)
{
struct prod_token_parm_item *this_parm;
tok = $1;
SYMBOL_TABLE_NAME ((&search_prod)) = tok;
+ search_prod.category = token_category;
current_function = proto = lookup_tree_name (&search_prod);
if (!proto)
{
SYMBOL_TABLE_NAME (prod) = tok;
PARAMETERS (prod) = reverse_prod_list ($3);
SYMBOL_TABLE_NAME ((&search_prod)) = tok;
+ search_prod.category = token_category;
proto = lookup_tree_name (&search_prod);
if (!proto)
{
tok = $1;
SYMBOL_TABLE_NAME ((&search_prod)) = tok;
+ search_prod.category = token_category;
symbol_table_entry = lookup_tree_name (&search_prod);
if (!symbol_table_entry)
{
TREELANG Compiler almost main (tree1)
Called by GCC's toplev.c
- Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
input_filename = "";
lineno = 0;
+ /* Init decls etc. */
+
treelang_init_decl_processing ();
/* This error will not happen from GCC as it will always create a
yyparse ();
}
-/* Allocate SIZE bytes and clear them. */
+/* Allocate SIZE bytes and clear them. Not to be used for strings
+ which must go in stringpool. */
void *
my_malloc (size_t size)
struct prod_token_parm_item *this;
struct prod_token_parm_item *this_tok;
struct prod_token_parm_item *tok;
+
+ sanity_check (prod);
+
tok = SYMBOL_TABLE_NAME (prod);
+ sanity_check (tok);
+
for (this = symbol_table; this; this = this->tp.pro.next)
{
+ sanity_check (this);
this_tok = this->tp.pro.main_token;
+ sanity_check (this_tok);
if (tok->tp.tok.length != this_tok->tp.tok.length)
continue;
if (memcmp (tok->tp.tok.chars, this_tok->tp.tok.chars, this_tok->tp.tok.length))
{
struct prod_token_parm_item *tok;
tok = SYMBOL_TABLE_NAME (prod);
+ sanity_check (prod);
if (lookup_tree_name (prod))
{
fprintf (stderr, "%s:%i:%i duplicate name %s\n", in_fname, tok->tp.tok.lineno,
return prod;
}
+/* Abort if ITEM is not a valid structure, based on 'category'. */
+
+void
+sanity_check (struct prod_token_parm_item *item)
+{
+ switch (item->category)
+ {
+ case token_category:
+ case production_category:
+ case parameter_category:
+ break;
+
+ default:
+ abort ();
+ }
+}
/* New garbage collection regime see gty.texi. */
#include "gt-treelang-tree1.h"
TREELANG Compiler common definitions (treelang.h)
- Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
void mark_token_used (struct prod_token_parm_item *tt);
void treelang_debug (void);
+void sanity_check (struct prod_token_parm_item *item);
If you want a working example of how to write a front end to GCC,
you are in the right place.
- Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000, 2001, 2002, 2003, Free Software Foundation, Inc.
This code is based on toy.c written by Richard Kenner.
#include "treelang.h"
#include "treetree.h"
+#include "parse.h"
extern int option_main;
extern char **file_names;
id = get_identifier ((const char*)chars);
for (parm = parms; parm; parm = parm->tp.par.next)
{
+ if (parm->category != parameter_category)
+ abort ();
type_node = get_type_for_numeric_type (parm->type);
type_list = tree_cons (NULL_TREE, type_node, type_list);
}
unsigned int i;
tree id;
- /* It is not necessary to register ridpointers as a GC root, because
- all the trees it points to are permanently interned in the
- get_identifier hash anyway. */
- ridpointers = (tree *) xcalloc ((int) RID_MAX, sizeof (tree));
+ ridpointers = (tree *) ggc_calloc ((int) RID_MAX, sizeof (tree));
for (i = 0; i < N_reswords; i++)
{
{
debug_tree (t);
}
+
+/* Get a stringpool entry for a string S of length L. This is needed
+ because the GTY routines don't mark strings, forcing you to put
+ them into stringpool, which is never freed. */
+
+const char*
+get_string (const char *s, size_t l)
+{
+ tree t;
+ t = get_identifier_with_length (s, l);
+ return IDENTIFIER_POINTER(t);
+}
TREELANG Compiler definitions for interfacing to treetree.c
(compiler back end interface).
- Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
tree tree_code_get_type (int type_num);
void treelang_init_decl_processing (void);
void treelang_finish (void);
-const char * treelang_init (const char* filename);
+const char *treelang_init (const char* filename);
int treelang_decode_option (int, char **);
void treelang_parse_file (int debug_flag);
void push_var_level (void);
void pop_var_level (void);
-
+const char* get_string (const char *s, size_t l);