Skip to content

Commit c718bdd

Browse files
committed
Merge remote-tracking branch 'official/master' into mmtk
2 parents 5077413 + ee3da37 commit c718bdd

File tree

120 files changed

+1679
-1103
lines changed

Some content is hidden

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

120 files changed

+1679
-1103
lines changed

.appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ skip_commits:
1717
- '**/*.md'
1818
- '**/*.rdoc'
1919
- '**/.document'
20+
- '**/*.[1-8]'
21+
- '**/*.ronn'
2022
environment:
2123
ruby_version: "24-%Platform%"
2224
matrix:

.cirrus.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010

1111
task:
1212
name: Arm64 Graviton2 / $CC
13-
skip: "changesIncludeOnly('doc/**', '**.{md,rdoc}', '.document')"
13+
skip: "changesIncludeOnly('doc/**', '**.{md,rdoc,ronn,[1-8]}', '.document')"
1414
arm_container:
1515
# We use the arm64 images at https://github.com/ruby/ruby-ci-image/pkgs/container/ruby-ci-image .
1616
image: ghcr.io/ruby/ruby-ci-image:$CC
@@ -66,7 +66,7 @@ task:
6666
yjit_task:
6767
name: Arm64 Graviton2 / $CC YJIT
6868
auto_cancellation: $CIRRUS_BRANCH != 'master'
69-
skip: "changesIncludeOnly('doc/**', '**.{md,rdoc}')"
69+
skip: "changesIncludeOnly('doc/**', '**.{md,rdoc,ronn,[1-8]}', '.document')"
7070
arm_container:
7171
# We use the arm64 images at https://github.com/ruby/ruby-ci-image/pkgs/container/ruby-ci-image .
7272
image: ghcr.io/ruby/ruby-ci-image:$CC

NEWS.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,21 @@ Note: We're only listing outstanding class updates.
115115
STDIN.read # => Blocking operation timed out! (IO::TimeoutError)
116116
```
117117
118+
* Class
119+
* `Class#attached_object`, which returns the object for which
120+
the receiver is the singleton class. Raises `TypeError` if the
121+
receiver is not a singleton class.
122+
[[Feature #12084]]
123+
124+
```ruby
125+
class Foo; end
126+
127+
Foo.singleton_class.attached_object #=> Foo
128+
Foo.new.singleton_class.attached_object #=> #<Foo:0x000000010491a370>
129+
Foo.attached_object #=> TypeError: `Foo' is not a singleton class
130+
nil.singleton_class.attached_object #=> TypeError: `NilClass' is not a singleton class
131+
```
132+
118133
* Data
119134
* New core class to represent simple immutable value object. The class is
120135
similar to `Struct` and partially shares an implementation, but has more
@@ -169,6 +184,9 @@ Note: We're only listing outstanding class updates.
169184
* Refinement
170185
* Refinement#refined_class has been added. [[Feature #12737]]
171186

187+
* RubyVM::AbstractSyntaxTree
188+
* Add `error_tolerant` option for `parse`, `parse_file` and `of`. [[Feature #19013]]
189+
172190
* Set
173191
* Set is now available as a built-in class without the need for `require "set"`. [[Feature #16989]]
174192
It is currently autoloaded via the `Set` constant or a call to `Enumerable#to_set`.
@@ -223,7 +241,7 @@ Note: We're only listing outstanding class updates.
223241
* irb 1.4.2
224242
* json 2.6.2
225243
* logger 1.5.1
226-
* net-http 0.2.2
244+
* net-http 0.3.0
227245
* net-protocol 0.1.3
228246
* openssl 3.1.0.pre
229247
* ostruct 0.5.5
@@ -244,7 +262,7 @@ Note: We're only listing outstanding class updates.
244262
* net-smtp 0.3.2
245263
* rbs 2.7.0
246264
* typeprof 0.21.3
247-
* debug 1.6.2
265+
* debug 1.6.3
248266
* The following default gems are now bundled gems.
249267

250268
## Compatibility issues
@@ -323,6 +341,7 @@ The following deprecated APIs are removed.
323341
## Miscellaneous changes
324342

325343
[Feature #12005]: https://bugs.ruby-lang.org/issues/12005
344+
[Feature #12084]: https://bugs.ruby-lang.org/issues/12084
326345
[Feature #12655]: https://bugs.ruby-lang.org/issues/12655
327346
[Feature #12737]: https://bugs.ruby-lang.org/issues/12737
328347
[Feature #13110]: https://bugs.ruby-lang.org/issues/13110

addr2line.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,11 @@ typedef struct {
869869
int type;
870870
} DebugInfoValue;
871871

872-
/* TODO: Big Endian */
872+
#if defined(WORDS_BIGENDIAN)
873+
#define MERGE_2INTS(a,b,sz) (((uint64_t)(a)<<sz)|(b))
874+
#else
873875
#define MERGE_2INTS(a,b,sz) (((uint64_t)(b)<<sz)|(a))
876+
#endif
874877

875878
static uint16_t
876879
get_uint16(const uint8_t *p)

class.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,6 @@ class_alloc(VALUE flags, VALUE klass)
208208

209209
#if USE_RVARGC
210210
memset(RCLASS_EXT(obj), 0, sizeof(rb_classext_t));
211-
# if SIZEOF_SERIAL_T != SIZEOF_VALUE
212-
RCLASS(obj)->class_serial_ptr = ZALLOC(rb_serial_t);
213-
# endif
214211
#else
215212
obj->ptr = ZALLOC(rb_classext_t);
216213
#endif
@@ -226,7 +223,6 @@ class_alloc(VALUE flags, VALUE klass)
226223
RCLASS_MODULE_SUBCLASSES(obj) = NULL;
227224
*/
228225
RCLASS_SET_ORIGIN((VALUE)obj, (VALUE)obj);
229-
RCLASS_SERIAL(obj) = rb_next_class_serial();
230226
RB_OBJ_WRITE(obj, &RCLASS_REFINED_CLASS(obj), Qnil);
231227
RCLASS_ALLOCATOR(obj) = 0;
232228

@@ -1589,6 +1585,33 @@ rb_class_subclasses(VALUE klass)
15891585
return class_descendants(klass, true);
15901586
}
15911587

1588+
/*
1589+
* call-seq:
1590+
* attached_object -> object
1591+
*
1592+
* Returns the object for which the receiver is the singleton class.
1593+
*
1594+
* Raises an TypeError if the class is not a singleton class.
1595+
*
1596+
* class Foo; end
1597+
*
1598+
* Foo.singleton_class.attached_object #=> Foo
1599+
* Foo.attached_object #=> TypeError: `Foo' is not a singleton class
1600+
* Foo.new.singleton_class.attached_object #=> #<Foo:0x000000010491a370>
1601+
* TrueClass.attached_object #=> TypeError: `TrueClass' is not a singleton class
1602+
* NilClass.attached_object #=> TypeError: `NilClass' is not a singleton class
1603+
*/
1604+
1605+
VALUE
1606+
rb_class_attached_object(VALUE klass)
1607+
{
1608+
if (!FL_TEST(klass, FL_SINGLETON)) {
1609+
rb_raise(rb_eTypeError, "`%"PRIsVALUE"' is not a singleton class", klass);
1610+
}
1611+
1612+
return rb_attr_get(klass, id_attached);
1613+
}
1614+
15921615
static void
15931616
ins_methods_push(st_data_t name, st_data_t ary)
15941617
{
@@ -2116,9 +2139,7 @@ singleton_class_of(VALUE obj)
21162139
klass = METACLASS_OF(obj);
21172140
if (!(FL_TEST(klass, FL_SINGLETON) &&
21182141
rb_attr_get(klass, id_attached) == obj)) {
2119-
rb_serial_t serial = RCLASS_SERIAL(klass);
21202142
klass = rb_make_metaclass(obj, klass);
2121-
RCLASS_SERIAL(klass) = serial;
21222143
}
21232144

21242145
RB_FL_SET_RAW(klass, RB_OBJ_FROZEN_RAW(obj));

common.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16771,6 +16771,7 @@ version.$(OBJEXT): $(hdrdir)/ruby.h
1677116771
version.$(OBJEXT): $(hdrdir)/ruby/ruby.h
1677216772
version.$(OBJEXT): $(hdrdir)/ruby/version.h
1677316773
version.$(OBJEXT): $(top_srcdir)/internal/array.h
16774+
version.$(OBJEXT): $(top_srcdir)/internal/cmdlineopt.h
1677416775
version.$(OBJEXT): $(top_srcdir)/internal/compilers.h
1677516776
version.$(OBJEXT): $(top_srcdir)/internal/gc.h
1677616777
version.$(OBJEXT): $(top_srcdir)/internal/imemo.h

compile.c

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12157,6 +12157,40 @@ ibf_load_iseq_each(struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
1215712157
const char catch_except_p = (char)ibf_load_small_value(load, &reading_pos);
1215812158
const bool builtin_inline_p = (bool)ibf_load_small_value(load, &reading_pos);
1215912159

12160+
// setup fname and dummy frame
12161+
VALUE path = ibf_load_object(load, location_pathobj_index);
12162+
{
12163+
VALUE realpath = Qnil;
12164+
12165+
if (RB_TYPE_P(path, T_STRING)) {
12166+
realpath = path = rb_fstring(path);
12167+
}
12168+
else if (RB_TYPE_P(path, T_ARRAY)) {
12169+
VALUE pathobj = path;
12170+
if (RARRAY_LEN(pathobj) != 2) {
12171+
rb_raise(rb_eRuntimeError, "path object size mismatch");
12172+
}
12173+
path = rb_fstring(RARRAY_AREF(pathobj, 0));
12174+
realpath = RARRAY_AREF(pathobj, 1);
12175+
if (!NIL_P(realpath)) {
12176+
if (!RB_TYPE_P(realpath, T_STRING)) {
12177+
rb_raise(rb_eArgError, "unexpected realpath %"PRIxVALUE
12178+
"(%x), path=%+"PRIsVALUE,
12179+
realpath, TYPE(realpath), path);
12180+
}
12181+
realpath = rb_fstring(realpath);
12182+
}
12183+
}
12184+
else {
12185+
rb_raise(rb_eRuntimeError, "unexpected path object");
12186+
}
12187+
rb_iseq_pathobj_set(iseq, path, realpath);
12188+
}
12189+
12190+
// push dummy frame
12191+
rb_execution_context_t *ec = GET_EC();
12192+
VALUE dummy_frame = rb_vm_push_frame_fname(ec, path);
12193+
1216012194
#undef IBF_BODY_OFFSET
1216112195

1216212196
load_body->type = type;
@@ -12225,40 +12259,16 @@ ibf_load_iseq_each(struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
1222512259
load->current_buffer = &load->global_buffer;
1222612260
#endif
1222712261

12228-
{
12229-
VALUE realpath = Qnil, path = ibf_load_object(load, location_pathobj_index);
12230-
if (RB_TYPE_P(path, T_STRING)) {
12231-
realpath = path = rb_fstring(path);
12232-
}
12233-
else if (RB_TYPE_P(path, T_ARRAY)) {
12234-
VALUE pathobj = path;
12235-
if (RARRAY_LEN(pathobj) != 2) {
12236-
rb_raise(rb_eRuntimeError, "path object size mismatch");
12237-
}
12238-
path = rb_fstring(RARRAY_AREF(pathobj, 0));
12239-
realpath = RARRAY_AREF(pathobj, 1);
12240-
if (!NIL_P(realpath)) {
12241-
if (!RB_TYPE_P(realpath, T_STRING)) {
12242-
rb_raise(rb_eArgError, "unexpected realpath %"PRIxVALUE
12243-
"(%x), path=%+"PRIsVALUE,
12244-
realpath, TYPE(realpath), path);
12245-
}
12246-
realpath = rb_fstring(realpath);
12247-
}
12248-
}
12249-
else {
12250-
rb_raise(rb_eRuntimeError, "unexpected path object");
12251-
}
12252-
rb_iseq_pathobj_set(iseq, path, realpath);
12253-
}
12254-
1225512262
RB_OBJ_WRITE(iseq, &load_body->location.base_label, ibf_load_location_str(load, location_base_label_index));
1225612263
RB_OBJ_WRITE(iseq, &load_body->location.label, ibf_load_location_str(load, location_label_index));
1225712264

1225812265
#if IBF_ISEQ_ENABLE_LOCAL_BUFFER
1225912266
load->current_buffer = saved_buffer;
1226012267
#endif
1226112268
verify_call_cache(iseq);
12269+
12270+
RB_GC_GUARD(dummy_frame);
12271+
rb_vm_pop_frame(ec);
1226212272
}
1226312273

1226412274
struct ibf_dump_iseq_list_arg

complex.c

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -421,15 +421,22 @@ f_complex_new_bang2(VALUE klass, VALUE x, VALUE y)
421421
return nucomp_s_new_internal(klass, x, y);
422422
}
423423

424-
inline static void
424+
WARN_UNUSED_RESULT(inline static VALUE nucomp_real_check(VALUE num));
425+
inline static VALUE
425426
nucomp_real_check(VALUE num)
426427
{
427428
if (!RB_INTEGER_TYPE_P(num) &&
428429
!RB_FLOAT_TYPE_P(num) &&
429430
!RB_TYPE_P(num, T_RATIONAL)) {
431+
if (RB_TYPE_P(num, T_COMPLEX) && nucomp_real_p(num)) {
432+
VALUE real = RCOMPLEX(num)->real;
433+
assert(!RB_TYPE_P(real, T_COMPLEX));
434+
return real;
435+
}
430436
if (!k_numeric_p(num) || !f_real_p(num))
431437
rb_raise(rb_eTypeError, "not a real");
432438
}
439+
return num;
433440
}
434441

435442
inline static VALUE
@@ -480,16 +487,16 @@ nucomp_s_new(int argc, VALUE *argv, VALUE klass)
480487

481488
switch (rb_scan_args(argc, argv, "11", &real, &imag)) {
482489
case 1:
483-
nucomp_real_check(real);
490+
real = nucomp_real_check(real);
484491
imag = ZERO;
485492
break;
486493
default:
487-
nucomp_real_check(real);
488-
nucomp_real_check(imag);
494+
real = nucomp_real_check(real);
495+
imag = nucomp_real_check(imag);
489496
break;
490497
}
491498

492-
return nucomp_s_canonicalize_internal(klass, real, imag);
499+
return nucomp_s_new_internal(klass, real, imag);
493500
}
494501

495502
inline static VALUE
@@ -611,16 +618,8 @@ m_sin(VALUE x)
611618
}
612619

613620
static VALUE
614-
f_complex_polar(VALUE klass, VALUE x, VALUE y)
621+
f_complex_polar_real(VALUE klass, VALUE x, VALUE y)
615622
{
616-
if (RB_TYPE_P(x, T_COMPLEX)) {
617-
get_dat1(x);
618-
x = dat->real;
619-
}
620-
if (RB_TYPE_P(y, T_COMPLEX)) {
621-
get_dat1(y);
622-
y = dat->real;
623-
}
624623
if (f_zero_p(x) || f_zero_p(y)) {
625624
return nucomp_s_new_internal(klass, x, RFLOAT_0);
626625
}
@@ -656,6 +655,14 @@ f_complex_polar(VALUE klass, VALUE x, VALUE y)
656655
f_mul(x, m_sin(y)));
657656
}
658657

658+
static VALUE
659+
f_complex_polar(VALUE klass, VALUE x, VALUE y)
660+
{
661+
x = nucomp_real_check(x);
662+
y = nucomp_real_check(y);
663+
return f_complex_polar_real(klass, x, y);
664+
}
665+
659666
#ifdef HAVE___COSPI
660667
# define cospi(x) __cospi(x)
661668
#else
@@ -704,16 +711,15 @@ nucomp_s_polar(int argc, VALUE *argv, VALUE klass)
704711
{
705712
VALUE abs, arg;
706713

707-
switch (rb_scan_args(argc, argv, "11", &abs, &arg)) {
708-
case 1:
709-
nucomp_real_check(abs);
710-
return nucomp_s_new_internal(klass, abs, ZERO);
711-
default:
712-
nucomp_real_check(abs);
713-
nucomp_real_check(arg);
714-
break;
714+
argc = rb_scan_args(argc, argv, "11", &abs, &arg);
715+
abs = nucomp_real_check(abs);
716+
if (argc == 2) {
717+
arg = nucomp_real_check(arg);
718+
}
719+
else {
720+
arg = ZERO;
715721
}
716-
return f_complex_polar(klass, abs, arg);
722+
return f_complex_polar_real(klass, abs, arg);
717723
}
718724

719725
/*

configure.ac

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,8 +1903,8 @@ AS_CASE(["${target_cpu}-${target_os}:${target_archs}"],
19031903
[universal-darwin*:*ppc*], [
19041904
AC_LIBSOURCES(alloca.c)
19051905
AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.${ac_objext}])
1906-
RUBY_DEFINE_IF([defined __powerpc__], C_ALLOCA, 1)
1907-
RUBY_DEFINE_IF([defined __powerpc__], alloca, alloca)
1906+
RUBY_DEFINE_IF([defined __POWERPC__], C_ALLOCA, 1) # Darwin defines __POWERPC__ for ppc and ppc64 both
1907+
RUBY_DEFINE_IF([defined __POWERPC__], alloca, alloca)
19081908
],
19091909
[
19101910
AC_FUNC_ALLOCA
@@ -2574,10 +2574,13 @@ AS_CASE([$coroutine_type], [yes|''], [
25742574
[arm64-darwin*], [
25752575
coroutine_type=arm64
25762576
],
2577-
[powerpc-darwin*], [
2577+
# Correct target name is powerpc*-, but Ruby seems to prefer ppc*-.
2578+
# Notice that Darwin PPC ABI differs from AIX and ELF.
2579+
# Adding PPC targets for AIX, *BSD and *Linux will require separate implementations.
2580+
[powerpc-darwin*|ppc-darwin*], [
25782581
coroutine_type=ppc
25792582
],
2580-
[powerpc64-darwin*], [
2583+
[powerpc64-darwin*|ppc64-darwin*], [
25812584
coroutine_type=ppc64
25822585
],
25832586
[x*64-linux*], [
@@ -3754,12 +3757,12 @@ AS_CASE(["${YJIT_SUPPORT}"],
37543757
],
37553758
[dev], [
37563759
rb_rust_target_subdir=debug
3757-
CARGO_BUILD_ARGS='--features stats,disasm,asm_comments'
3760+
CARGO_BUILD_ARGS='--features stats,disasm'
37583761
AC_DEFINE(RUBY_DEBUG, 1)
37593762
],
37603763
[dev_nodebug], [
37613764
rb_rust_target_subdir=dev_nodebug
3762-
CARGO_BUILD_ARGS='--profile dev_nodebug --features stats,disasm,asm_comments'
3765+
CARGO_BUILD_ARGS='--profile dev_nodebug --features stats,disasm'
37633766
],
37643767
[stats], [
37653768
rb_rust_target_subdir=stats

0 commit comments

Comments
 (0)