[前][次][番号順一覧][スレッド一覧]

ruby-changes:55728

From: Aaron <ko1@a...>
Date: Wed, 15 May 2019 12:43:34 +0900 (JST)
Subject: [ruby-changes:55728] Aaron Patterson: 0cc893d01d (trunk): Static symbols can't be moved (they are not RValue)

https://git.ruby-lang.org/ruby.git/commit/?id=0cc893d01d

From 0cc893d01d1c4a6b36f01a25587a121261601697 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Tue, 14 May 2019 20:41:31 -0700
Subject: Static symbols can't be moved (they are not RValue)

This is my mistake, I thought they were regular objects, but apparently
they are not.  We don't need to pin them.

Revert "Symbols can move so only cache IDs"

This reverts commit 672ee5f6ed5a6840a3be9150b6721a5ee8f8766b.

diff --git a/enumerator.c b/enumerator.c
index facecdf..76560fa 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -111,7 +111,7 @@ static VALUE rb_cLazy; https://github.com/ruby/ruby/blob/trunk/enumerator.c#L111
 static ID id_rewind, id_new, id_to_enum;
 static ID id_next, id_result, id_receiver, id_arguments, id_memo, id_method, id_force;
 static ID id_begin, id_end, id_step, id_exclude_end, id_to_proc;
-static ID id_cycle, id_yield;
+static VALUE sym_each, sym_cycle, sym_yield;
 
 #define id_call idCall
 #define id_each idEach
@@ -312,7 +312,7 @@ proc_entry_ptr(VALUE proc_entry) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L312
 static VALUE
 obj_to_enum(int argc, VALUE *argv, VALUE obj)
 {
-    VALUE enumerator, meth = ID2SYM(id_each);
+    VALUE enumerator, meth = sym_each;
 
     if (argc > 0) {
 	--argc;
@@ -404,7 +404,7 @@ enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, const VALUE *ar https://github.com/ruby/ruby/blob/trunk/enumerator.c#L404
 static VALUE
 enumerator_initialize(int argc, VALUE *argv, VALUE obj)
 {
-    VALUE recv, meth = ID2SYM(id_each);
+    VALUE recv, meth = sym_each;
     VALUE size = Qnil;
 
     if (rb_block_given_p()) {
@@ -1303,7 +1303,7 @@ yielder_yield_push(VALUE obj, VALUE arg) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1303
 static VALUE
 yielder_to_proc(VALUE obj)
 {
-    VALUE method = rb_obj_method(obj, ID2SYM(id_yield));
+    VALUE method = rb_obj_method(obj, sym_yield);
 
     return rb_funcall(method, id_to_proc, 0);
 }
@@ -1679,7 +1679,7 @@ lazy_initialize(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1679
     }
     generator = generator_allocate(rb_cGenerator);
     rb_block_call(generator, id_initialize, 0, 0, lazy_init_block_i, obj);
-    enumerator_init(self, generator, ID2SYM(id_each), 0, 0, 0, size);
+    enumerator_init(self, generator, sym_each, 0, 0, 0, size);
     rb_ivar_set(self, id_receiver, obj);
 
     return self;
@@ -1794,7 +1794,7 @@ lazy_add_method(VALUE obj, int argc, VALUE *argv, VALUE args, VALUE memo, https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1794
 static VALUE
 enumerable_lazy(VALUE obj)
 {
-    VALUE result = lazy_to_enum_i(obj, ID2SYM(id_each), 0, 0, lazyenum_size);
+    VALUE result = lazy_to_enum_i(obj, sym_each, 0, 0, lazyenum_size);
     /* Qfalse indicates that the Enumerator::Lazy has no method name */
     rb_ivar_set(result, id_method, Qfalse);
     return result;
@@ -1833,7 +1833,7 @@ lazy_to_enum_i(VALUE obj, VALUE meth, int argc, const VALUE *argv, rb_enumerator https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1833
 static VALUE
 lazy_to_enum(int argc, VALUE *argv, VALUE self)
 {
-    VALUE lazy, meth = ID2SYM(id_each);
+    VALUE lazy, meth = sym_each;
 
     if (argc > 0) {
 	--argc;
@@ -2308,7 +2308,7 @@ lazy_take(VALUE obj, VALUE n) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L2308
     }
 
     if (len == 0) {
-       argv[0] = ID2SYM(id_cycle);
+       argv[0] = sym_cycle;
        argv[1] = INT2NUM(0);
        argc = 2;
     }
@@ -2397,7 +2397,7 @@ lazy_drop(VALUE obj, VALUE n) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L2397
 {
     long len = NUM2LONG(n);
     VALUE argv[2];
-    argv[0] = ID2SYM(id_each);
+    argv[0] = sym_each;
     argv[1] = n;
 
     if (len < 0) {
@@ -3650,8 +3650,9 @@ Init_Enumerator(void) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L3650
     id_step = rb_intern("step");
     id_exclude_end = rb_intern("exclude_end");
     id_to_proc = rb_intern("to_proc");
-    id_cycle = rb_intern("cycle");
-    id_yield = rb_intern("yield");
+    sym_each = ID2SYM(id_each);
+    sym_cycle = ID2SYM(rb_intern("cycle"));
+    sym_yield = ID2SYM(rb_intern("yield"));
 
     InitVM(Enumerator);
 }
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]