This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATH] fix c/10962, slow lookup_field


Thanks Jason again for hint on how to combine the c and c++ codes.
Here is a patch where it moves most of it from cp/class.c to c-common.c.
Also it changes in the c++ front-end a usage of a tree to a struct which only has one field plus a variable size one, this will reduce memory usage how much I do not know because I did not test for it.
Counting only the sorting fields a struct with 100 fields would take 132 before now takes 116, there might be an off by one error in allocating but since it is over not under allocating I am not that worried because you are saving 16 bytes per struct/class already.


There still is some improvements that can happen, and more common code but this was my first stab at changing this over to be common code, one thing it being able to handle anonymous structs/unions in, that will bring over more common code.

The header guards on ggc.h were needed because of the pervious patch but since I have not tested without them and it is nice to have them, I am keep that part of this patch.

Since C90 is okay to use now, I just used that style for functions.

ChangeLog:
2003-05-30  Andrew Pinski  <pinskia@physics.uc.edu>

	* ggc.h: Add header guards.
	* c-decl.c (finish_struct): Sort fields if
	number greater than 15 and there are no
	anonymous structs/unions.
	* c-common.h: Include ggc.h.
	(lang_record_type): New struct.
	(field_decl_cmp): New prototype.
	(resort_sorted_fields): New prototype.
	(DECL_DECLARES_TYPE_NON_TEMPLATE_P): New macro.
	* c-tree.h: (lang_type): Use pointer to lang_record_type
	as s, removing other fields.
	* c-typeck.c (lookup_field): Use s in lang_type.
These were mostly moved from cp/class.c:
	* c-common.c (field_decl_cmp): New static function.
	(field_decl_cmp): New function.
	(resort_sorted_fields): New function.


cp/ChangeLog: 2003-05-30 Andrew Pinski <pinskia@physics.uc.edu>

	* class.c (field_decl_cmp): Remove.
	(resort_field_decl_cmp): Remove.
	(resort_sorted_fields): Remove.
	(add_fields_to_vec): Rename to ...
	(add_fields_to_record_type): this.
	(finish_struct_1): Change to be using
	lang_record_type's fields.
	* cp-tree.h (lang_decl): In lang_decl_u3
	change sorted_fields to be a pointer to
	lang_record_type.
	(resort_sorted_fields): Remove prototype.
	* search.c (lookup_field_1): Change to be using
	lang_record_type's fields.

Patch:

Attachment: fixPR10962.diff
Description: Binary data




Okay if bootstrap is fine and no regressions?


Thanks,
Andrew Pinski


On Thursday, May 29, 2003, at 22:57 US/Eastern, Jason Merrill wrote:


On Thu, 29 May 2003 20:14:59 -0400, Andrew Pinski <pinskia@physics.uc.edu> wrote:

I wish it could very easy but since in the c++, it depends on this macros
that only in C++ front-end:


/* Nonzero if NODE which declares a type.  */
#define DECL_DECLARES_TYPE_P(NODE) \
   (TREE_CODE (NODE) == TYPE_DECL || DECL_CLASS_TEMPLATE_P (NODE))

You should be able to replace the use of that macro with just the TYPE_DECL
check; you can't have a template with the same name as another field.


Jason



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]