mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 04:55:21 +02:00
Move object_id
in object fields.
And get rid of the `obj_to_id_tbl` It's no longer needed, the `object_id` is now stored inline in the object alongside instance variables. We still need the inverse table in case `_id2ref` is invoked, but we lazily build it by walking the heap if that happens. The `object_id` concern is also no longer a GC implementation concern, but a generic implementation. Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
This commit is contained in:
parent
d34c150547
commit
f48e45d1e9
Notes:
git
2025-05-08 05:58:19 +00:00
23 changed files with 1140 additions and 560 deletions
20
shape.h
20
shape.h
|
@ -33,11 +33,13 @@ typedef uint32_t redblack_id_t;
|
|||
# define SHAPE_MAX_VARIATIONS 8
|
||||
|
||||
# define INVALID_SHAPE_ID SHAPE_MASK
|
||||
# define ROOT_SHAPE_ID 0x0
|
||||
|
||||
# define SPECIAL_CONST_SHAPE_ID (ROOT_SHAPE_ID + 1)
|
||||
# define OBJ_TOO_COMPLEX_SHAPE_ID (SPECIAL_CONST_SHAPE_ID + 1)
|
||||
# define FIRST_T_OBJECT_SHAPE_ID (OBJ_TOO_COMPLEX_SHAPE_ID + 1)
|
||||
#define ROOT_SHAPE_ID 0x0
|
||||
#define SPECIAL_CONST_SHAPE_ID 0x1
|
||||
// ROOT_TOO_COMPLEX_SHAPE_ID 0x2
|
||||
#define FIRST_T_OBJECT_SHAPE_ID 0x3
|
||||
|
||||
extern ID ruby_internal_object_id;
|
||||
|
||||
typedef struct redblack_node redblack_node_t;
|
||||
|
||||
|
@ -65,6 +67,7 @@ struct redblack_node {
|
|||
enum shape_type {
|
||||
SHAPE_ROOT,
|
||||
SHAPE_IVAR,
|
||||
SHAPE_OBJ_ID,
|
||||
SHAPE_FROZEN,
|
||||
SHAPE_T_OBJECT,
|
||||
SHAPE_OBJ_TOO_COMPLEX,
|
||||
|
@ -169,6 +172,9 @@ rb_shape_t *rb_shape_transition_shape_too_complex(VALUE obj);
|
|||
bool rb_shape_transition_shape_remove_ivar(VALUE obj, ID id, rb_shape_t *shape, VALUE *removed);
|
||||
rb_shape_t *rb_shape_get_next(rb_shape_t *shape, VALUE obj, ID id);
|
||||
rb_shape_t *rb_shape_get_next_no_warnings(rb_shape_t *shape, VALUE obj, ID id);
|
||||
rb_shape_t *rb_shape_object_id_shape(VALUE obj);
|
||||
bool rb_shape_has_object_id(rb_shape_t *shape);
|
||||
attr_index_t rb_shape_object_id_index(rb_shape_t *shape);
|
||||
|
||||
rb_shape_t *rb_shape_rebuild_shape(rb_shape_t *initial_shape, rb_shape_t *dest_shape);
|
||||
|
||||
|
@ -229,6 +235,12 @@ rb_shape_t *rb_shape_traverse_from_new_root(rb_shape_t *initial_shape, rb_shape_
|
|||
|
||||
bool rb_shape_set_shape_id(VALUE obj, shape_id_t shape_id);
|
||||
|
||||
static inline bool
|
||||
rb_shape_obj_has_id(VALUE obj)
|
||||
{
|
||||
return rb_shape_has_object_id(rb_shape_get_shape(obj));
|
||||
}
|
||||
|
||||
VALUE rb_obj_debug_shape(VALUE self, VALUE obj);
|
||||
|
||||
// For ext/objspace
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue