Adjust indents [ci skip]

This commit is contained in:
Nobuyoshi Nakada 2022-10-12 18:27:23 +09:00
parent 504e388525
commit 70bc8cc6c2
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6
2 changed files with 204 additions and 175 deletions

64
shape.c
View File

@ -10,7 +10,8 @@
* Shape getters
*/
static rb_shape_t*
rb_shape_get_root_shape(void) {
rb_shape_get_root_shape(void)
{
return GET_VM()->root_shape;
}
@ -21,12 +22,14 @@ rb_shape_id(rb_shape_t * shape)
}
static rb_shape_t*
rb_shape_get_frozen_root_shape(void) {
rb_shape_get_frozen_root_shape(void)
{
return GET_VM()->frozen_root_shape;
}
bool
rb_shape_root_shape_p(rb_shape_t* shape) {
rb_shape_root_shape_p(rb_shape_t* shape)
{
return shape == rb_shape_get_root_shape();
}
@ -90,7 +93,8 @@ rb_shape_get_shape(VALUE obj)
}
static rb_shape_t *
rb_shape_lookup_id(rb_shape_t* shape, ID id, enum shape_type shape_type) {
rb_shape_lookup_id(rb_shape_t* shape, ID id, enum shape_type shape_type)
{
while (shape->parent_id != INVALID_SHAPE_ID) {
if (shape->edge_name == id) {
// If the shape type is different, we don't
@ -136,7 +140,7 @@ get_next_shape_internal(rb_shape_t* shape, ID id, VALUE obj, enum shape_type sha
new_shape->type = (uint8_t)shape_type;
switch(shape_type) {
switch (shape_type) {
case SHAPE_IVAR:
new_shape->iv_count = rb_shape_get_shape_by_id(new_shape->parent_id)->iv_count + 1;
@ -199,7 +203,7 @@ rb_shape_transition_shape_frozen(VALUE obj)
rb_shape_t* next_shape;
if (shape == rb_shape_get_root_shape()) {
switch(BUILTIN_TYPE(obj)) {
switch (BUILTIN_TYPE(obj)) {
case T_OBJECT:
case T_CLASS:
case T_MODULE:
@ -239,13 +243,14 @@ rb_shape_get_next(rb_shape_t* shape, VALUE obj, ID id)
}
bool
rb_shape_get_iv_index(rb_shape_t * shape, ID id, attr_index_t *value) {
rb_shape_get_iv_index(rb_shape_t * shape, ID id, attr_index_t *value)
{
while (shape->parent_id != INVALID_SHAPE_ID) {
if (shape->edge_name == id) {
enum shape_type shape_type;
shape_type = (enum shape_type)shape->type;
switch(shape_type) {
switch (shape_type) {
case SHAPE_IVAR:
RUBY_ASSERT(shape->iv_count > 0);
*value = shape->iv_count - 1;
@ -313,14 +318,16 @@ static const rb_data_type_t shape_data_type = {
};
static VALUE
rb_wrapped_shape_id(VALUE self) {
rb_wrapped_shape_id(VALUE self)
{
rb_shape_t * shape;
TypedData_Get_Struct(self, rb_shape_t, &shape_data_type, shape);
return INT2NUM(rb_shape_id(shape));
}
static VALUE
rb_shape_type(VALUE self) {
rb_shape_type(VALUE self)
{
rb_shape_t * shape;
TypedData_Get_Struct(self, rb_shape_t, &shape_data_type, shape);
return INT2NUM(shape->type);
@ -339,16 +346,20 @@ rb_shape_parent_id(VALUE self)
}
}
static VALUE parse_key(ID key) {
static VALUE
parse_key(ID key)
{
if ((key & RUBY_ID_INTERNAL) == RUBY_ID_INTERNAL) {
return LONG2NUM(key);
} else {
}
else {
return ID2SYM(key);
}
}
static VALUE
rb_shape_t_to_rb_cShape(rb_shape_t *shape) {
rb_shape_t_to_rb_cShape(rb_shape_t *shape)
{
union { const rb_shape_t *in; void *out; } deconst;
VALUE res;
deconst.in = shape;
@ -357,7 +368,8 @@ rb_shape_t_to_rb_cShape(rb_shape_t *shape) {
return res;
}
static enum rb_id_table_iterator_result rb_edges_to_hash(ID key, VALUE value, void *ref)
static enum rb_id_table_iterator_result
rb_edges_to_hash(ID key, VALUE value, void *ref)
{
rb_hash_aset(*(VALUE *)ref, parse_key(key), rb_shape_t_to_rb_cShape((rb_shape_t*)value));
return ID_TABLE_CONTINUE;
@ -428,15 +440,21 @@ rb_shape_parent(VALUE self)
}
}
VALUE rb_shape_debug_shape(VALUE self, VALUE obj) {
VALUE
rb_shape_debug_shape(VALUE self, VALUE obj)
{
return rb_shape_t_to_rb_cShape(rb_shape_get_shape(obj));
}
VALUE rb_shape_root_shape(VALUE self) {
VALUE
rb_shape_root_shape(VALUE self)
{
return rb_shape_t_to_rb_cShape(rb_shape_get_root_shape());
}
VALUE rb_shape_frozen_root_shape(VALUE self) {
VALUE
rb_shape_frozen_root_shape(VALUE self)
{
return rb_shape_t_to_rb_cShape(rb_shape_get_frozen_root_shape());
}
@ -456,7 +474,9 @@ static VALUE edges(struct rb_id_table* edges)
return hash;
}
VALUE rb_obj_shape(rb_shape_t* shape) {
VALUE
rb_obj_shape(rb_shape_t* shape)
{
VALUE rb_shape = rb_hash_new();
rb_hash_aset(rb_shape, ID2SYM(rb_intern("id")), INT2NUM(rb_shape_id(shape)));
@ -473,11 +493,15 @@ VALUE rb_obj_shape(rb_shape_t* shape) {
return rb_shape;
}
static VALUE shape_transition_tree(VALUE self) {
static VALUE
shape_transition_tree(VALUE self)
{
return rb_obj_shape(rb_shape_get_root_shape());
}
static VALUE next_shape_id(VALUE self) {
static VALUE
next_shape_id(VALUE self)
{
return INT2NUM(GET_VM()->next_shape_id);
}

View File

@ -1151,7 +1151,8 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
shape_id = ivtbl->shape_id;
#endif
ivar_list = ivtbl->ivptr;
} else {
}
else {
return Qnil;
}
}
@ -1172,7 +1173,7 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
vm_ic_atomic_shape_and_index(ic, &cached_id, &index);
}
if(LIKELY(cached_id == shape_id)) {
if (LIKELY(cached_id == shape_id)) {
if (index == ATTR_INDEX_NOT_SET) {
return Qnil;
}
@ -1185,14 +1186,16 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
if (is_attr) {
if (cached_id != INVALID_SHAPE_ID) {
RB_DEBUG_COUNTER_INC(ivar_get_cc_miss_set);
} else {
}
else {
RB_DEBUG_COUNTER_INC(ivar_get_cc_miss_unset);
}
}
else {
if (cached_id != INVALID_SHAPE_ID) {
RB_DEBUG_COUNTER_INC(ivar_get_ic_miss_set);
} else {
}
else {
RB_DEBUG_COUNTER_INC(ivar_get_ic_miss_unset);
}
}
@ -1426,7 +1429,8 @@ vm_setivar(VALUE obj, ID id, VALUE val, shape_id_t dest_shape_id, attr_index_t i
else {
break;
}
} else {
}
else {
break;
}
@ -3895,7 +3899,8 @@ vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, st
VM_CALL_METHOD_ATTR(v,
vm_call_attrset_direct(ec, cfp, cc, calling->recv),
CC_SET_FASTPATH(cc, vm_call_attrset, !(vm_ci_flag(ci) & aset_mask)));
} else {
}
else {
cc = &((struct rb_callcache) {
.flags = T_IMEMO |
(imemo_callcache << FL_USHIFT) |