This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] rearrange struct value to save memory
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tromey at redhat dot com>
- Date: Thu, 9 Jan 2014 12:03:02 -0700
- Subject: [PATCH] rearrange struct value to save memory
- Authentication-results: sourceware.org; auth=none
This patch rearranges struct value a tiny bit, moving the "regnum"
field into a hole. This saves 8 bytes per value on a 64-bit machine,
and 4 bytes per value on a 32 bit machine. I think it does not
negatively affect readability or performance.
Built and regtested on x86-64 Fedora 18.
Let me know what you think.
2014-01-09 Tom Tromey <tromey@redhat.com>
* value.c (struct value) <regnum>: Move earlier.
---
gdb/ChangeLog | 4 ++++
gdb/value.c | 6 +++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/gdb/value.c b/gdb/value.c
index 8542316..0e13b76 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -216,6 +216,9 @@ struct value
/* If the value has been released. */
unsigned int released : 1;
+ /* Register number if the value is from a register. */
+ short regnum;
+
/* Location of value (if lval). */
union
{
@@ -324,9 +327,6 @@ struct value
taken off this list. */
struct value *next;
- /* Register number if the value is from a register. */
- short regnum;
-
/* Actual contents of the value. Target byte-order. NULL or not
valid if lazy is nonzero. */
gdb_byte *contents;
--
1.8.1.4