Adjust styles and indents [ci skip]

This commit is contained in:
Nobuyoshi Nakada 2024-01-08 00:50:41 +09:00
parent 76c20b06aa
commit c30b8ae947
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
13 changed files with 155 additions and 143 deletions

View File

@ -5501,10 +5501,10 @@ big_op(VALUE x, VALUE y, enum big_op_t op)
n = FIX2INT(rel); n = FIX2INT(rel);
switch (op) { switch (op) {
case big_op_gt: return RBOOL(n > 0); case big_op_gt: return RBOOL(n > 0);
case big_op_ge: return RBOOL(n >= 0); case big_op_ge: return RBOOL(n >= 0);
case big_op_lt: return RBOOL(n < 0); case big_op_lt: return RBOOL(n < 0);
case big_op_le: return RBOOL(n <= 0); case big_op_le: return RBOOL(n <= 0);
} }
return Qundef; return Qundef;
} }

View File

@ -2680,7 +2680,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
break; break;
} }
case TS_CALLDATA: case TS_CALLDATA:
{ {
const struct rb_callinfo *source_ci = (const struct rb_callinfo *)operands[j]; const struct rb_callinfo *source_ci = (const struct rb_callinfo *)operands[j];
assert(ISEQ_COMPILE_DATA(iseq)->ci_index <= body->ci_size); 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))) { if ((flag & VM_CALL_ARGS_SPLAT) && !(flag & (VM_CALL_KW_SPLAT|VM_CALL_ARGS_BLOCKARG))) {
OPERAND_AT(iobj, 0) = Qfalse; 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; niobj = niobj->next;
if (IS_NEXT_INSN_ID(niobj, send)) { if (IS_NEXT_INSN_ID(niobj, send)) {

3
cont.c
View File

@ -3299,7 +3299,8 @@ rb_fiber_m_kill(VALUE self)
else if (fiber->status != FIBER_TERMINATED) { else if (fiber->status != FIBER_TERMINATED) {
if (fiber_current() == fiber) { if (fiber_current() == fiber) {
fiber_check_killed(fiber); fiber_check_killed(fiber);
} else { }
else {
fiber_raise(fiber_ptr(self), Qnil); fiber_raise(fiber_ptr(self), Qnil);
} }
} }

74
gc.c
View File

@ -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); asan_unpoison_object(vp, false);
if (bitset & 1) { if (bitset & 1) {
switch (BUILTIN_TYPE(vp)) { switch (BUILTIN_TYPE(vp)) {
default: /* majority case */ default: /* majority case */
gc_report(2, objspace, "page_sweep: free %p\n", (void *)p); gc_report(2, objspace, "page_sweep: free %p\n", (void *)p);
#if RGENGC_CHECK_MODE #if RGENGC_CHECK_MODE
if (!is_full_marking(objspace)) { if (!is_full_marking(objspace)) {
if (RVALUE_OLD_P(vp)) rb_bug("page_sweep: %p - old while minor GC.", (void *)p); 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 (RVALUE_REMEMBERED(vp)) rb_bug("page_sweep: %p - remembered.", (void *)p);
} }
#endif #endif
if (obj_free(objspace, vp)) { if (obj_free(objspace, vp)) {
// always add free slots back to the swept pages freelist, // always add free slots back to the swept pages freelist,
// so that if we're comapacting, we can re-use the slots // so that if we're comapacting, we can re-use the slots
(void)VALGRIND_MAKE_MEM_UNDEFINED((void*)p, BASE_SLOT_SIZE); (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++;
heap_page_add_freeobj(objspace, sweep_page, vp); heap_page_add_freeobj(objspace, sweep_page, vp);
break; gc_report(3, objspace, "page_sweep: %s is added to freelist\n", obj_info(vp));
case T_ZOMBIE: ctx->freed_slots++;
/* already counted */ }
break; else {
case T_NONE: ctx->final_slots++;
ctx->empty_slots++; /* already freed */ }
break; 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; p += slot_size;

40
parse.y
View File

@ -9161,20 +9161,20 @@ set_number_literal(struct parser_params *p, enum yytokentype type, int suffix, i
} }
switch (type) { switch (type) {
case tINTEGER: case tINTEGER:
set_yylval_node(NEW_INTEGER(strdup(tok(p)), base, &_cur_loc)); set_yylval_node(NEW_INTEGER(strdup(tok(p)), base, &_cur_loc));
break; break;
case tFLOAT: case tFLOAT:
set_yylval_node(NEW_FLOAT(strdup(tok(p)), &_cur_loc)); set_yylval_node(NEW_FLOAT(strdup(tok(p)), &_cur_loc));
break; break;
case tRATIONAL: case tRATIONAL:
set_yylval_node(NEW_RATIONAL(strdup(tok(p)), base, seen_point, &_cur_loc)); set_yylval_node(NEW_RATIONAL(strdup(tok(p)), base, seen_point, &_cur_loc));
break; break;
case tIMAGINARY: case tIMAGINARY:
set_yylval_node(NEW_IMAGINARY(strdup(tok(p)), base, seen_point, numeric_type, &_cur_loc)); set_yylval_node(NEW_IMAGINARY(strdup(tok(p)), base, seen_point, numeric_type, &_cur_loc));
break; break;
default: default:
rb_bug("unexpected token: %d", type); rb_bug("unexpected token: %d", type);
} }
SET_LEX_STATE(EXPR_END); SET_LEX_STATE(EXPR_END);
return type; 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 * 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); rb_node_integer_t *n = NODE_NEWNODE(NODE_INTEGER, rb_node_integer_t, loc);
n->val = val; n->val = val;
n->minus = FALSE; 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 * 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); rb_node_float_t *n = NODE_NEWNODE(NODE_FLOAT, rb_node_float_t, loc);
n->val = val; n->val = val;
n->minus = FALSE; 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 * 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); rb_node_rational_t *n = NODE_NEWNODE(NODE_RATIONAL, rb_node_rational_t, loc);
n->val = val; n->val = val;
n->minus = FALSE; 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 * 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); rb_node_imaginary_t *n = NODE_NEWNODE(NODE_IMAGINARY, rb_node_imaginary_t, loc);
n->val = val; n->val = val;
n->minus = FALSE; n->minus = FALSE;

92
re.c
View File

@ -3040,55 +3040,55 @@ escape_asis:
parens++; parens++;
} }
for(s = p+1; s < end; s++) { for (s = p+1; s < end; s++) {
switch(*s) { switch(*s) {
case 'x': case 'x':
local_extend = invert ? -1 : 1; local_extend = invert ? -1 : 1;
break; break;
case '-': case '-':
invert = 1; invert = 1;
break; break;
case ':': case ':':
case ')': case ')':
if (local_extend == 0 || if (local_extend == 0 ||
(local_extend == -1 && !extended_mode) || (local_extend == -1 && !extended_mode) ||
(local_extend == 1 && extended_mode)) { (local_extend == 1 && extended_mode)) {
/* no changes to extended flag */ /* no changes to extended flag */
goto fallthrough; goto fallthrough;
} }
if (*s == ':') { if (*s == ':') {
/* change extended flag until ')' */ /* change extended flag until ')' */
int local_options = options; int local_options = options;
if (local_extend == 1) { if (local_extend == 1) {
local_options |= ONIG_OPTION_EXTEND; local_options |= ONIG_OPTION_EXTEND;
} }
else { else {
local_options &= ~ONIG_OPTION_EXTEND; local_options &= ~ONIG_OPTION_EXTEND;
} }
rb_str_buf_cat(buf, (char *)&c, 1); rb_str_buf_cat(buf, (char *)&c, 1);
int ret = unescape_nonascii0(&p, end, enc, buf, encp, int ret = unescape_nonascii0(&p, end, enc, buf, encp,
has_property, err, has_property, err,
local_options, 1); local_options, 1);
if (ret < 0) return ret; if (ret < 0) return ret;
goto begin_scan; goto begin_scan;
} }
else { else {
/* change extended flag for rest of expression */ /* change extended flag for rest of expression */
extended_mode = local_extend == 1; extended_mode = local_extend == 1;
goto fallthrough; goto fallthrough;
} }
case 'i': case 'i':
case 'm': case 'm':
case 'a': case 'a':
case 'd': case 'd':
case 'u': case 'u':
/* other option flags, ignored during scanning */ /* other option flags, ignored during scanning */
break; break;
default: default:
/* other character, no extended flag change*/ /* other character, no extended flag change*/
goto fallthrough; goto fallthrough;
} }
} }
} }

View File

@ -17,23 +17,22 @@ compile_negative_numeric(VALUE val)
} }
#endif #endif
} }
switch (OBJ_BUILTIN_TYPE(val)) switch (OBJ_BUILTIN_TYPE(val)) {
{ case T_BIGNUM:
case T_BIGNUM:
BIGNUM_NEGATE(val); BIGNUM_NEGATE(val);
val = rb_big_norm(val); val = rb_big_norm(val);
break; break;
case T_RATIONAL: case T_RATIONAL:
RATIONAL_SET_NUM(val, compile_negative_numeric(RRATIONAL(val)->num)); RATIONAL_SET_NUM(val, compile_negative_numeric(RRATIONAL(val)->num));
break; break;
case T_COMPLEX: case T_COMPLEX:
RCOMPLEX_SET_REAL(val, compile_negative_numeric(RCOMPLEX(val)->real)); RCOMPLEX_SET_REAL(val, compile_negative_numeric(RCOMPLEX(val)->real));
RCOMPLEX_SET_IMAG(val, compile_negative_numeric(RCOMPLEX(val)->imag)); RCOMPLEX_SET_IMAG(val, compile_negative_numeric(RCOMPLEX(val)->imag));
break; break;
case T_FLOAT: case T_FLOAT:
val = DBL2NUM(-RFLOAT_VALUE(val)); val = DBL2NUM(-RFLOAT_VALUE(val));
break; break;
default: default:
val = LONG2FIX(-FIX2LONG(val)); val = LONG2FIX(-FIX2LONG(val));
break; break;
} }
@ -79,7 +78,8 @@ compile_rational_literal(char* node_val, int base, int seen_point)
memmove(point, point+1, fraclen+1); memmove(point, point+1, fraclen+1);
lit = rb_rational_new(compile_numeric_literal(val, base), rb_int_positive_pow(10, fraclen)); 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)); lit = rb_rational_raw1(compile_numeric_literal(val, base));
} }

View File

@ -410,12 +410,12 @@ rb_threadptr_join_list_wakeup(rb_thread_t *thread)
rb_threadptr_interrupt(target_thread); rb_threadptr_interrupt(target_thread);
switch (target_thread->status) { switch (target_thread->status) {
case THREAD_STOPPED: case THREAD_STOPPED:
case THREAD_STOPPED_FOREVER: case THREAD_STOPPED_FOREVER:
target_thread->status = THREAD_RUNNABLE; target_thread->status = THREAD_RUNNABLE;
break; break;
default: default:
break; break;
} }
} }
} }

View File

@ -552,14 +552,14 @@ static enum thread_sched_waiting_flag
kqueue_translate_filter_to_flags(int16_t filter) kqueue_translate_filter_to_flags(int16_t filter)
{ {
switch (filter) { switch (filter) {
case EVFILT_READ: case EVFILT_READ:
return thread_sched_waiting_io_read; return thread_sched_waiting_io_read;
case EVFILT_WRITE: case EVFILT_WRITE:
return thread_sched_waiting_io_write; return thread_sched_waiting_io_write;
case EVFILT_TIMER: case EVFILT_TIMER:
return thread_sched_waiting_timeout; return thread_sched_waiting_timeout;
default: default:
rb_bug("kevent filter:%d not supported", filter); 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); RUBY_DEBUG_LOG("failed (%d)", errno);
switch (errno) { switch (errno) {
case EBADF: case EBADF:
// the fd is closed? // the fd is closed?
case EINTR: case EINTR:
// signal received? is there a sensible way to handle this? // signal received? is there a sensible way to handle this?
default: default:
perror("kevent"); perror("kevent");
rb_bug("register/kevent failed(fd:%d, errno:%d)", fd, errno); rb_bug("register/kevent failed(fd:%d, errno:%d)", fd, errno);
} }
} }
RUBY_DEBUG_LOG("kevent(add, fd:%d) success", fd); RUBY_DEBUG_LOG("kevent(add, fd:%d) success", fd);
@ -921,7 +921,8 @@ timer_thread_polling(rb_vm_t *vm)
// wakeup timerthread // wakeup timerthread
RUBY_DEBUG_LOG("comm from fd:%d", timer_th.comm_fds[1]); RUBY_DEBUG_LOG("comm from fd:%d", timer_th.comm_fds[1]);
consume_communication_pipe(timer_th.comm_fds[0]); consume_communication_pipe(timer_th.comm_fds[0]);
} else { }
else {
// wakeup specific thread by IO // wakeup specific thread by IO
RUBY_DEBUG_LOG("io event. wakeup_th:%u event:%s%s", RUBY_DEBUG_LOG("io event. wakeup_th:%u event:%s%s",
rb_th_serial(th), rb_th_serial(th),
@ -940,7 +941,8 @@ timer_thread_polling(rb_vm_t *vm)
th->sched.waiting_reason.data.result = filter; th->sched.waiting_reason.data.result = filter;
timer_thread_wakeup_thread(th); timer_thread_wakeup_thread(th);
} else { }
else {
// already released // already released
} }
} }

View File

@ -216,7 +216,8 @@ rb_mod_set_temporary_name(VALUE mod, VALUE name)
if (NIL_P(name)) { if (NIL_P(name)) {
// Set the temporary classpath to NULL (anonymous): // Set the temporary classpath to NULL (anonymous):
RCLASS_SET_CLASSPATH(mod, 0, FALSE); RCLASS_SET_CLASSPATH(mod, 0, FALSE);
} else { }
else {
// Ensure the name is a string: // Ensure the name is a string:
StringValue(name); StringValue(name);

View File

@ -551,7 +551,8 @@ setup_parameters_complex(rb_execution_context_t * const ec, const rb_iseq_t * co
arg_rest_dup(args); arg_rest_dup(args);
rb_ary_push(args->rest, converted_keyword_hash); rb_ary_push(args->rest, converted_keyword_hash);
keyword_hash = Qnil; keyword_hash = Qnil;
} else { }
else {
keyword_hash = converted_keyword_hash; keyword_hash = converted_keyword_hash;
} }

View File

@ -5884,7 +5884,8 @@ rb_vm_opt_getconstant_path(rb_execution_context_t *ec, rb_control_frame_t *const
val = ice->value; val = ice->value;
VM_ASSERT(val == vm_get_ev_const_chain(ec, segments)); VM_ASSERT(val == vm_get_ev_const_chain(ec, segments));
} else { }
else {
ruby_vm_constant_cache_misses++; ruby_vm_constant_cache_misses++;
val = vm_get_ev_const_chain(ec, segments); val = vm_get_ev_const_chain(ec, segments);
vm_ic_track_const_chain(GET_CFP(), ic, segments); vm_ic_track_const_chain(GET_CFP(), ic, segments);

View File

@ -1767,7 +1767,8 @@ rb_postponed_job_preregister(unsigned int flags, rb_postponed_job_func_t func, v
* datas being written */ * datas being written */
RUBY_ATOMIC_PTR_EXCHANGE(pjq->table[i].data, data); RUBY_ATOMIC_PTR_EXCHANGE(pjq->table[i].data, data);
return (rb_postponed_job_handle_t)i; return (rb_postponed_job_handle_t)i;
} else { }
else {
/* Try the next slot if this one already has a func in it */ /* Try the next slot if this one already has a func in it */
continue; continue;
} }