From 9ea4267d62830b0b41e3282964d6cb0872355f6b Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 26 Dec 2013 22:06:27 -0700 Subject: [PATCH] better packing for command struct This moves all the bitfields in struct cmd_list_element to be closer together. This packs the structure somewhat better. On a 64 bit machine, this simple rearrangement saves around 50k at startup. 2014-01-20 Tom Tromey * cli/cli-decode.h (struct cmd_list_element): Move all bitfields together. --- gdb/ChangeLog | 5 +++ gdb/cli/cli-decode.h | 96 ++++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 48 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ddbc5ba582..8093be3a24 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-01-20 Tom Tromey + + * cli/cli-decode.h (struct cmd_list_element): Move all bitfields + together. + 2014-01-20 Tom Tromey * cli/cli-decode.c (add_cmd, deprecate_cmd, add_alias_cmd) diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index 10ff36d83d..c6edc87198 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -55,6 +55,54 @@ struct cmd_list_element /* Command class; class values are chosen by application program. */ enum command_class class; + /* When 1 indicated that this command is deprecated. It may be + removed from gdb's command set in the future. */ + + unsigned int cmd_deprecated : 1; + + /* The user needs to be warned that this is a deprecated command. + The user should only be warned the first time a command is + used. */ + + unsigned int deprecated_warn_user : 1; + + /* When functions are deprecated at compile time (this is the way + it should, in general, be done) the memory containing the + replacement string is statically allocated. In some cases it + makes sense to deprecate commands at runtime (the testsuite is + one example). In this case the memory for replacement is + malloc'ed. When a command is undeprecated or re-deprecated at + runtime we don't want to risk calling free on statically + allocated memory, so we check this flag. */ + + unsigned int malloced_replacement : 1; + + /* Set if the doc field should be xfree'd. */ + + unsigned int doc_allocated : 1; + + /* Flag that specifies if this command is already running its hook. */ + /* Prevents the possibility of hook recursion. */ + unsigned int hook_in : 1; + + /* For prefix commands only: + nonzero means do not get an error if subcommand is not + recognized; call the prefix's own function in that case. */ + unsigned int allow_unknown : 1; + + /* Nonzero says this is an abbreviation, and should not + be mentioned in lists of commands. + This allows "br" to complete to "break", which it + otherwise wouldn't. */ + unsigned int abbrev_flag : 1; + + /* Type of "set" or "show" command (or SET_NOT_SET if not "set" + or "show"). */ + ENUM_BITFIELD (cmd_types) type : 2; + + /* What kind of variable is *VAR? */ + ENUM_BITFIELD (var_types) var_type : 4; + /* Function definition of this command. NULL for command class names and for help topics that are not really commands. NOTE: cagney/2002-02-02: This function signature is evolving. For @@ -86,32 +134,6 @@ struct cmd_list_element specified stream. */ show_value_ftype *show_value_func; - /* When 1 indicated that this command is deprecated. It may be - removed from gdb's command set in the future. */ - - unsigned int cmd_deprecated : 1; - - /* The user needs to be warned that this is a deprecated command. - The user should only be warned the first time a command is - used. */ - - unsigned int deprecated_warn_user : 1; - - /* When functions are deprecated at compile time (this is the way - it should, in general, be done) the memory containing the - replacement string is statically allocated. In some cases it - makes sense to deprecate commands at runtime (the testsuite is - one example). In this case the memory for replacement is - malloc'ed. When a command is undeprecated or re-deprecated at - runtime we don't want to risk calling free on statically - allocated memory, so we check this flag. */ - - unsigned int malloced_replacement : 1; - - /* Set if the doc field should be xfree'd. */ - - unsigned int doc_allocated : 1; - /* If this command is deprecated, this is the replacement name. */ char *replacement; @@ -122,10 +144,6 @@ struct cmd_list_element /* Hook for another command to be executed before this command. */ struct cmd_list_element *hook_pre; - /* Flag that specifies if this command is already running its hook. */ - /* Prevents the possibility of hook recursion. */ - unsigned int hook_in : 1; - /* Hook for another command to be executed after this command. */ struct cmd_list_element *hook_post; @@ -140,20 +158,9 @@ struct cmd_list_element commands reached through this prefix. */ char *prefixname; - /* For prefix commands only: - nonzero means do not get an error if subcommand is not - recognized; call the prefix's own function in that case. */ - unsigned int allow_unknown : 1; - /* The prefix command of this command. */ struct cmd_list_element *prefix; - /* Nonzero says this is an abbreviation, and should not - be mentioned in lists of commands. - This allows "br" to complete to "break", which it - otherwise wouldn't. */ - unsigned int abbrev_flag : 1; - /* Completion routine for this command. TEXT is the text beyond what was matched for the command itself (leading whitespace is skipped). It stops where we are supposed to stop completing @@ -174,17 +181,10 @@ struct cmd_list_element used to finalize the CONTEXT field, if needed. */ void (*destroyer) (struct cmd_list_element *self, void *context); - /* Type of "set" or "show" command (or SET_NOT_SET if not "set" - or "show"). */ - ENUM_BITFIELD (cmd_types) type : 2; - /* Pointer to variable affected by "set" and "show". Doesn't matter if type is not_set. */ void *var; - /* What kind of variable is *VAR? */ - ENUM_BITFIELD (var_types) var_type : 4; - /* Pointer to NULL terminated list of enumerated values (like argv). */ const char *const *enums; -- 2.34.1