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

58
shape.c
View File

@ -10,7 +10,8 @@
* Shape getters * Shape getters
*/ */
static rb_shape_t* static rb_shape_t*
rb_shape_get_root_shape(void) { rb_shape_get_root_shape(void)
{
return GET_VM()->root_shape; return GET_VM()->root_shape;
} }
@ -21,12 +22,14 @@ rb_shape_id(rb_shape_t * shape)
} }
static rb_shape_t* static rb_shape_t*
rb_shape_get_frozen_root_shape(void) { rb_shape_get_frozen_root_shape(void)
{
return GET_VM()->frozen_root_shape; return GET_VM()->frozen_root_shape;
} }
bool 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(); return shape == rb_shape_get_root_shape();
} }
@ -90,7 +93,8 @@ rb_shape_get_shape(VALUE obj)
} }
static rb_shape_t * 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) { while (shape->parent_id != INVALID_SHAPE_ID) {
if (shape->edge_name == id) { if (shape->edge_name == id) {
// If the shape type is different, we don't // If the shape type is different, we don't
@ -239,7 +243,8 @@ rb_shape_get_next(rb_shape_t* shape, VALUE obj, ID id)
} }
bool 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) { while (shape->parent_id != INVALID_SHAPE_ID) {
if (shape->edge_name == id) { if (shape->edge_name == id) {
enum shape_type shape_type; enum shape_type shape_type;
@ -313,14 +318,16 @@ static const rb_data_type_t shape_data_type = {
}; };
static VALUE static VALUE
rb_wrapped_shape_id(VALUE self) { rb_wrapped_shape_id(VALUE self)
{
rb_shape_t * shape; rb_shape_t * shape;
TypedData_Get_Struct(self, rb_shape_t, &shape_data_type, shape); TypedData_Get_Struct(self, rb_shape_t, &shape_data_type, shape);
return INT2NUM(rb_shape_id(shape)); return INT2NUM(rb_shape_id(shape));
} }
static VALUE static VALUE
rb_shape_type(VALUE self) { rb_shape_type(VALUE self)
{
rb_shape_t * shape; rb_shape_t * shape;
TypedData_Get_Struct(self, rb_shape_t, &shape_data_type, shape); TypedData_Get_Struct(self, rb_shape_t, &shape_data_type, shape);
return INT2NUM(shape->type); 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) { if ((key & RUBY_ID_INTERNAL) == RUBY_ID_INTERNAL) {
return LONG2NUM(key); return LONG2NUM(key);
} else { }
else {
return ID2SYM(key); return ID2SYM(key);
} }
} }
static VALUE 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; union { const rb_shape_t *in; void *out; } deconst;
VALUE res; VALUE res;
deconst.in = shape; deconst.in = shape;
@ -357,7 +368,8 @@ rb_shape_t_to_rb_cShape(rb_shape_t *shape) {
return res; 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)); rb_hash_aset(*(VALUE *)ref, parse_key(key), rb_shape_t_to_rb_cShape((rb_shape_t*)value));
return ID_TABLE_CONTINUE; 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)); 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()); 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()); 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; return hash;
} }
VALUE rb_obj_shape(rb_shape_t* shape) { VALUE
rb_obj_shape(rb_shape_t* shape)
{
VALUE rb_shape = rb_hash_new(); VALUE rb_shape = rb_hash_new();
rb_hash_aset(rb_shape, ID2SYM(rb_intern("id")), INT2NUM(rb_shape_id(shape))); 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; 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()); 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); 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; shape_id = ivtbl->shape_id;
#endif #endif
ivar_list = ivtbl->ivptr; ivar_list = ivtbl->ivptr;
} else { }
else {
return Qnil; 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 (is_attr) {
if (cached_id != INVALID_SHAPE_ID) { if (cached_id != INVALID_SHAPE_ID) {
RB_DEBUG_COUNTER_INC(ivar_get_cc_miss_set); RB_DEBUG_COUNTER_INC(ivar_get_cc_miss_set);
} else { }
else {
RB_DEBUG_COUNTER_INC(ivar_get_cc_miss_unset); RB_DEBUG_COUNTER_INC(ivar_get_cc_miss_unset);
} }
} }
else { else {
if (cached_id != INVALID_SHAPE_ID) { if (cached_id != INVALID_SHAPE_ID) {
RB_DEBUG_COUNTER_INC(ivar_get_ic_miss_set); RB_DEBUG_COUNTER_INC(ivar_get_ic_miss_set);
} else { }
else {
RB_DEBUG_COUNTER_INC(ivar_get_ic_miss_unset); 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 { else {
break; break;
} }
} else { }
else {
break; 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_METHOD_ATTR(v,
vm_call_attrset_direct(ec, cfp, cc, calling->recv), vm_call_attrset_direct(ec, cfp, cc, calling->recv),
CC_SET_FASTPATH(cc, vm_call_attrset, !(vm_ci_flag(ci) & aset_mask))); CC_SET_FASTPATH(cc, vm_call_attrset, !(vm_ci_flag(ci) & aset_mask)));
} else { }
else {
cc = &((struct rb_callcache) { cc = &((struct rb_callcache) {
.flags = T_IMEMO | .flags = T_IMEMO |
(imemo_callcache << FL_USHIFT) | (imemo_callcache << FL_USHIFT) |