зеркало из https://github.com/github/ruby.git
Make special const and too complex shapes before T_OBJECT shapes
This commit is contained in:
Родитель
6b0434c0f7
Коммит
3896f9940e
2
gc.c
2
gc.c
|
@ -8119,7 +8119,7 @@ gc_compact_move(rb_objspace_t *objspace, rb_heap_t *heap, rb_size_pool_t *size_p
|
|||
if (RB_TYPE_P(src, T_OBJECT)) {
|
||||
orig_shape = rb_shape_get_shape(src);
|
||||
if (dheap != heap && !rb_shape_obj_too_complex(src)) {
|
||||
rb_shape_t *initial_shape = rb_shape_get_shape_by_id((shape_id_t)((dest_pool - size_pools) + SIZE_POOL_COUNT));
|
||||
rb_shape_t *initial_shape = rb_shape_get_shape_by_id((shape_id_t)((dest_pool - size_pools) + FIRST_T_OBJECT_SHAPE_ID));
|
||||
new_shape = rb_shape_traverse_from_new_root(initial_shape, orig_shape);
|
||||
|
||||
if (!new_shape) {
|
||||
|
|
2
object.c
2
object.c
|
@ -135,7 +135,7 @@ rb_class_allocate_instance(VALUE klass)
|
|||
RUBY_ASSERT(rb_shape_get_shape(obj)->type == SHAPE_ROOT);
|
||||
|
||||
// Set the shape to the specific T_OBJECT shape.
|
||||
ROBJECT_SET_SHAPE_ID(obj, (shape_id_t)(rb_gc_size_pool_id_for_size(size) + 1));
|
||||
ROBJECT_SET_SHAPE_ID(obj, (shape_id_t)(rb_gc_size_pool_id_for_size(size) + FIRST_T_OBJECT_SHAPE_ID));
|
||||
|
||||
#if RUBY_DEBUG
|
||||
RUBY_ASSERT(!rb_shape_obj_too_complex(obj));
|
||||
|
|
13
shape.c
13
shape.c
|
@ -1256,18 +1256,6 @@ Init_default_shapes(void)
|
|||
GET_SHAPE_TREE()->root_shape = root;
|
||||
RUBY_ASSERT(rb_shape_id(GET_SHAPE_TREE()->root_shape) == ROOT_SHAPE_ID);
|
||||
|
||||
// Make shapes for T_OBJECT
|
||||
size_t *sizes = rb_gc_size_pool_sizes();
|
||||
for (int i = 0; sizes[i] > 0; i++) {
|
||||
rb_shape_t *t_object_shape =
|
||||
rb_shape_alloc_with_parent_id(0, INVALID_SHAPE_ID);
|
||||
t_object_shape->type = SHAPE_T_OBJECT;
|
||||
t_object_shape->capacity = (uint32_t)((sizes[i] - offsetof(struct RObject, as.ary)) / sizeof(VALUE));
|
||||
t_object_shape->edges = rb_id_table_create(0);
|
||||
t_object_shape->ancestor_index = LEAF;
|
||||
RUBY_ASSERT(rb_shape_id(t_object_shape) == (shape_id_t)(i + 1));
|
||||
}
|
||||
|
||||
bool dont_care;
|
||||
// Special const shape
|
||||
#if RUBY_DEBUG
|
||||
|
@ -1323,6 +1311,7 @@ Init_shape(void)
|
|||
rb_define_const(rb_cShape, "SHAPE_FLAG_SHIFT", INT2NUM(SHAPE_FLAG_SHIFT));
|
||||
rb_define_const(rb_cShape, "SPECIAL_CONST_SHAPE_ID", INT2NUM(SPECIAL_CONST_SHAPE_ID));
|
||||
rb_define_const(rb_cShape, "OBJ_TOO_COMPLEX_SHAPE_ID", INT2NUM(OBJ_TOO_COMPLEX_SHAPE_ID));
|
||||
rb_define_const(rb_cShape, "FIRST_T_OBJECT_SHAPE_ID", INT2NUM(FIRST_T_OBJECT_SHAPE_ID));
|
||||
rb_define_const(rb_cShape, "SHAPE_MAX_VARIATIONS", INT2NUM(SHAPE_MAX_VARIATIONS));
|
||||
rb_define_const(rb_cShape, "SIZEOF_RB_SHAPE_T", INT2NUM(sizeof(rb_shape_t)));
|
||||
rb_define_const(rb_cShape, "SIZEOF_REDBLACK_NODE_T", INT2NUM(sizeof(redblack_node_t)));
|
||||
|
|
3
shape.h
3
shape.h
|
@ -35,8 +35,9 @@ typedef uint32_t redblack_id_t;
|
|||
# define INVALID_SHAPE_ID SHAPE_MASK
|
||||
# define ROOT_SHAPE_ID 0x0
|
||||
|
||||
# define SPECIAL_CONST_SHAPE_ID (SIZE_POOL_COUNT + 1)
|
||||
# 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)
|
||||
|
||||
typedef struct redblack_node redblack_node_t;
|
||||
|
||||
|
|
|
@ -786,7 +786,7 @@ class TestShapes < Test::Unit::TestCase
|
|||
def test_remove_instance_variable_capacity_transition
|
||||
assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
|
||||
begin;
|
||||
t_object_shape = RubyVM::Shape.find_by_id(1)
|
||||
t_object_shape = RubyVM::Shape.find_by_id(RubyVM::Shape::FIRST_T_OBJECT_SHAPE_ID)
|
||||
assert_equal(RubyVM::Shape::SHAPE_T_OBJECT, t_object_shape.type)
|
||||
|
||||
initial_capacity = t_object_shape.capacity
|
||||
|
|
Загрузка…
Ссылка в новой задаче