diff options
-rw-r--r-- | bignum.c | 8 | ||||
-rw-r--r-- | compile.c | 5 | ||||
-rw-r--r-- | cont.c | 3 | ||||
-rw-r--r-- | gc.c | 74 | ||||
-rw-r--r-- | parse.y | 40 | ||||
-rw-r--r-- | re.c | 96 | ||||
-rw-r--r-- | ruby_parser.c | 16 | ||||
-rw-r--r-- | thread.c | 12 | ||||
-rw-r--r-- | thread_pthread_mn.c | 36 | ||||
-rw-r--r-- | variable.c | 3 | ||||
-rw-r--r-- | vm_args.c | 3 | ||||
-rw-r--r-- | vm_insnhelper.c | 3 | ||||
-rw-r--r-- | vm_trace.c | 3 |
13 files changed, 157 insertions, 145 deletions
@@ -5501,10 +5501,10 @@ big_op(VALUE x, VALUE y, enum big_op_t op) n = FIX2INT(rel); switch (op) { - case big_op_gt: return RBOOL(n > 0); - case big_op_ge: return RBOOL(n >= 0); - case big_op_lt: return RBOOL(n < 0); - case big_op_le: return RBOOL(n <= 0); + case big_op_gt: return RBOOL(n > 0); + case big_op_ge: return RBOOL(n >= 0); + case big_op_lt: return RBOOL(n < 0); + case big_op_le: return RBOOL(n <= 0); } return Qundef; } @@ -2680,7 +2680,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor) break; } - case TS_CALLDATA: + case TS_CALLDATA: { const struct rb_callinfo *source_ci = (const struct rb_callinfo *)operands[j]; assert(ISEQ_COMPILE_DATA(iseq)->ci_index <= body->ci_size); @@ -3880,7 +3880,8 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal if ((flag & VM_CALL_ARGS_SPLAT) && !(flag & (VM_CALL_KW_SPLAT|VM_CALL_ARGS_BLOCKARG))) { OPERAND_AT(iobj, 0) = Qfalse; } - } else if (IS_NEXT_INSN_ID(niobj, getlocal) || IS_NEXT_INSN_ID(niobj, getinstancevariable)) { + } + else if (IS_NEXT_INSN_ID(niobj, getlocal) || IS_NEXT_INSN_ID(niobj, getinstancevariable)) { niobj = niobj->next; if (IS_NEXT_INSN_ID(niobj, send)) { @@ -3299,7 +3299,8 @@ rb_fiber_m_kill(VALUE self) else if (fiber->status != FIBER_TERMINATED) { if (fiber_current() == fiber) { fiber_check_killed(fiber); - } else { + } + else { fiber_raise(fiber_ptr(self), Qnil); } } @@ -5669,46 +5669,46 @@ gc_sweep_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bit asan_unpoison_object(vp, false); if (bitset & 1) { switch (BUILTIN_TYPE(vp)) { - default: /* majority case */ - gc_report(2, objspace, "page_sweep: free %p\n", (void *)p); + default: /* majority case */ + gc_report(2, objspace, "page_sweep: free %p\n", (void *)p); #if RGENGC_CHECK_MODE - if (!is_full_marking(objspace)) { - if (RVALUE_OLD_P(vp)) rb_bug("page_sweep: %p - old while minor GC.", (void *)p); - if (RVALUE_REMEMBERED(vp)) rb_bug("page_sweep: %p - remembered.", (void *)p); - } + if (!is_full_marking(objspace)) { + if (RVALUE_OLD_P(vp)) rb_bug("page_sweep: %p - old while minor GC.", (void *)p); + if (RVALUE_REMEMBERED(vp)) rb_bug("page_sweep: %p - remembered.", (void *)p); + } #endif - if (obj_free(objspace, vp)) { - // always add free slots back to the swept pages freelist, - // so that if we're comapacting, we can re-use the slots - (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)p, BASE_SLOT_SIZE); - heap_page_add_freeobj(objspace, sweep_page, vp); - gc_report(3, objspace, "page_sweep: %s is added to freelist\n", obj_info(vp)); - ctx->freed_slots++; - } - else { - ctx->final_slots++; - } - break; - - case T_MOVED: - if (objspace->flags.during_compacting) { - /* The sweep cursor shouldn't have made it to any - * T_MOVED slots while the compact flag is enabled. - * The sweep cursor and compact cursor move in - * opposite directions, and when they meet references will - * get updated and "during_compacting" should get disabled */ - rb_bug("T_MOVED shouldn't be seen until compaction is finished"); - } - gc_report(3, objspace, "page_sweep: %s is added to freelist\n", obj_info(vp)); - ctx->empty_slots++; + if (obj_free(objspace, vp)) { + // always add free slots back to the swept pages freelist, + // so that if we're comapacting, we can re-use the slots + (void)VALGRIND_MAKE_MEM_UNDEFINED((void*)p, BASE_SLOT_SIZE); heap_page_add_freeobj(objspace, sweep_page, vp); - break; - case T_ZOMBIE: - /* already counted */ - break; - case T_NONE: - ctx->empty_slots++; /* already freed */ - break; + gc_report(3, objspace, "page_sweep: %s is added to freelist\n", obj_info(vp)); + ctx->freed_slots++; + } + else { + ctx->final_slots++; + } + break; + + case T_MOVED: + if (objspace->flags.during_compacting) { + /* The sweep cursor shouldn't have made it to any + * T_MOVED slots while the compact flag is enabled. + * The sweep cursor and compact cursor move in + * opposite directions, and when they meet references will + * get updated and "during_compacting" should get disabled */ + rb_bug("T_MOVED shouldn't be seen until compaction is finished"); + } + gc_report(3, objspace, "page_sweep: %s is added to freelist\n", obj_info(vp)); + ctx->empty_slots++; + heap_page_add_freeobj(objspace, sweep_page, vp); + break; + case T_ZOMBIE: + /* already counted */ + break; + case T_NONE: + ctx->empty_slots++; /* already freed */ + break; } } p += slot_size; @@ -9161,20 +9161,20 @@ set_number_literal(struct parser_params *p, enum yytokentype type, int suffix, i } switch (type) { - case tINTEGER: - set_yylval_node(NEW_INTEGER(strdup(tok(p)), base, &_cur_loc)); - break; - case tFLOAT: - set_yylval_node(NEW_FLOAT(strdup(tok(p)), &_cur_loc)); - break; - case tRATIONAL: - set_yylval_node(NEW_RATIONAL(strdup(tok(p)), base, seen_point, &_cur_loc)); - break; - case tIMAGINARY: - set_yylval_node(NEW_IMAGINARY(strdup(tok(p)), base, seen_point, numeric_type, &_cur_loc)); - break; - default: - rb_bug("unexpected token: %d", type); + case tINTEGER: + set_yylval_node(NEW_INTEGER(strdup(tok(p)), base, &_cur_loc)); + break; + case tFLOAT: + set_yylval_node(NEW_FLOAT(strdup(tok(p)), &_cur_loc)); + break; + case tRATIONAL: + set_yylval_node(NEW_RATIONAL(strdup(tok(p)), base, seen_point, &_cur_loc)); + break; + case tIMAGINARY: + set_yylval_node(NEW_IMAGINARY(strdup(tok(p)), base, seen_point, numeric_type, &_cur_loc)); + break; + default: + rb_bug("unexpected token: %d", type); } SET_LEX_STATE(EXPR_END); return type; @@ -12068,7 +12068,8 @@ rb_node_lit_new(struct parser_params *p, VALUE nd_lit, const YYLTYPE *loc) } static rb_node_integer_t * -rb_node_integer_new(struct parser_params *p, char* val, int base, const YYLTYPE *loc) { +rb_node_integer_new(struct parser_params *p, char* val, int base, const YYLTYPE *loc) +{ rb_node_integer_t *n = NODE_NEWNODE(NODE_INTEGER, rb_node_integer_t, loc); n->val = val; n->minus = FALSE; @@ -12078,7 +12079,8 @@ rb_node_integer_new(struct parser_params *p, char* val, int base, const YYLTYPE } static rb_node_float_t * -rb_node_float_new(struct parser_params *p, char* val, const YYLTYPE *loc) { +rb_node_float_new(struct parser_params *p, char* val, const YYLTYPE *loc) +{ rb_node_float_t *n = NODE_NEWNODE(NODE_FLOAT, rb_node_float_t, loc); n->val = val; n->minus = FALSE; @@ -12087,7 +12089,8 @@ rb_node_float_new(struct parser_params *p, char* val, const YYLTYPE *loc) { } static rb_node_rational_t * -rb_node_rational_new(struct parser_params *p, char* val, int base, int seen_point, const YYLTYPE *loc) { +rb_node_rational_new(struct parser_params *p, char* val, int base, int seen_point, const YYLTYPE *loc) +{ rb_node_rational_t *n = NODE_NEWNODE(NODE_RATIONAL, rb_node_rational_t, loc); n->val = val; n->minus = FALSE; @@ -12098,7 +12101,8 @@ rb_node_rational_new(struct parser_params *p, char* val, int base, int seen_poin } static rb_node_imaginary_t * -rb_node_imaginary_new(struct parser_params *p, char* val, int base, int seen_point, enum rb_numeric_type numeric_type, const YYLTYPE *loc) { +rb_node_imaginary_new(struct parser_params *p, char* val, int base, int seen_point, enum rb_numeric_type numeric_type, const YYLTYPE *loc) +{ rb_node_imaginary_t *n = NODE_NEWNODE(NODE_IMAGINARY, rb_node_imaginary_t, loc); n->val = val; n->minus = FALSE; @@ -3040,55 +3040,55 @@ escape_asis: parens++; } - for(s = p+1; s < end; s++) { + for (s = p+1; s < end; s++) { switch(*s) { - case 'x': - local_extend = invert ? -1 : 1; - break; - case '-': - invert = 1; - break; - case ':': - case ')': - if (local_extend == 0 || - (local_extend == -1 && !extended_mode) || - (local_extend == 1 && extended_mode)) { - /* no changes to extended flag */ - goto fallthrough; - } - - if (*s == ':') { - /* change extended flag until ')' */ - int local_options = options; - if (local_extend == 1) { - local_options |= ONIG_OPTION_EXTEND; - } - else { - local_options &= ~ONIG_OPTION_EXTEND; - } - - rb_str_buf_cat(buf, (char *)&c, 1); - int ret = unescape_nonascii0(&p, end, enc, buf, encp, - has_property, err, - local_options, 1); - if (ret < 0) return ret; - goto begin_scan; - } - else { - /* change extended flag for rest of expression */ - extended_mode = local_extend == 1; - goto fallthrough; - } - case 'i': - case 'm': - case 'a': - case 'd': - case 'u': - /* other option flags, ignored during scanning */ - break; - default: - /* other character, no extended flag change*/ - goto fallthrough; + case 'x': + local_extend = invert ? -1 : 1; + break; + case '-': + invert = 1; + break; + case ':': + case ')': + if (local_extend == 0 || + (local_extend == -1 && !extended_mode) || + (local_extend == 1 && extended_mode)) { + /* no changes to extended flag */ + goto fallthrough; + } + + if (*s == ':') { + /* change extended flag until ')' */ + int local_options = options; + if (local_extend == 1) { + local_options |= ONIG_OPTION_EXTEND; + } + else { + local_options &= ~ONIG_OPTION_EXTEND; + } + + rb_str_buf_cat(buf, (char *)&c, 1); + int ret = unescape_nonascii0(&p, end, enc, buf, encp, + has_property, err, + local_options, 1); + if (ret < 0) return ret; + goto begin_scan; + } + else { + /* change extended flag for rest of expression */ + extended_mode = local_extend == 1; + goto fallthrough; + } + case 'i': + case 'm': + case 'a': + case 'd': + case 'u': + /* other option flags, ignored during scanning */ + break; + default: + /* other character, no extended flag change*/ + goto fallthrough; } } } diff --git a/ruby_parser.c b/ruby_parser.c index 829d9e86d5..eb05771f7e 100644 --- a/ruby_parser.c +++ b/ruby_parser.c @@ -17,23 +17,22 @@ compile_negative_numeric(VALUE val) } #endif } - switch (OBJ_BUILTIN_TYPE(val)) - { - case T_BIGNUM: + switch (OBJ_BUILTIN_TYPE(val)) { + case T_BIGNUM: BIGNUM_NEGATE(val); val = rb_big_norm(val); break; - case T_RATIONAL: + case T_RATIONAL: RATIONAL_SET_NUM(val, compile_negative_numeric(RRATIONAL(val)->num)); break; - case T_COMPLEX: + case T_COMPLEX: RCOMPLEX_SET_REAL(val, compile_negative_numeric(RCOMPLEX(val)->real)); RCOMPLEX_SET_IMAG(val, compile_negative_numeric(RCOMPLEX(val)->imag)); break; - case T_FLOAT: + case T_FLOAT: val = DBL2NUM(-RFLOAT_VALUE(val)); break; - default: + default: val = LONG2FIX(-FIX2LONG(val)); break; } @@ -79,7 +78,8 @@ compile_rational_literal(char* node_val, int base, int seen_point) memmove(point, point+1, fraclen+1); lit = rb_rational_new(compile_numeric_literal(val, base), rb_int_positive_pow(10, fraclen)); - } else { + } + else { lit = rb_rational_raw1(compile_numeric_literal(val, base)); } @@ -410,12 +410,12 @@ rb_threadptr_join_list_wakeup(rb_thread_t *thread) rb_threadptr_interrupt(target_thread); switch (target_thread->status) { - case THREAD_STOPPED: - case THREAD_STOPPED_FOREVER: - target_thread->status = THREAD_RUNNABLE; - break; - default: - break; + case THREAD_STOPPED: + case THREAD_STOPPED_FOREVER: + target_thread->status = THREAD_RUNNABLE; + break; + default: + break; } } } diff --git a/thread_pthread_mn.c b/thread_pthread_mn.c index c8c7d9f173..f44c8b18a2 100644 --- a/thread_pthread_mn.c +++ b/thread_pthread_mn.c @@ -552,14 +552,14 @@ static enum thread_sched_waiting_flag kqueue_translate_filter_to_flags(int16_t filter) { switch (filter) { - case EVFILT_READ: - return thread_sched_waiting_io_read; - case EVFILT_WRITE: - return thread_sched_waiting_io_write; - case EVFILT_TIMER: - return thread_sched_waiting_timeout; - default: - rb_bug("kevent filter:%d not supported", filter); + case EVFILT_READ: + return thread_sched_waiting_io_read; + case EVFILT_WRITE: + return thread_sched_waiting_io_write; + case EVFILT_TIMER: + return thread_sched_waiting_timeout; + default: + rb_bug("kevent filter:%d not supported", filter); } } @@ -713,13 +713,13 @@ timer_thread_register_waiting(rb_thread_t *th, int fd, enum thread_sched_waiting RUBY_DEBUG_LOG("failed (%d)", errno); switch (errno) { - case EBADF: - // the fd is closed? - case EINTR: - // signal received? is there a sensible way to handle this? - default: - perror("kevent"); - rb_bug("register/kevent failed(fd:%d, errno:%d)", fd, errno); + case EBADF: + // the fd is closed? + case EINTR: + // signal received? is there a sensible way to handle this? + default: + perror("kevent"); + rb_bug("register/kevent failed(fd:%d, errno:%d)", fd, errno); } } RUBY_DEBUG_LOG("kevent(add, fd:%d) success", fd); @@ -921,7 +921,8 @@ timer_thread_polling(rb_vm_t *vm) // wakeup timerthread RUBY_DEBUG_LOG("comm from fd:%d", timer_th.comm_fds[1]); consume_communication_pipe(timer_th.comm_fds[0]); - } else { + } + else { // wakeup specific thread by IO RUBY_DEBUG_LOG("io event. wakeup_th:%u event:%s%s", rb_th_serial(th), @@ -940,7 +941,8 @@ timer_thread_polling(rb_vm_t *vm) th->sched.waiting_reason.data.result = filter; timer_thread_wakeup_thread(th); - } else { + } + else { // already released } } diff --git a/variable.c b/variable.c index 1a4f919c4c..bb53d15f25 100644 --- a/variable.c +++ b/variable.c @@ -216,7 +216,8 @@ rb_mod_set_temporary_name(VALUE mod, VALUE name) if (NIL_P(name)) { // Set the temporary classpath to NULL (anonymous): RCLASS_SET_CLASSPATH(mod, 0, FALSE); - } else { + } + else { // Ensure the name is a string: StringValue(name); @@ -551,7 +551,8 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co arg_rest_dup(args); rb_ary_push(args->rest, converted_keyword_hash); keyword_hash = Qnil; - } else { + } + else { keyword_hash = converted_keyword_hash; } diff --git a/vm_insnhelper.c b/vm_insnhelper.c index b72167f75d..d81a121c1f 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -5884,7 +5884,8 @@ rb_vm_opt_getconstant_path(rb_execution_context_t *ec, rb_control_frame_t *const val = ice->value; VM_ASSERT(val == vm_get_ev_const_chain(ec, segments)); - } else { + } + else { ruby_vm_constant_cache_misses++; val = vm_get_ev_const_chain(ec, segments); vm_ic_track_const_chain(GET_CFP(), ic, segments); diff --git a/vm_trace.c b/vm_trace.c index e6e60efaec..02008166e4 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -1767,7 +1767,8 @@ rb_postponed_job_preregister(unsigned int flags, rb_postponed_job_func_t func, v * datas being written */ RUBY_ATOMIC_PTR_EXCHANGE(pjq->table[i].data, data); return (rb_postponed_job_handle_t)i; - } else { + } + else { /* Try the next slot if this one already has a func in it */ continue; } |