aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog24
-rw-r--r--method.h7
-rw-r--r--test/ruby/test_module.rb14
-rw-r--r--vm_method.c35
4 files changed, 11 insertions, 69 deletions
diff --git a/ChangeLog b/ChangeLog
index 0f5a5c73c7..54dd631a64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,35 +2,11 @@ Tue Nov 17 19:50:06 2015 NAKAMURA Usaku <usa@ruby-lang.org>
* win32/win32.c (fstat): declare for mingw.
-Tue Nov 17 19:32:42 2015 Koichi Sasada <ko1@atdot.net>
-
- * method.h (METHOD_ENTRY_COMPLEMENTED(_SET)): introduced to recognize
- complemented method entries or not. There are some cases that callabe
- method entries do not have defined_class.
-
- * vm_method.c (rb_method_entry_complement_defined_class):
- use METHOD_ENTRY_COMPLEMENTED_SET().
-
Tue Nov 17 19:02:59 2015 NAKAMURA Usaku <usa@ruby-lang.org>
* configure.in (BASERUBY): use Kernel#print instead of Kernel#p because
the baseruby may output CRLF as end of line.
-Tue Nov 17 18:36:52 2015 Koichi Sasada <ko1@atdot.net>
-
- * method.h: introduce rb_method_definition_t::complemented_count.
-
- * vm_method.c (method_definition_addref_complement): introduced.
-
- def->alias_count is used to decide warn or do not warn at method
- redefinition. Complemented method entries should not prevent
- redefiniton warnings.
-
- * vm_method.c (rb_method_definition_release): release def iff
- alias_count == 0 && complemented_count == 0.
-
- * test/ruby/test_module.rb: add a test.
-
Tue Nov 17 15:34:34 2015 Martin Duerst <duerst@it.aoyama.ac.jp>
* NEWS: Added update from Unicode 7.0.0 to 8.0.0 [ci skip]
diff --git a/method.h b/method.h
index 315915beb8..d36cf38297 100644
--- a/method.h
+++ b/method.h
@@ -65,8 +65,6 @@ typedef struct rb_callable_method_entry_struct { /* same fields with rb_method_e
#define METHOD_ENTRY_VISI(me) (rb_method_visibility_t)(((me)->flags & (IMEMO_FL_USER0 | IMEMO_FL_USER1)) >> (IMEMO_FL_USHIFT+0))
#define METHOD_ENTRY_BASIC(me) (int) (((me)->flags & (IMEMO_FL_USER2 )) >> (IMEMO_FL_USHIFT+2))
-#define METHOD_ENTRY_COMPLEMENTED(me) ((me)->flags & IMEMO_FL_USER3)
-#define METHOD_ENTRY_COMPLEMENTED_SET(me) ((me)->flags = (me)->flags | IMEMO_FL_USER3)
static inline void
METHOD_ENTRY_VISI_SET(rb_method_entry_t *me, rb_method_visibility_t visi)
@@ -145,9 +143,8 @@ typedef struct rb_method_refined_struct {
} rb_method_refined_t;
typedef struct rb_method_definition_struct {
- rb_method_type_t type : 8; /* method type */
- int alias_count : 28;
- int complemented_count: 28;
+ rb_method_type_t type; /* method type */
+ int alias_count;
union {
rb_method_iseq_t iseq;
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index b86efd7005..dbbeca850d 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1280,20 +1280,6 @@ class TestModule < Test::Unit::TestCase
undef foo
end
end
-
- stderr = EnvUtil.verbose_warning do
- Module.new do
- def foo; end
- mod = self
- c = Class.new do
- include mod
- end
- c.new.foo
- def foo; end
- end
- end
- assert_match(/: warning: method redefined; discarding old foo/, stderr)
- assert_match(/: warning: previous definition of foo/, stderr)
end
def test_protected_singleton_method
diff --git a/vm_method.c b/vm_method.c
index 685e31fa7c..c88167434b 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -135,24 +135,19 @@ rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_me
}
static void
-rb_method_definition_release(rb_method_definition_t *def, int complemented)
+rb_method_definition_release(rb_method_definition_t *def)
{
if (def != NULL) {
- const int alias_count = def->alias_count;
- const int complemented_count = def->complemented_count;
- VM_ASSERT(alias_count >= 0);
- VM_ASSERT(complemented_count >= 0);
+ const int count = def->alias_count;
+ VM_ASSERT(count >= 0);
- if (alias_count + complemented_count == 0) {
- if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d,%d (remove)\n", def, rb_id2name(def->original_id), alias_count, complemented_count);
+ if (count == 0) {
+ if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d\n", def, rb_id2name(def->original_id), count);
xfree(def);
}
else {
- if (complemented) def->complemented_count--;
- else if (def->alias_count > 0) def->alias_count--;
-
- if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d->%d,%d->%d (dec)\n", def, rb_id2name(def->original_id),
- alias_count, def->alias_count, complemented_count, def->complemented_count);
+ if (METHOD_DEBUG) fprintf(stderr, "-%p-%s:%d->%d\n", def, rb_id2name(def->original_id), count, count-1);
+ def->alias_count--;
}
}
}
@@ -160,7 +155,7 @@ rb_method_definition_release(rb_method_definition_t *def, int complemented)
void
rb_free_method_entry(const rb_method_entry_t *me)
{
- rb_method_definition_release(me->def, METHOD_ENTRY_COMPLEMENTED(me));
+ rb_method_definition_release(me->def);
}
static inline rb_method_entry_t *search_method(VALUE klass, ID id, VALUE *defined_class_ptr);
@@ -347,14 +342,6 @@ method_definition_addref(rb_method_definition_t *def)
return def;
}
-static rb_method_definition_t *
-method_definition_addref_complement(rb_method_definition_t *def)
-{
- def->complemented_count++;
- if (METHOD_DEBUG) fprintf(stderr, "+%p-%s:%d\n", def, rb_id2name(def->original_id), def->alias_count);
- return def;
-}
-
static rb_method_entry_t *
rb_method_entry_alloc(ID called_id, VALUE owner, VALUE defined_class, const rb_method_definition_t *def)
{
@@ -398,12 +385,8 @@ const rb_callable_method_entry_t *
rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, VALUE defined_class)
{
rb_method_entry_t *me = rb_method_entry_alloc(src_me->called_id, src_me->owner, defined_class,
- method_definition_addref_complement(src_me->def));
+ method_definition_addref(src_me->def));
METHOD_ENTRY_FLAGS_COPY(me, src_me);
- METHOD_ENTRY_COMPLEMENTED_SET(me);
-
- VM_ASSERT(RB_TYPE_P(me->owner, T_MODULE));
-
return (rb_callable_method_entry_t *)me;
}