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

ruby-changes:50275

From: usa <ko1@a...>
Date: Tue, 13 Feb 2018 18:34:41 +0900 (JST)
Subject: [ruby-changes:50275] usa:r62393 (trunk): revert r62392

usa	2018-02-13 18:34:37 +0900 (Tue, 13 Feb 2018)

  New Revision: 62393

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62393

  Log:
    revert r62392
    
    check the declaration of `rb_autoloading_value()` in vm_core.h and the call in
    vm_insnhelper.c, and retry it.

  Modified files:
    trunk/test/ruby/test_autoload.rb
    trunk/variable.c
Index: test/ruby/test_autoload.rb
===================================================================
--- test/ruby/test_autoload.rb	(revision 62392)
+++ test/ruby/test_autoload.rb	(revision 62393)
@@ -245,46 +245,6 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L245
     assert_ruby_status([script], '', '[ruby-core:81016] [Bug #13526]')
   end
 
-  def test_autoload_private_constant
-    Dir.mktmpdir('autoload') do |tmpdir|
-      File.write(tmpdir+"/zzz.rb", "#{<<~"begin;"}\n#{<<~'end;'}")
-      begin;
-        class AutoloadTest
-          ZZZ = :ZZZ
-          private_constant :ZZZ
-        end
-      end;
-      assert_separately(%W[-I #{tmpdir}], "#{<<-"begin;"}\n#{<<-'end;'}")
-      bug = '[ruby-core:85516] [Bug #14469]'
-      begin;
-        class AutoloadTest
-          autoload :ZZZ, "zzz.rb"
-        end
-        assert_raise(NameError, bug) {AutoloadTest::ZZZ}
-      end;
-    end
-  end
-
-  def test_autoload_deprecate_constant
-    Dir.mktmpdir('autoload') do |tmpdir|
-      File.write(tmpdir+"/zzz.rb", "#{<<~"begin;"}\n#{<<~'end;'}")
-      begin;
-        class AutoloadTest
-          ZZZ = :ZZZ
-          deprecate_constant :ZZZ
-        end
-      end;
-      assert_separately(%W[-I #{tmpdir}], "#{<<-"begin;"}\n#{<<-'end;'}")
-      bug = '[ruby-core:85516] [Bug #14469]'
-      begin;
-        class AutoloadTest
-          autoload :ZZZ, "zzz.rb"
-        end
-        assert_warning(/ZZZ is deprecated/, bug) {AutoloadTest::ZZZ}
-      end;
-    end
-  end
-
   def add_autoload(path)
     (@autoload_paths ||= []) << path
     ::Object.class_eval {autoload(:AutoloadTest, path)}
Index: variable.c
===================================================================
--- variable.c	(revision 62392)
+++ variable.c	(revision 62393)
@@ -1854,7 +1854,6 @@ struct autoload_state { https://github.com/ruby/ruby/blob/trunk/variable.c#L1854
 struct autoload_data_i {
     VALUE feature;
     int safe_level;
-    rb_const_flag_t flag;
     VALUE value;
     struct autoload_state *state; /* points to on-stack struct */
 };
@@ -1937,7 +1936,6 @@ rb_autoload_str(VALUE mod, ID id, VALUE https://github.com/ruby/ruby/blob/trunk/variable.c#L1936
     ele->safe_level = rb_safe_level();
     ele->value = Qundef;
     ele->state = 0;
-    ele->flag = CONST_PUBLIC;
     st_insert(tbl, (st_data_t)id, (st_data_t)ad);
 }
 
@@ -2013,7 +2011,7 @@ check_autoload_required(VALUE mod, ID id https://github.com/ruby/ruby/blob/trunk/variable.c#L2011
 }
 
 MJIT_FUNC_EXPORTED int
-rb_autoloading_value(VALUE mod, ID id, VALUE* value, rb_const_flag_t *flag)
+rb_autoloading_value(VALUE mod, ID id, VALUE* value)
 {
     VALUE load;
     struct autoload_data_i *ele;
@@ -2026,9 +2024,6 @@ rb_autoloading_value(VALUE mod, ID id, V https://github.com/ruby/ruby/blob/trunk/variable.c#L2024
 	    if (value) {
 		*value = ele->value;
 	    }
-	    if (flag) {
-		*flag = ele->flag;
-	    }
 	    return 1;
 	}
     }
@@ -2043,14 +2038,13 @@ autoload_defined_p(VALUE mod, ID id) https://github.com/ruby/ruby/blob/trunk/variable.c#L2038
     if (!ce || ce->value != Qundef) {
 	return 0;
     }
-    return !rb_autoloading_value(mod, id, NULL, NULL);
+    return !rb_autoloading_value(mod, id, NULL);
 }
 
 struct autoload_const_set_args {
     VALUE mod;
     ID id;
     VALUE value;
-    rb_const_flag_t flag;
 };
 
 static void const_tbl_update(struct autoload_const_set_args *);
@@ -2097,7 +2091,6 @@ autoload_reset(VALUE arg) https://github.com/ruby/ruby/blob/trunk/variable.c#L2091
 	args.mod = state->mod;
 	args.id = state->id;
 	args.value = state->ele->value;
-	args.flag = state->ele->flag;
 	safe_backup = rb_safe_level();
 	rb_set_safe_level_force(state->ele->safe_level);
 	rb_ensure(autoload_const_set, (VALUE)&args,
@@ -2244,7 +2237,6 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/variable.c#L2237
 rb_const_search(VALUE klass, ID id, int exclude, int recurse, int visibility)
 {
     VALUE value, tmp, av;
-    rb_const_flag_t flag;
     int mod_retry = 0;
 
     tmp = klass;
@@ -2263,7 +2255,7 @@ rb_const_search(VALUE klass, ID id, int https://github.com/ruby/ruby/blob/trunk/variable.c#L2255
 	    if (value == Qundef) {
 		if (am == tmp) break;
 		am = tmp;
-		if (rb_autoloading_value(tmp, id, &av, &flag)) return av;
+		if (rb_autoloading_value(tmp, id, &av)) return av;
 		rb_autoload_load(tmp, id);
 		continue;
 	    }
@@ -2514,7 +2506,7 @@ rb_const_defined_0(VALUE klass, ID id, i https://github.com/ruby/ruby/blob/trunk/variable.c#L2506
 		return (int)Qfalse;
 	    }
 	    if (ce->value == Qundef && !check_autoload_required(tmp, id, 0) &&
-		!rb_autoloading_value(tmp, id, NULL, NULL))
+		    !rb_autoloading_value(tmp, id, 0))
 		return (int)Qfalse;
 
 	    if (exclude && tmp == rb_cObject && klass != rb_cObject) {
@@ -2600,7 +2592,6 @@ rb_const_set(VALUE klass, ID id, VALUE v https://github.com/ruby/ruby/blob/trunk/variable.c#L2592
 	args.mod = klass;
 	args.id = id;
 	args.value = val;
-	args.flag = CONST_PUBLIC;
 	const_tbl_update(&args);
     }
     /*
@@ -2632,21 +2623,6 @@ rb_const_set(VALUE klass, ID id, VALUE v https://github.com/ruby/ruby/blob/trunk/variable.c#L2623
     }
 }
 
-static struct autoload_data_i *
-current_autoload_data(VALUE mod, ID id)
-{
-    struct autoload_data_i *ele;
-    VALUE load = autoload_data(mod, id);
-    if (!load) return 0;
-    ele = check_autoload_data(load);
-    if (!ele) return 0;
-    /* for autoloading thread, keep the defined value to autoloading storage */
-    if (ele->state && (ele->state->thread == rb_thread_current())) {
-	return ele;
-    }
-    return 0;
-}
-
 static void
 const_tbl_update(struct autoload_const_set_args *args)
 {
@@ -2655,15 +2631,19 @@ const_tbl_update(struct autoload_const_s https://github.com/ruby/ruby/blob/trunk/variable.c#L2631
     VALUE val = args->value;
     ID id = args->id;
     struct rb_id_table *tbl = RCLASS_CONST_TBL(klass);
-    rb_const_flag_t visibility = args->flag;
+    rb_const_flag_t visibility = CONST_PUBLIC;
     rb_const_entry_t *ce;
 
     if (rb_id_table_lookup(tbl, id, &value)) {
 	ce = (rb_const_entry_t *)value;
 	if (ce->value == Qundef) {
-	    struct autoload_data_i *ele = current_autoload_data(klass, id);
+	    VALUE load;
+	    struct autoload_data_i *ele;
 
-	    if (ele) {
+	    load = autoload_data(klass, id);
+	    /* for autoloading thread, keep the defined value to autoloading storage */
+	    if (load && (ele = check_autoload_data(load)) && ele->state &&
+			(ele->state->thread == rb_thread_current())) {
 		rb_clear_constant_cache();
 
 		ele->value = val; /* autoload_i is non-WB-protected */
@@ -2752,13 +2732,6 @@ set_const_visibility(VALUE mod, int argc https://github.com/ruby/ruby/blob/trunk/variable.c#L2732
 	if ((ce = rb_const_lookup(mod, id))) {
 	    ce->flag &= ~mask;
 	    ce->flag |= flag;
-	    if (ce->value == Qundef) {
-		struct autoload_data_i *ele = current_autoload_data(mod, id);
-		if (ele) {
-		    ele->flag &= ~mask;
-		    ele->flag |= flag;
-		}
-	    }
 	}
 	else {
 	    if (i > 0) {

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

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