Move rvalue_overhead out of RVALUE
Since we cannot read the rvalue_overhead out of the RVALUE anyways (since it is at the end of the slot), it makes more sense to move it out of the RVALUE.
This commit is contained in:
parent
e34c131ce8
commit
6d605f1e50
31
gc.c
31
gc.c
@ -689,11 +689,11 @@ typedef struct RVALUE {
|
|||||||
VALUE v3;
|
VALUE v3;
|
||||||
} values;
|
} values;
|
||||||
} as;
|
} as;
|
||||||
|
} RVALUE;
|
||||||
|
|
||||||
/* Start of RVALUE_OVERHEAD.
|
/* These members ae located at the end of the slot that the object is in. */
|
||||||
* Do not directly read these members from the RVALUE as they're located
|
#if RACTOR_CHECK_MODE || GC_DEBUG
|
||||||
* at the end of the slot (which may differ in size depending on the size
|
struct rvalue_overhead {
|
||||||
* pool). */
|
|
||||||
# if RACTOR_CHECK_MODE
|
# if RACTOR_CHECK_MODE
|
||||||
uint32_t _ractor_belonging_id;
|
uint32_t _ractor_belonging_id;
|
||||||
# endif
|
# endif
|
||||||
@ -701,17 +701,20 @@ typedef struct RVALUE {
|
|||||||
const char *file;
|
const char *file;
|
||||||
int line;
|
int line;
|
||||||
# endif
|
# endif
|
||||||
} RVALUE;
|
};
|
||||||
|
|
||||||
#if RACTOR_CHECK_MODE
|
// Make sure that RVALUE_OVERHEAD aligns to sizeof(VALUE)
|
||||||
# define RVALUE_OVERHEAD (sizeof(RVALUE) - offsetof(RVALUE, _ractor_belonging_id))
|
# define RVALUE_OVERHEAD (sizeof(struct { \
|
||||||
#elif GC_DEBUG
|
union { \
|
||||||
# define RVALUE_OVERHEAD (sizeof(RVALUE) - offsetof(RVALUE, file))
|
struct rvalue_overhead overhead; \
|
||||||
|
VALUE value; \
|
||||||
|
}; \
|
||||||
|
}))
|
||||||
#else
|
#else
|
||||||
# define RVALUE_OVERHEAD 0
|
# define RVALUE_OVERHEAD 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC_ASSERT(sizeof_rvalue, sizeof(RVALUE) == (SIZEOF_VALUE * 5) + RVALUE_OVERHEAD);
|
STATIC_ASSERT(sizeof_rvalue, sizeof(RVALUE) == (SIZEOF_VALUE * 5));
|
||||||
STATIC_ASSERT(alignof_rvalue, RUBY_ALIGNOF(RVALUE) == SIZEOF_VALUE);
|
STATIC_ASSERT(alignof_rvalue, RUBY_ALIGNOF(RVALUE) == SIZEOF_VALUE);
|
||||||
|
|
||||||
typedef uintptr_t bits_t;
|
typedef uintptr_t bits_t;
|
||||||
@ -955,7 +958,7 @@ typedef struct rb_objspace {
|
|||||||
#define HEAP_PAGE_ALIGN_LOG 16
|
#define HEAP_PAGE_ALIGN_LOG 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BASE_SLOT_SIZE sizeof(RVALUE)
|
#define BASE_SLOT_SIZE (sizeof(RVALUE) + RVALUE_OVERHEAD)
|
||||||
|
|
||||||
#define CEILDIV(i, mod) roomof(i, mod)
|
#define CEILDIV(i, mod) roomof(i, mod)
|
||||||
enum {
|
enum {
|
||||||
@ -3476,7 +3479,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define OBJ_ID_INCREMENT (sizeof(RVALUE))
|
#define OBJ_ID_INCREMENT (BASE_SLOT_SIZE)
|
||||||
#define OBJ_ID_INITIAL (OBJ_ID_INCREMENT)
|
#define OBJ_ID_INITIAL (OBJ_ID_INCREMENT)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -8194,7 +8197,7 @@ gc_compact_plane(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
VALUE vp = (VALUE)p;
|
VALUE vp = (VALUE)p;
|
||||||
GC_ASSERT(vp % sizeof(RVALUE) == 0);
|
GC_ASSERT(vp % BASE_SLOT_SIZE == 0);
|
||||||
|
|
||||||
if (bitset & 1) {
|
if (bitset & 1) {
|
||||||
objspace->rcompactor.considered_count_table[BUILTIN_TYPE(vp)]++;
|
objspace->rcompactor.considered_count_table[BUILTIN_TYPE(vp)]++;
|
||||||
@ -13652,7 +13655,7 @@ Init_GC(void)
|
|||||||
rb_hash_aset(gc_constants, ID2SYM(rb_intern("DEBUG")), RBOOL(GC_DEBUG));
|
rb_hash_aset(gc_constants, ID2SYM(rb_intern("DEBUG")), RBOOL(GC_DEBUG));
|
||||||
rb_hash_aset(gc_constants, ID2SYM(rb_intern("BASE_SLOT_SIZE")), SIZET2NUM(BASE_SLOT_SIZE - RVALUE_OVERHEAD));
|
rb_hash_aset(gc_constants, ID2SYM(rb_intern("BASE_SLOT_SIZE")), SIZET2NUM(BASE_SLOT_SIZE - RVALUE_OVERHEAD));
|
||||||
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OVERHEAD")), SIZET2NUM(RVALUE_OVERHEAD));
|
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OVERHEAD")), SIZET2NUM(RVALUE_OVERHEAD));
|
||||||
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_SIZE")), SIZET2NUM(sizeof(RVALUE)));
|
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_SIZE")), SIZET2NUM(BASE_SLOT_SIZE));
|
||||||
rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_OBJ_LIMIT")), SIZET2NUM(HEAP_PAGE_OBJ_LIMIT));
|
rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_OBJ_LIMIT")), SIZET2NUM(HEAP_PAGE_OBJ_LIMIT));
|
||||||
rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_BITMAP_SIZE")), SIZET2NUM(HEAP_PAGE_BITMAP_SIZE));
|
rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_BITMAP_SIZE")), SIZET2NUM(HEAP_PAGE_BITMAP_SIZE));
|
||||||
rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_SIZE")), SIZET2NUM(HEAP_PAGE_SIZE));
|
rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_SIZE")), SIZET2NUM(HEAP_PAGE_SIZE));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user