diff options
author | Peter Zhu <[email protected]> | 2022-01-14 13:59:38 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2022-01-14 14:36:33 -0500 |
commit | 6b7eff90860d4fb4db01ec4d1f522afa6d809632 (patch) | |
tree | c545242eaf1dfeb27a1ec59d0cb181429584af88 /internal/class.h | |
parent | ca3d405242c722c8140944bda7278c2a9e5a7139 (diff) |
Separately allocate class_serial on 32-bit systems
On 32-bit systems, VWA causes class_serial to not be aligned (it only
guarantees 4 byte alignment but class_serial is 8 bytes and requires 8
byte alignment). This commit uses a hack to allocate class_serial
through malloc. Once VWA allocates with 8 byte alignment in the future,
we will revert this commit.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5442
Diffstat (limited to 'internal/class.h')
-rw-r--r-- | internal/class.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/class.h b/internal/class.h index 9edc821701..8942f80c9b 100644 --- a/internal/class.h +++ b/internal/class.h @@ -55,7 +55,7 @@ struct rb_classext_struct { * included. Hopefully that makes sense. */ struct rb_subclass_entry *module_subclass_entry; -#if SIZEOF_SERIAL_T != SIZEOF_VALUE /* otherwise class_serial is in struct RClass */ +#if SIZEOF_SERIAL_T != SIZEOF_VALUE && !USE_RVARGC /* otherwise class_serial is in struct RClass */ rb_serial_t class_serial; #endif const VALUE origin_; @@ -76,6 +76,9 @@ struct RClass { #else /* Class serial does not fit into struct RClass. Place m_tbl instead. */ struct rb_id_table *m_tbl; +# if USE_RVARGC + rb_serial_t *class_serial_ptr; +# endif #endif }; @@ -103,7 +106,11 @@ typedef struct rb_classext_struct rb_classext_t; #if SIZEOF_SERIAL_T == SIZEOF_VALUE # define RCLASS_SERIAL(c) (RCLASS(c)->class_serial) #else -# define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial) +# if USE_RVARGC +# define RCLASS_SERIAL(c) (*RCLASS(c)->class_serial_ptr) +# else +# define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial) +# endif #endif #define RCLASS_INCLUDER(c) (RCLASS_EXT(c)->includer) #define RCLASS_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->subclass_entry) |