Граф коммитов

347 Коммитов

Автор SHA1 Сообщение Дата
normal f7f097a369 remove unused rb_obj_basic_to_s_p function
This hasn't been used since r36709 (2012-08-15)
("Kernel#inspect: improve consistency and do not call #to_s.")
and was never part of public API in include/ruby/

* class.c (rb_obj_basic_to_s_p): remove function
* internal.h (rb_obj_basic_to_s_p): remove declaration

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-29 22:34:19 +00:00
nobu 217f599a1e class.c: prohibit refinement module
* class.c (ensure_includable): cannot include refinement
  module, or the type and the class do not match.
  [ruby-core:79632] [Bug #13236]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 03:23:43 +00:00
nobu 19a1f70364 class.c: ensure_includable
* class.c (ensure_includable): extract checks to include and
  prepend.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-25 02:57:30 +00:00
nobu 13dffd8a2a class.c: non-keyword hash class
* class.c (rb_extract_keywords): keep the class of non-keyword
  elements hash as the original.  [ruby-core:77813] [Bug #12884]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-18 03:38:52 +00:00
nobu f5ef84cb5e class.c: missing unknown_keyword_error
* class.c (rb_get_kwargs): when values are stored, corresponding
  keys have been remove from the keyword hash, and the hash should
  be empty in that case.  [ruby-dev:49893] [Bug #13004]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-04 08:50:29 +00:00
nobu ee160e68f9 class.c: no fstring singleton class
* class.c (singleton_class_of): prohibit fstrings from creating
  singleton classes.
  temporary measure for [ruby-dev:49867] [Bug #12923]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 09:43:05 +00:00
nobu 4e41467894 class.c: trivial optimization
* class.c (singleton_class_of): just copy FROZEN flag without
  conditions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-12 06:12:12 +00:00
nobu 4065c38a6a class.c: rb_undef_methods_from
* class.c (rb_undef_methods_from): undefine methods defined in
  super from klass.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-24 01:49:52 +00:00
nobu dd2ebf4d78 replace Fixnum with Integer in rdoc [ci skip]
* array.c, class.c: Fixed documentation where Fixnum was referred
  directly to use Integer, as Fixnum and Bignum are now unified
  into Integer and direct usage is deprecated.  [Fix GH-1459]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-09 14:05:57 +00:00
tenderlove c4c53310c2 Copy the serial number from the super class to the singleton class
This helps hit inline method caches more frequently.  Before this
commit:

```
[aaron@TC ruby (trunk)]$ time ./ruby -v benchmark/bm_vm2_poly_singleton.rb
ruby 2.4.0dev (2016-09-12 trunk 56141) [x86_64-darwin15]

real  0m3.679s
user  0m3.632s
sys 0m0.022s
```

After this commit:

```
[aaron@TC ruby (trunk)]$ time ./ruby -v benchmark/bm_vm2_poly_singleton.rb
ruby 2.4.0dev (2016-09-12 trunk 56141) [x86_64-darwin15]
last_commit=Copy the serial number from the super class to the singleton class

real  0m2.246s
user  0m2.203s
sys 0m0.020s
```

[Feature #12364]
[ruby-core:75425]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-12 15:40:09 +00:00
nobu d9a6f701bf class.c: instance method conditions
* class.c (ins_methods_i, ins_methods_prot_i, ins_methods_priv_i),
  (ins_methods_pub_i): check for each conditions to match.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-07 07:35:45 +00:00
nobu 9662ee0584 internal.h: inline Check_Type
* internal.h (Check_Type): inline check for the object type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-23 13:43:44 +00:00
nobu 81442f903c prevent rb_cObject from GC
* class.c (Init_class_hierarchy): prevent rb_cObject which is the
  class tree root, from GC.  [ruby-dev:49666] [Bug #12492]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-16 07:35:37 +00:00
eregon e4cab0fe95 * class.c (rb_define_class): Fix documentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-25 20:01:24 +00:00
nobu 29123a3799 class.c: simplify
* class.c (rb_scan_args): merge code for n_trail.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-25 08:13:37 +00:00
naruse 75307ce858 * class.c (rb_scan_args): moved to bottom of the file to make the
effect of `#undef rb_scan_args` the minimum.

* include/ruby/ruby.h (rb_scan_args): overwrite only if GCC and
  optimized. Visual C++ 14 or later can compile it but make it
  conservative.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-22 02:44:54 +00:00
naruse 8becb1e465 Revert r50102
This reverts "* include/ruby/ruby.h (rb_scan_args): don't use ALWAYS_INLINE with"
This rb_scan_args macro is GCCism.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-21 14:01:23 +00:00
naruse cc41066002 * include/ruby/ruby.h (rb_scan_args): use __VA_ARGS__ instead of
va_arg to allow compilers optimize more aggressive.
  https://gustedt.wordpress.com/2011/07/10/avoid-writing-va_arg-functions/
  rb_scan_args is now expected to be statically resolved.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-21 13:24:33 +00:00
nobu 9bb8f28f3d class.c: err if superclass is 0
* class.c (rb_define_class, rb_define_class_id_under): raise
  ArgumentError if super is 0, deprecated behavior which has been
  warned long time.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-07 04:33:00 +00:00
normal 244916d43b resolve class name earlier and more consistently
This further avoids class name resolution issues which came
about due to relying on hash table ordering before r53376.

Pre-caching the class name when it is never used raises memory
use, but the overall gain from moving away from st still gives
us a small gain.  Reverting r53376 and this patch and testing with
"valgrind -v ./ruby -rrdoc -eexit" on x86 (32-bit) shows:

before:
    in use at exit: 1,662,239 bytes in 25,286 blocks
  total heap usage: 49,514 allocs, 24,228 frees, 6,005,561 bytes allocated

after, with this change:
    in use at exit: 1,646,529 bytes in 24,572 blocks
  total heap usage: 48,891 allocs, 24,319 frees, 6,003,921 bytes allocated

* class.c (Init_class_hierarchy): resolve name for rb_cObject ASAP
* object.c (rb_mod_const_set): move name resolution to rb_const_set
* variable.c (rb_const_set): do class resolution here
  [ruby-core:72807] [Bug #11977]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-12 19:26:07 +00:00
normal 1142de8e2a use id_table for constant tables
valgrind 3.9.0 on x86-64 reports a minor reduction in memory usage
when loading only RubyGems and RDoc by running: ruby -rrdoc -eexit

before: HEAP SUMMARY:
    in use at exit: 2,913,448 bytes in 27,394 blocks
  total heap usage: 48,362 allocs, 20,968 frees, 9,034,621 bytes alloc

after: HEAP SUMMARY:
    in use at exit: 2,880,056 bytes in 26,712 blocks
  total heap usage: 47,791 allocs, 21,079 frees, 9,046,507 bytes alloc

* class.c (struct clone_const_arg): adjust for id_table
  (clone_const): ditto
  (clone_const_i): ditto
  (rb_mod_init_copy): ditto
  (rb_singleton_class_clone_and_attach): ditto
  (rb_include_class_new): ditto
  (include_modules_at): ditto
* constant.h (rb_free_const_table): ditto
* gc.c (free_const_entry_i): ditto
  (rb_free_const_table): ditto
  (obj_memsize_of): ditto
  (mark_const_entry_i): ditto
  (mark_const_tbl): ditto
* internal.h (struct rb_classext_struct): ditto
* object.c (rb_mod_const_set): resolve class name on assignment
* variable.c (const_update): replace with const_tbl_update
  (const_tbl_update): new function
  (fc_i): adjust for id_table
  (find_class_path): ditto
  (autoload_const_set): st_update => const_tbl_update
  (rb_const_remove): adjust for id_table
  (sv_i): ditto
  (rb_local_constants_i): ditto
  (rb_local_constants): ditto
  (rb_mod_const_at): ditto
  (rb_mod_const_set): ditto
  (rb_const_lookup): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-29 20:19:14 +00:00
nobu 96ac47c251 gc.c: do not expose internal singleton class
* gc.c (internal_object_p): should not expose singleton classes
  without a metaclass.  based on patches by ko1 and shugo.
  [Bug #11740]
* class.c (rb_singleton_class_object_p): added.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-22 13:15:58 +00:00
ko1 800607aa7e revert r53228 because this patch breaks rubyspec
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-21 10:32:33 +00:00
ko1 1bcee938d5 * gc.c (internal_object_p): should not expose singleton classes
without a metaclass.
  [Bug #11740]

* class.c (rb_singleton_class_has_metaclass_p): added.

* test/ruby/test_class.rb: add a test.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-21 09:40:58 +00:00
hsbt b381e3caee * class.c: fix documentation for rb_define_class{_id}_under.
[fix GH-991][ci skip] Patch by @kachick

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-04 06:46:05 +00:00
nobu 6f77d0a3aa variable.c: rb_class_ivar_set
* variable.c (rb_class_ivar_set): rename as class specific ivar
  setter, and st_table is no longer involved.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-30 03:07:06 +00:00
normal a666e9b5f2 variable.c (rb_st_insert_id_and_value): reduce args
Minor simplification; this will hopefully make future patches
for switching to id_table easier-to-review.

* internal.h (rb_st_insert_id_and_value): update prototype
* variable.c (rb_st_insert_id_and_value): reduce args
  (find_class_path): adjust call for less args
  (rb_ivar_set): ditto
  (rb_cvar_set): ditto
* class.c (rb_singleton_class_attached): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-30 01:40:28 +00:00
nobu eb47de3005 class.c: refine error messages
* class.c (rb_define_class, rb_define_class_id_under): refine
  error messages.
* class.c (rb_define_module, rb_define_module_id_under): ditto,
  and make consistent with class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-27 14:32:50 +00:00
ko1 15e48288fd * class.c (move_refined_method): should insert a write barrier
from an original class to a created (cloned) method entry.
* test/ruby/test_refinement.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-31 08:07:59 +00:00
ko1 2e2bd1c26b * class.c (move_refined_method): same as the last commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-12 09:00:56 +00:00
ko1 408fa5e687 * class.c, gc.c vm.c: use ID_TABLE_* instead of ST_*
(such as ST_CONTINUE) for enum rb_id_table_iterator_result.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-12 08:59:27 +00:00
ko1 c35ff11ae5 * id_table.h: introduce ID key table.
[Feature #11420]
  This table only manage ID->VALUE table to reduce overhead of st.
  Some functions prefixed rb_id_table_* are provided.
* id_table.c: implement rb_id_table_*.
  There are several algorithms to implement it.
  Now, there are roughly 4 types:
    * st
    * array
    * hash (implemented by  Yura Sokolov)
    * mix of array and hash
  The macro ID_TABLE_IMPL can choose implementation.
  You can see detailes about them at the head of id_table.c.
  At the default, I choose 34 (mix of list and hash).
  This is not final decision.
  Please report your suitable parameters or
  your data structure.
  * symbol.c: introduce rb_id_serial_t and rb_id_to_serial()
    to represent ID by serial number.
  * internal.h: use id_table for method tables.
  * class.c, gc.c, marshal.c, vm.c, vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-12 08:43:55 +00:00
ko1 e4198a73d4 * make rb_iseq_t T_IMEMO object (type is imemo_iseq).
All contents of previous rb_iseq_t is in rb_iseq_t::body.
  Remove rb_iseq_t::self because rb_iseq_t is an object.
  RubyVM::InstructionSequence is wrapper object points T_IMEMO/iseq.
  So RubyVM::ISeq.of(something) method returns different wrapper
  objects but they point the same T_IMEMO/iseq object.
  This patch is big, but most of difference is replacement of
  iseq->xxx to iseq->body->xxx.
  (previous) rb_iseq_t::compile_data is also located to
  rb_iseq_t::compile_data.
  It was moved from rb_iseq_body::compile_data.
  Now rb_iseq_t has empty two pointers.
  I will split rb_iseq_body data into static data and dynamic data.
* compile.c: rename some functions/macros.
  Now, we don't need to separate iseq and iseqval (only VALUE).
* eval.c (ruby_exec_internal): `n' is rb_iseq_t (T_IMEMO/iseq).
* ext/objspace/objspace.c (count_imemo_objects): count T_IMEMO/iseq.
* gc.c: check T_IMEMO/iseq.
* internal.h: add imemo_type::imemo_iseq.
* iseq.c: define RubyVM::InstructionSequnce as T_OBJECT.
  Methods are implemented by functions named iseqw_....
* load.c (rb_load_internal0): rb_iseq_new_top() returns
  rb_iseq_t (T_IMEMO/iesq).
* method.h (rb_add_method_iseq): accept rb_iseq_t (T_IMEMO/iseq).
* vm_core.h (GetISeqPtr): removed because it is not T_DATA now.
* vm_core.h (struct rb_iseq_body): remove padding for
  [Bug #10037][ruby-core:63721].



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21 22:52:59 +00:00
ko1 16a68369d2 * iseq.c, internal.h (rb_iseq_clone): removed because we don't need to
clone iseq any more.
* class.c (clone_method): share iseq between cloned methods. All of
  method dependent information are able to refer from method entry.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-07 02:27:41 +00:00
ko1 5e8a147480 * method.h: introduce rb_callable_method_entry_t to remove
rb_control_frame_t::klass.
  [Bug #11278], [Bug #11279]
  rb_method_entry_t data belong to modules/classes.
  rb_method_entry_t::owner points defined module or class.
    module M
      def foo; end
    end
  In this case, owner is M.
  rb_callable_method_entry_t data belong to only classes.
  For modules, MRI creates corresponding T_ICLASS internally.
  rb_callable_method_entry_t can also belong to T_ICLASS.
  rb_callable_method_entry_t::defined_class points T_CLASS or
  T_ICLASS.
  rb_method_entry_t data for classes (not for modules) are also
  rb_callable_method_entry_t data because it is completely same data.
  In this case, rb_method_entry_t::owner == rb_method_entry_t::defined_class.
  For example, there are classes C and D, and incldues M,
    class C; include M; end
    class D; include M; end
  then, two T_ICLASS objects for C's super class and D's super class
  will be created.
  When C.new.foo is called, then M#foo is searcheed and
  rb_callable_method_t data is used by VM to invoke M#foo.
  rb_method_entry_t data is only one for M#foo.
  However, rb_callable_method_entry_t data are two (and can be more).
  It is proportional to the number of including (and prepending)
  classes (the number of T_ICLASS which point to the module).
  Now, created rb_callable_method_entry_t are collected when
  the original module M was modified. We can think it is a cache.
  We need to select what kind of method entry data is needed.
  To operate definition, then you need to use rb_method_entry_t.
  You can access them by the following functions.
  * rb_method_entry(VALUE klass, ID id);
  * rb_method_entry_with_refinements(VALUE klass, ID id);
  * rb_method_entry_without_refinements(VALUE klass, ID id);
  * rb_resolve_refined_method(VALUE refinements, const rb_method_entry_t *me);
  To invoke methods, then you need to use rb_callable_method_entry_t
  which you can get by the following APIs corresponding to the
  above listed functions.
  * rb_callable_method_entry(VALUE klass, ID id);
  * rb_callable_method_entry_with_refinements(VALUE klass, ID id);
  * rb_callable_method_entry_without_refinements(VALUE klass, ID id);
  * rb_resolve_refined_method_callable(VALUE refinements, const rb_callable_method_entry_t *me);
  VM pushes rb_callable_method_entry_t, so that rb_vm_frame_method_entry()
  returns rb_callable_method_entry_t.
  You can check a super class of current method by
  rb_callable_method_entry_t::defined_class.
* method.h: renamed from rb_method_entry_t::klass to
  rb_method_entry_t::owner.
* internal.h: add rb_classext_struct::callable_m_tbl to cache
  rb_callable_method_entry_t data.
  We need to consider abotu this field again because it is only
  active for T_ICLASS.
* class.c (method_entry_i): ditto.
* class.c (rb_define_attr): rb_method_entry() does not takes
  defiend_class_ptr.
* gc.c (mark_method_entry): mark RCLASS_CALLABLE_M_TBL() for T_ICLASS.
* cont.c (fiber_init): rb_control_frame_t::klass is removed.
* proc.c: fix `struct METHOD' data structure because
  rb_callable_method_t has all information.
* vm_core.h: remove several fields.
  * rb_control_frame_t::klass.
  * rb_block_t::klass.
  And catch up changes.
* eval.c: catch up changes.
* gc.c: ditto.
* insns.def: ditto.
* vm.c: ditto.
* vm_args.c: ditto.
* vm_backtrace.c: ditto.
* vm_dump.c: ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-03 11:24:50 +00:00
normal b49075cdf1 move RB_GC_GUARD responsibility to rb_add_method_iseq
This simplifies all the callers and makes code easier to use
and review.  I was confused about the need for RB_GC_GUARD
in define_{aset,aref}_method of struct.c without reading
rb_add_method_iseq.

Likewise, do the same for rb_iseq_clone, where the GC guard
only seems neccesary iff RGenGC is disabled.

* vm_method.c (rb_add_method_iseq): add RB_GC_GUARD
* class.c (clone_method): remove RB_GC_GUARD
* struct.c (define_aref_method): ditto
  (define_aset_method): ditto
* vm.c (vm_define_method):
* iseq.c (rb_iseq_clone): add RB_GC_GUARD

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-30 21:07:18 +00:00
nobu da70f4d02a class.c: preserve encoding
* class.c (rb_check_inheritable): preserve encoding in an error
  message when the superclass is not a class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-28 03:28:50 +00:00
nobu a13ab237c7 class.c: TypeError when superclass mismatch
* class.c (rb_define_class_id_under): raise TypeError exception
  same as ruby level class definition when superclass mismatch.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-28 03:07:37 +00:00
ko1 c8590d60f1 * method.h: constify rb_method_alias_struct::original_me and
rb_method_refined_struct::orig_me.
* class.c (move_refined_method): use RB_OBJ_WRITE() for
  me->def->body.refined.orig_me.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-18 08:01:13 +00:00
ko1 c19d373750 * method.h: back to share rb_method_definition_t by
rb_method_entry_t.
  r50728 changed sharing `def's to isolating `def's
  on alias and so on. However, this change conflicts
  future improvement plan. So I change back to sharing approach.
* method.h: move rb_method_definition_t::flags to
  rb_method_entry_t::attr::flags.
  rb_method_entry_t::attr is union with VALUE because this field
  should have same size of VALUE. rb_method_entry_t is T_IMEMO).
  And also add the following access macros to it's fileds.
  * METHOD_ENTRY_VISI(me)
  * METHOD_ENTRY_BASIC(me)
  * METHOD_ENTRY_SAFE(me)
* vm_method.c (rb_method_definition_addref): added instead of
  rb_method_definition_clone().
  Do not create new definition, but increment alias_count.
* class.c (clone_method): catch up this fix.
* class.c (method_entry_i): ditto.
* proc.c (mnew_internal): ditto.
* proc.c (mnew_missing): ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-06 10:19:48 +00:00
ko1 c9044a2472 * class.c: ins_methods_push() needs rb_method_visibility_t type on
2nd arg.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-06 07:01:21 +00:00
ko1 1f9af2a953 * class.c (ins_methods_push): Change type and name of parameters
to make more clear.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-06 06:07:06 +00:00
nobu 32a586d738 class.c: suppress a warning
* class.c (ins_methods_push): suppress a signed and unsigned
  comparison warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-06 01:37:50 +00:00
ko1 eb774ceb22 * class.c (ins_methods_push): change 3rd parameter's type
from long to rb_method_visibility_t.
* class.c (ins_methods_i): catch up this fix.
* class.c (method_entry_i): cast to st_data_t instead of `long'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-05 13:39:59 +00:00
ko1 3619a8b52d * method.h: constify rb_method_refined_t::orig_me.
Also constify the following functions.
  * rb_resolve_refined_method()
  * rb_method_entry_with_refinements()
  * rb_method_entry_without_refinements()
  * rb_method_entry_copy()'s parameter.
* class.c: catch up this fix.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04 16:02:01 +00:00
ko1 9e73d45e0f * method.h: introduce rb_method_refined_t for refined method entry.
* class.c (move_refined_method): catch up this fix.
* gc.c (mark_method_entry): ditto.
* vm_eval.c (vm_call0_body): ditto.
* vm_insnhelper.c (vm_call_method): ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 22:27:51 +00:00
ko1 332210d441 * class.c (method_entry_i): mtbl should not have `me' as NULL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 19:51:38 +00:00
ko1 93f88afbd6 * class.c (clone_method): do not use me->klass, but use explicitly
passed argument.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 19:36:52 +00:00
ko1 4e870d302b * vm_core.h (rb_vm_rewrite_cref_stack): rename to rb_vm_rewrite_cref().
* class.c (clone_method): use renamed name.
* vm_insnhelper.c (rb_vm_rewrite_cref): do not use `node' in variable
  names.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 19:12:26 +00:00
ko1 c3cc282f7f * class.c (clone_method): remove redundant check for me->def != NULL.
Now, all `me` have `me->def`.
* proc.c (rb_method_entry_location): ditto.
* vm.c (rb_vm_check_redefinition_opt_method): ditto.
* vm.c (add_opt_method): ditto.
* vm_eval.c (vm_call0_body): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 11:10:16 +00:00