[前][次][番号順一覧][スレッド一覧]

ruby-changes:65093

From: Nobuyoshi <ko1@a...>
Date: Sun, 31 Jan 2021 14:26:51 +0900 (JST)
Subject: [ruby-changes:65093] ae0a179c4b (master): Narrowed down the condition to pack RValue

https://git.ruby-lang.org/ruby.git/commit/?id=ae0a179c4b

From ae0a179c4bb13c64584bc07b29372723d1d6c4fa Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 31 Jan 2021 12:50:29 +0900
Subject: Narrowed down the condition to pack RValue

Because of `double` in `RFloat`, `RValue` would be packed by
`sizeof(double)` by default, on platforms where `double` is wider
than `VALUE`.  Size of `RValue` is multiple of 5 now.
---
 gc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gc.c b/gc.c
index c407293..fa294b1 100644
--- a/gc.c
+++ b/gc.c
@@ -552,8 +552,8 @@ struct RMoved { https://github.com/ruby/ruby/blob/trunk/gc.c#L552
 
 #define RMOVED(obj) ((struct RMoved *)(obj))
 
-#if defined(_MSC_VER) || defined(__CYGWIN__)
-#pragma pack(push, 1) /* magic for reducing sizeof(RVALUE): 24 -> 20 */
+#if (SIZEOF_DOUBLE > SIZEOF_VALUE) && (defined(_MSC_VER) || defined(__CYGWIN__))
+#pragma pack(push, 4) /* == SIZEOF_VALUE: magic for reducing sizeof(RVALUE): 24 -> 20 */
 #endif
 
 typedef struct RVALUE {
@@ -604,10 +604,12 @@ typedef struct RVALUE { https://github.com/ruby/ruby/blob/trunk/gc.c#L604
 #endif
 } RVALUE;
 
-#if defined(_MSC_VER) || defined(__CYGWIN__)
+#if (SIZEOF_DOUBLE > SIZEOF_VALUE) && (defined(_MSC_VER) || defined(__CYGWIN__))
 #pragma pack(pop)
 #endif
 
+STATIC_ASSERT(sizeof_rvalue, sizeof(RVALUE) == 5*SIZEOF_VALUE);
+
 typedef uintptr_t bits_t;
 enum {
     BITS_SIZE = sizeof(bits_t),
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]