From 06e12e45459013f640f0e3448c47f87e343436a9 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Tue, 10 Dec 2024 13:19:21 +0000 Subject: [PATCH] asm: improve alignment of on-disk structures --- asm/include/ivy/asm/bin.h | 76 +++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/asm/include/ivy/asm/bin.h b/asm/include/ivy/asm/bin.h index 79f965b..ca5820b 100644 --- a/asm/include/ivy/asm/bin.h +++ b/asm/include/ivy/asm/bin.h @@ -3,53 +3,60 @@ #include -#define IVY_BIN_MAGIC 0x2E495659u +#define IVY_BIN_MAGIC 0x2E495659u -#define IVY_TABLE_IMPORT 0x58494D50u -#define IVY_TABLE_CLASS 0x58434C53u -#define IVY_TABLE_LAMBDA 0x4C424441u -#define IVY_TABLE_MSGH 0x4D534748u -#define IVY_TABLE_POOL 0x504F4F4Cu -#define IVY_TABLE_XDAT 0x53544142u +#define IVY_TABLE_IMPORT 0x58494D50u +#define IVY_TABLE_CLASS 0x58434C53u +#define IVY_TABLE_LAMBDA 0x4C424441u +#define IVY_TABLE_MSGH 0x4D534748u +#define IVY_TABLE_POOL 0x504F4F4Cu +#define IVY_TABLE_XDAT 0x53544142u -#define IVY_CLASS_TABLE_MVAR 0x4D564152u -#define IVY_CLASS_TABLE_PROP 0x50524F50u +#define IVY_CLASS_TABLE_MVAR 0x4D564152u +#define IVY_CLASS_TABLE_PROP 0x50524F50u -#define IVY_CONSTPOOL_TABLE_NULL 0x00000000u -#define IVY_CONSTPOOL_TABLE_STRING 0x58535452u -#define IVY_CONSTPOOL_TABLE_INT 0x53494E54u -#define IVY_CONSTPOOL_TABLE_UINT 0x55494E54u -#define IVY_CONSTPOOL_TABLE_ATOM 0x41544F4Du -#define IVY_CONSTPOOL_TABLE_SELECTOR 0x5853454Cu -#define IVY_CONSTPOOL_TABLE_IDENT 0x49444E54u +#define IVY_CONSTPOOL_TABLE_NULL 0x00000000u +#define IVY_CONSTPOOL_TABLE_STRING 0x58535452u +#define IVY_CONSTPOOL_TABLE_INT 0x53494E54u +#define IVY_CONSTPOOL_TABLE_UINT 0x55494E54u +#define IVY_CONSTPOOL_TABLE_ATOM 0x41544F4Du +#define IVY_CONSTPOOL_TABLE_SELECTOR 0x5853454Cu +#define IVY_CONSTPOOL_TABLE_IDENT 0x49444E54u -#define IVY_BIN_SELECTOR_OBJECT 0x00000001u -#define IVY_BIN_SELECTOR_CLASS 0x00000002u +#define IVY_BIN_SELECTOR_OBJECT 0x00000001u +#define IVY_BIN_SELECTOR_CLASS 0x00000002u + +#define IVY_BIN_NULL_HANDLE ((ivy_bin_data_handle)0) + +typedef uint32_t ivy_bin_data_handle; struct ivy_bin_header { uint32_t h_magic; uint16_t h_table_len; + uint8_t h_reserved[2]; uint64_t h_table_offset; }; struct ivy_bin_table_entry { uint32_t e_type; - uint64_t e_offset; uint32_t e_size; + uint64_t e_offset; }; struct ivy_bin_class_table_entry { uint32_t e_type; union { struct { - uint32_t p_ident; - uint32_t p_get; - uint32_t p_set; + ivy_bin_data_handle p_ident; + ivy_bin_data_handle p_get; + ivy_bin_data_handle p_set; + uint32_t p_reserved; } e_property; struct { uint32_t m_index; - uint32_t m_ident; + ivy_bin_data_handle m_ident; + uint8_t m_reserved[16]; } e_mvar; }; }; @@ -60,18 +67,19 @@ struct ivy_bin_class { }; struct ivy_bin_lambda { - uint32_t l_ident; + ivy_bin_data_handle l_ident; uint32_t l_instr[]; }; struct ivy_bin_msgh { - uint32_t msg_recipient; - uint32_t msg_selector; + ivy_bin_data_handle msg_recipient; + ivy_bin_data_handle msg_selector; uint32_t msg_instr[]; }; struct ivy_bin_constpool_header { uint32_t c_nr_table_entries; + uint8_t c_reserved[4]; uint64_t c_table_offset; }; @@ -84,28 +92,28 @@ struct ivy_bin_string { struct ivy_bin_selector { uint8_t sel_flags; uint8_t sel_nr_args; + uint8_t sel_reserved[2]; uint32_t sel_hash; - uint32_t sel_name; - uint32_t sel_args[]; + ivy_bin_data_handle sel_name; + ivy_bin_data_handle sel_args[]; }; struct ivy_bin_ident { uint32_t id_hash; uint8_t id_nr_parts; - uint32_t id_parts[]; + uint8_t id_reserved[3]; + ivy_bin_data_handle id_parts[]; }; struct ivy_bin_constpool_table_entry { uint32_t e_type; + uint32_t e_reserved; union { - uint32_t e_atom; - uint32_t e_string; - uint32_t e_ident; - uint32_t e_sel; + ivy_bin_data_handle e_handle; int64_t e_sint; uint64_t e_uint; }; }; -#endif \ No newline at end of file +#endif