From 6ba826b28c3a2eb252036fd1c2052e6b50b3c201 Mon Sep 17 00:00:00 2001 From: Dipin Hora Date: Wed, 9 Oct 2024 11:40:12 -0400 Subject: [PATCH 1/2] Make actor pad automagically calculated Prior to this commit, we had to manually update the actor pad size if the size of pony_actor_t changed. This commit makes it so that the actor pad size is now automagically calculated by the compiler so it doesn't have to be manually maintained any longer. --- src/libponyrt/actor/actor.h | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/libponyrt/actor/actor.h b/src/libponyrt/actor/actor.h index 4777ec671b..1572d12953 100644 --- a/src/libponyrt/actor/actor.h +++ b/src/libponyrt/actor/actor.h @@ -72,27 +72,10 @@ typedef struct pony_actor_t /** Padding for actor types. * - * 56 bytes: initial header, not including the type descriptor - * 52/104 bytes: heap - * 4/8 bytes: muted counter - * 4/8 bytes: internal flags (after alignment) - * 64/128 bytes: actorstats (if enabled) - * 48/88 bytes: gc - * 24/56 bytes: padding to 64 bytes, ignored + * Size of pony_actor_t minus the padding at the end and the pony_type_t* at the beginning. + * */ -#if INTPTR_MAX == INT64_MAX -#ifdef USE_RUNTIMESTATS -# define PONY_ACTOR_PAD_SIZE 392 -#else -# define PONY_ACTOR_PAD_SIZE 264 -#endif -#elif INTPTR_MAX == INT32_MAX -#ifdef USE_RUNTIMESTATS -# define PONY_ACTOR_PAD_SIZE 232 -#else -# define PONY_ACTOR_PAD_SIZE 168 -#endif -#endif +#define PONY_ACTOR_PAD_SIZE (offsetof(pony_actor_t, gc) + sizeof(gc_t) - sizeof(pony_type_t*)) typedef struct pony_actor_pad_t { From aba3f4befcb726ec3e12cfcc29a856752d0b8bcb Mon Sep 17 00:00:00 2001 From: Dipin Hora Date: Tue, 15 Oct 2024 15:39:15 -0400 Subject: [PATCH 2/2] Add warning comment --- src/libponyrt/actor/actor.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libponyrt/actor/actor.h b/src/libponyrt/actor/actor.h index 1572d12953..f2cf3a2c8b 100644 --- a/src/libponyrt/actor/actor.h +++ b/src/libponyrt/actor/actor.h @@ -68,6 +68,9 @@ typedef struct pony_actor_t actorstats_t actorstats; // 64/128 bytes #endif gc_t gc; // 48/88 bytes + // if you add more members here, you need to update the PONY_ACTOR_PAD_SIZE + // calculation below and the pony_static_assert at the top of actor.c, to + // reference the final member, its offset, and size } pony_actor_t; /** Padding for actor types.