Reduce padding and relocations (#355)

* Optimize the JEP106 list by using __attribute__((packed)) to remove padding. The x86 & x86_64 series support unaligned accesses just fine, after all, and this is not remotely a hot path.

* Optimize several string-related constructs by switching to fixed-length char arrays, which avoids pointers + relocations.

* app/interrupt.c: array of different-length strings, but most of those are lengthy enough for this to be a clear win, especially on x86_64;
* system/usbhcd.c: array of same-length strings;
* tests/tests.h: array of structs containing same-length strings.

* Reduce the size of the list of tests by using a narrower type for the cpu mode, which reduces padding.
This commit is contained in:
Lionel Debroux 2023-11-29 12:45:17 +01:00 committed by GitHub
parent 34eb8186fd
commit 9b9c65b968
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 6 deletions

View File

@ -56,7 +56,7 @@
#define ADR_DIGITS "8"
#endif
static const char *codes[] = {
static const char codes[][13] = {
"Divide by 0",
"Debug",
"NMI",

View File

@ -10,12 +10,12 @@
#define JEP106_CNT \
sizeof(jep106)/sizeof(jep106[0])
struct spd_jedec_manufacturer {
struct __attribute__((packed)) spd_jedec_manufacturer {
uint16_t jedec_code;
char *name;
};
static const struct spd_jedec_manufacturer jep106[] = {
static const struct __attribute__((packed)) spd_jedec_manufacturer jep106[] = {
{ 0x0001, "AMD" },
// { 0x0002, "AMI" },
// { 0x0003, "Fairchild" },

View File

@ -56,7 +56,7 @@ typedef struct {
// Private Variables
//------------------------------------------------------------------------------
static const char *hci_name[MAX_HCI_TYPE] = { "UHCI", "OHCI", "EHCI", "XHCI" };
static const char hci_name[MAX_HCI_TYPE][5] = { "UHCI", "OHCI", "EHCI", "XHCI" };
static const hcd_methods_t methods = {
.reset_root_hub_port = NULL,

View File

@ -18,11 +18,11 @@
typedef struct {
bool enabled;
cpu_mode_t cpu_mode;
uint8_t cpu_mode;
int stages;
int iterations;
int errors;
char *description;
char description[40];
} test_pattern_t;
extern test_pattern_t test_list[NUM_TEST_PATTERNS];