Skip to content

Commit 430c826

Browse files
committed
New upstream version 2.5.4~tmp1
1 parent cd28c99 commit 430c826

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2781
-987
lines changed

ChangeLog

Lines changed: 647 additions & 2 deletions
Large diffs are not rendered by default.

array.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3241,6 +3241,7 @@ static VALUE
32413241
rb_ary_reject_bang(VALUE ary)
32423242
{
32433243
RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length);
3244+
rb_ary_modify(ary);
32443245
return ary_reject_bang(ary);
32453246
}
32463247

bootstraptest/test_literal.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,24 @@
223223
:ok
224224
}
225225

226+
assert_equal 'ok', %q{ # Bug #15536
227+
eval <<-END
228+
{
229+
**{
230+
a0: nil, a1: nil, a2: nil, a3: nil, a4: nil, a5: nil, a6: nil, a7: nil, a8: nil,
231+
},
232+
a0: nil, a1: nil, a2: nil, a3: nil, a4: nil, a5: nil, a6: nil, a7: nil, a8: nil,
233+
**{
234+
c: nil
235+
},
236+
b0: nil, b1: nil, b2: nil, b3: nil, b4: nil, b5: nil, b6: nil, b7: nil, b8: nil,
237+
b9: nil, b10: nil, b11: nil, b12: nil, b13: nil, b14: nil, b15: nil, b16: nil,
238+
b17: nil, b18: nil, b19: nil, b20: nil, b21: nil,
239+
}
240+
END
241+
:ok
242+
}
243+
226244
assert_equal 'ok', %q{
227245
[print(:ok), exit] # void literal with side-effect
228246
:dummy

compile.c

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,7 +2651,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
26512651
}
26522652
else if (!iseq_pop_newarray(iseq, pobj)) {
26532653
pobj = new_insn_core(iseq, pobj->insn_info.line_no, BIN(pop), 0, NULL);
2654-
ELEM_INSERT_NEXT(&iobj->link, &pobj->link);
2654+
ELEM_INSERT_PREV(&iobj->link, &pobj->link);
26552655
}
26562656
if (cond) {
26572657
if (prev_dup) {
@@ -4580,6 +4580,7 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
45804580
DECL_ANCHOR(else_seq);
45814581
LABEL *then_label, *else_label, *end_label;
45824582
VALUE branches = 0;
4583+
int ci_size, ci_kw_size;
45834584

45844585
INIT_ANCHOR(cond_seq);
45854586
INIT_ANCHOR(then_seq);
@@ -4590,8 +4591,22 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
45904591

45914592
compile_branch_condition(iseq, cond_seq, node->nd_cond,
45924593
then_label, else_label);
4594+
4595+
ci_size = iseq->body->ci_size;
4596+
ci_kw_size = iseq->body->ci_kw_size;
45934597
CHECK(COMPILE_(then_seq, "then", node_body, popped));
4598+
if (!then_label->refcnt) {
4599+
iseq->body->ci_size = ci_size;
4600+
iseq->body->ci_kw_size = ci_kw_size;
4601+
}
4602+
4603+
ci_size = iseq->body->ci_size;
4604+
ci_kw_size = iseq->body->ci_kw_size;
45944605
CHECK(COMPILE_(else_seq, "else", node_else, popped));
4606+
if (!else_label->refcnt) {
4607+
iseq->body->ci_size = ci_size;
4608+
iseq->body->ci_kw_size = ci_kw_size;
4609+
}
45954610

45964611
ADD_SEQ(ret, cond_seq);
45974612

@@ -8635,7 +8650,15 @@ ibf_load_iseq_each(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t of
86358650
rb_raise(rb_eRuntimeError, "path object size mismatch");
86368651
}
86378652
path = rb_fstring(RARRAY_AREF(pathobj, 0));
8638-
realpath = rb_fstring(RARRAY_AREF(pathobj, 1));
8653+
realpath = RARRAY_AREF(pathobj, 1);
8654+
if (!NIL_P(realpath)) {
8655+
if (!RB_TYPE_P(realpath, T_STRING)) {
8656+
rb_raise(rb_eArgError, "unexpected realpath %"PRIxVALUE
8657+
"(%x), path=%+"PRIsVALUE,
8658+
realpath, TYPE(realpath), path);
8659+
}
8660+
realpath = rb_fstring(realpath);
8661+
}
86398662
}
86408663
else {
86418664
rb_raise(rb_eRuntimeError, "unexpected path object");
@@ -8899,9 +8922,9 @@ static void
88998922
ibf_dump_object_regexp(struct ibf_dump *dump, VALUE obj)
89008923
{
89018924
struct ibf_object_regexp regexp;
8902-
regexp.srcstr = RREGEXP_SRC(obj);
8925+
VALUE srcstr = RREGEXP_SRC(obj);
89038926
regexp.option = (char)rb_reg_options(obj);
8904-
regexp.srcstr = (long)ibf_dump_object(dump, regexp.srcstr);
8927+
regexp.srcstr = (long)ibf_dump_object(dump, srcstr);
89058928
IBF_WV(regexp);
89068929
}
89078930

@@ -9328,7 +9351,7 @@ ibf_dump_setup(struct ibf_dump *dump, VALUE dumper_obj)
93289351
}
93299352

93309353
VALUE
9331-
iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt)
9354+
rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt)
93329355
{
93339356
struct ibf_dump *dump;
93349357
struct ibf_header header = {{0}};
@@ -9387,7 +9410,7 @@ ibf_iseq_list(const struct ibf_load *load)
93879410
}
93889411

93899412
void
9390-
ibf_load_iseq_complete(rb_iseq_t *iseq)
9413+
rb_ibf_load_iseq_complete(rb_iseq_t *iseq)
93919414
{
93929415
struct ibf_load *load = RTYPEDDATA_DATA(iseq->aux.loader.obj);
93939416
rb_iseq_t *prev_src_iseq = load->iseq;
@@ -9402,7 +9425,7 @@ ibf_load_iseq_complete(rb_iseq_t *iseq)
94029425
const rb_iseq_t *
94039426
rb_iseq_complete(const rb_iseq_t *iseq)
94049427
{
9405-
ibf_load_iseq_complete((rb_iseq_t *)iseq);
9428+
rb_ibf_load_iseq_complete((rb_iseq_t *)iseq);
94069429
return iseq;
94079430
}
94089431
#endif
@@ -9429,7 +9452,7 @@ ibf_load_iseq(const struct ibf_load *load, const rb_iseq_t *index_iseq)
94299452
rb_ary_store(load->iseq_list, iseq_index, (VALUE)iseq);
94309453

94319454
#if !USE_LAZY_LOAD
9432-
ibf_load_iseq_complete(iseq);
9455+
rb_ibf_load_iseq_complete(iseq);
94339456
#endif /* !USE_LAZY_LOAD */
94349457

94359458
if (load->iseq) {
@@ -9504,23 +9527,23 @@ static const rb_data_type_t ibf_load_type = {
95049527
};
95059528

95069529
const rb_iseq_t *
9507-
iseq_ibf_load(VALUE str)
9530+
rb_iseq_ibf_load(VALUE str)
95089531
{
95099532
struct ibf_load *load;
9510-
const rb_iseq_t *iseq;
9533+
rb_iseq_t *iseq;
95119534
VALUE loader_obj = TypedData_Make_Struct(0, struct ibf_load, &ibf_load_type, load);
95129535

95139536
ibf_load_setup(load, loader_obj, str);
95149537
iseq = ibf_load_iseq(load, 0);
95159538

9516-
iseq_init_trace(iseq);
9539+
rb_iseq_init_trace(iseq);
95179540

95189541
RB_GC_GUARD(loader_obj);
95199542
return iseq;
95209543
}
95219544

95229545
VALUE
9523-
iseq_ibf_load_extra_data(VALUE str)
9546+
rb_iseq_ibf_load_extra_data(VALUE str)
95249547
{
95259548
struct ibf_load *load;
95269549
VALUE loader_obj = TypedData_Make_Struct(0, struct ibf_load, &ibf_load_type, load);

configure

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10652,6 +10652,8 @@ if test "x$ac_cv_header_jemalloc_jemalloc_h" = xyes; then :
1065210652
$as_echo "#define RUBY_ALTERNATIVE_MALLOC_HEADER <jemalloc/jemalloc.h>" >>confdefs.h
1065310653

1065410654

10655+
else
10656+
test x$with_jemalloc = xyes && with_jemalloc=no
1065510657
fi
1065610658

1065710659

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,8 @@ AS_IF([test "x$with_jemalloc" = xyes],[
13191319
[AC_DEFINE(HAVE_LIBJEMALLOC, 1)], [with_jemalloc=no])
13201320
AC_CHECK_HEADER(jemalloc/jemalloc.h, [
13211321
AC_DEFINE(RUBY_ALTERNATIVE_MALLOC_HEADER, [<jemalloc/jemalloc.h>])
1322-
])
1322+
],
1323+
[test x$with_jemalloc = xyes && with_jemalloc=no])
13231324
AS_IF([test "x$with_jemalloc" = xno], [
13241325
AC_CACHE_CHECK([for jemalloc with JEMALLOC_MANGLE], rb_cv_jemalloc_demangle,
13251326
[AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@define JEMALLOC_MANGLE 1

cont.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,6 +1616,7 @@ fiber_store(rb_fiber_t *next_fib, rb_thread_t *th)
16161616
return fib->cont.value;
16171617

16181618
#else /* FIBER_USE_NATIVE */
1619+
fib->cont.saved_ec.machine.stack_end = NULL;
16191620
if (ruby_setjmp(fib->cont.jmpbuf)) {
16201621
/* restored */
16211622
fib = th->ec->fiber_ptr;
@@ -1931,6 +1932,20 @@ fiber_to_s(VALUE fibval)
19311932
return rb_block_to_s(fibval, &proc->block, status_info);
19321933
}
19331934

1935+
#ifdef HAVE_WORKING_FORK
1936+
void
1937+
rb_fiber_atfork(rb_thread_t *th)
1938+
{
1939+
if (th->root_fiber) {
1940+
if (&th->root_fiber->cont.saved_ec != th->ec) {
1941+
th->root_fiber = th->ec->fiber_ptr;
1942+
th->root_fiber->cont.type = ROOT_FIBER_CONTEXT;
1943+
}
1944+
th->root_fiber->prev = 0;
1945+
}
1946+
}
1947+
#endif
1948+
19341949
/*
19351950
* Document-class: FiberError
19361951
*

dir.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
dir.c -
44
5-
$Author: naruse $
5+
$Author: nagachika $
66
created at: Wed Jan 5 09:51:01 JST 1994
77
88
Copyright (C) 1993-2007 Yukihiro Matsumoto
@@ -22,6 +22,10 @@
2222
#include <unistd.h>
2323
#endif
2424

25+
#ifndef O_CLOEXEC
26+
# define O_CLOEXEC 0
27+
#endif
28+
2529
#ifndef USE_OPENDIR_AT
2630
# if defined(HAVE_FDOPENDIR) && defined(HAVE_DIRFD) && \
2731
defined(HAVE_OPENAT) && defined(HAVE_FSTATAT)

eval.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
eval.c -
44
5-
$Author: ko1 $
5+
$Author: nagachika $
66
created at: Thu Jun 10 14:22:17 JST 1993
77
88
Copyright (C) 1993-2007 Yukihiro Matsumoto
@@ -175,6 +175,7 @@ ruby_cleanup(volatile int ex)
175175

176176
step_0: step++;
177177
errs[1] = th->ec->errinfo;
178+
if (THROW_DATA_P(th->ec->errinfo)) th->ec->errinfo = Qnil;
178179
th->ec->safe_level = 0;
179180
ruby_init_stack(&errs[STACK_UPPER(errs, 0, 1)]);
180181

@@ -516,7 +517,7 @@ setup_exception(rb_execution_context_t *ec, int tag, volatile VALUE mesg, VALUE
516517
mesg = rb_obj_dup(mesg);
517518
}
518519
}
519-
if (cause != Qundef) {
520+
if (cause != Qundef && !THROW_DATA_P(cause)) {
520521
exc_setup_cause(mesg, cause);
521522
}
522523
if (NIL_P(bt)) {

ext/-test-/integer/core_ext.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,17 @@ rb_int_to_bignum(VALUE x)
2020
return x;
2121
}
2222

23+
static VALUE
24+
positive_pow(VALUE x, VALUE y)
25+
{
26+
return rb_int_positive_pow(NUM2LONG(x), NUM2ULONG(y));
27+
}
28+
2329
void
2430
Init_core_ext(VALUE klass)
2531
{
2632
rb_define_method(rb_cInteger, "bignum?", int_bignum_p, 0);
2733
rb_define_method(rb_cInteger, "fixnum?", int_fixnum_p, 0);
2834
rb_define_method(rb_cInteger, "to_bignum", rb_int_to_bignum, 0);
35+
rb_define_method(rb_cInteger, "positive_pow", positive_pow, 1);
2936
}

0 commit comments

Comments
 (0)