summaryrefslogtreecommitdiff
path: root/shape.h
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-06-03 09:26:15 +0200
committerJean Boussier <[email protected]>2025-06-03 21:15:41 +0200
commite27404af9e2888bede6667e4bd0a145c4efa7c46 ()
treec97c020f9f3deb5be2f8cc21a82d942affba9b4a /shape.h
parentea8b53a53954c2f34b1093ae2547951ae0e1fe8c (diff)
Use all 32bits of `shape_id_t` on all platforms
Followup: https://.com/ruby/ruby/pull/13341 / [Feature #21353] Even thought `shape_id_t` has been make 32bits, we were still limited to use only the lower 16 bits because they had to fit alongside `attr_index_t` inside a `uintptr_t` in inline caches. By enlarging inline caches we can unlock the full 32bits on all platforms, allowing to use these extra bits for tagging.
Notes: Merged: https://.com/ruby/ruby/pull/13500
-rw-r--r--shape.h38
1 files changed, 17 insertions, 21 deletions
@@ -3,34 +3,22 @@
#include "internal/gc.h"
-#if (SIZEOF_UINT64_T <= SIZEOF_VALUE)
-
#define SIZEOF_SHAPE_T 4
-typedef uint32_t attr_index_t;
-typedef uint32_t shape_id_t;
-# define SHAPE_ID_NUM_BITS 32
-
-#else
-
-#define SIZEOF_SHAPE_T 2
typedef uint16_t attr_index_t;
-typedef uint16_t shape_id_t;
-# define SHAPE_ID_NUM_BITS 16
-
-#endif
typedef uint32_t redblack_id_t;
#define SHAPE_MAX_FIELDS (attr_index_t)(-1)
-# define SHAPE_FLAG_MASK (((VALUE)-1) >> SHAPE_ID_NUM_BITS)
-# define SHAPE_FLAG_SHIFT ((SIZEOF_VALUE * 8) - SHAPE_ID_NUM_BITS)
-# define SHAPE_MAX_VARIATIONS 8
-
-# define INVALID_SHAPE_ID (((uintptr_t)1 << SHAPE_ID_NUM_BITS) - 1)
-#define ATTR_INDEX_NOT_SET (attr_index_t)-1
#define ROOT_SHAPE_ID 0x0
#define SPECIAL_CONST_SHAPE_ID 0x1
@@ -44,13 +32,13 @@ typedef struct redblack_node redblack_node_t;
struct rb_shape {
VALUE edges; // id_table from ID (ivar) to next shape
ID edge_name; // ID (ivar) for transition from parent to rb_shape
attr_index_t next_field_index; // Fields are either ivars or internal properties like `object_id`
attr_index_t capacity; // Total capacity of the object with this shape
uint8_t type;
uint8_t heap_index;
uint8_t flags;
- shape_id_t parent_id;
- redblack_node_t *ancestor_index;
};
typedef struct rb_shape rb_shape_t;
@@ -82,6 +70,14 @@ typedef struct {
} rb_shape_tree_t;
RUBY_EXTERN rb_shape_tree_t *rb_shape_tree_ptr;
static inline rb_shape_tree_t *
rb_current_shape_tree(void)
{