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

421 Коммитов

Автор SHA1 Сообщение Дата
ko1 930595cd35 * vm_insnhelper.c (vm_push_frame): initialize other than sp (and ep)
first for performance.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-10 22:15:18 +00:00
ko1 ad45aea456 * vm_insnhelper.c (vm_call_iseq_setup_normal): setup sp first
for performance.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-10 21:20:59 +00:00
ko1 cb223b7533 * vm.c (invoke_block_from_c): split this function into several
functions.
* vm_insnhelper.c (vm_yield_callee_setup_arg): remove this function
  beacuse it is only delegation function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-10 20:32:07 +00:00
ko1 f6e57af98d * gc.c (newobj_of_slowpass): fix typo (pass -> path).
Pointed out by Yukihiro Matsumoto  <matz@ruby-lang.org>.
* gc.c (newobj_of_...): `of' is unnecessary.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-10 18:49:05 +00:00
ko1 a00fc76ce5 * vm_insnhelper.c (vm_call_method0): do not propagate enable_fastpath,
but pass dummy CC to prevent wrong caching.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-10 09:36:10 +00:00
ko1 603210060c * vm_insnhelper.c (vm_call_method0): use switch() for visibilities
(for readability).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-06 10:25:25 +00:00
ko1 72cf24c813 * method.h: remove METHOD_ENTRY_SAFE(me) and related code
because $SAFE = 3 and 4 is not available.
  Now, $SAFE is not checked on method dispatch at all.
* vm_eval.c, vm_insnhelper.c, vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-06 09:49:53 +00:00
ko1 9b77261a12 * vm_insnhelper.c: solve goto spaghetti.
Change all goto statement across blocks to tail call functions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05 19:44:05 +00:00
nobu c90550c251 vm_args.c: fix marking symbol ifunc
* vm_args.c (vm_caller_setup_arg_block): store new ifunc for
  symbol in control frame proc to be marked.

* proc.c (proc_new), vm_insnhelper.c (vm_yield_with_cfunc):
  block->proc may be an ifunc now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-01 10:52:52 +00:00
ko1 d5ec9ec308 * vm_core.h: split rb_call_info_t into several structs.
* rb_call_info (ci) has compiled fixed information.
  * if ci->flag & VM_CALL_KWARG, then rb_call_info is
    also rb_call_info_with_kwarg. This technique reduce one word
    for major rb_call_info data.
  * rb_calling_info has temporary data (argc, blockptr, recv).
    for each method dispatch. This data is allocated only on
    machine stack.
  * rb_call_cache is for inline method cache.
  Before this patch, only rb_call_info_t data is passed.
  After this patch, above three structs are passed.
  This patch improves:
  * data locarity (rb_call_info is now read-only data).
  * reduce memory consumption (rb_call_info_with_kwarg,
    rb_calling_info).
* compile.c: use above data.
* insns.def: ditto.
* iseq.c: ditto.
* vm_args.c: ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.
* vm_insnhelper.h: ditto.
* iseq.h: add iseq_compile_data::ci_index and
  iseq_compile_data::ci_kw_indx.
* tool/instruction.rb: introduce TS_CALLCACHE operand type.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-19 17:59:58 +00:00
ko1 163d436d42 * vm_insnhelper.c (vm_call_iseq_setup_normal): do not clear local
variables here. vm_push_frame() clears.
* vm_insnhelper.c (vm_call_iseq_setup_tailcall): ditto.
* vm_insnhelper.c (vm_push_frame): move check code to
  vm_check_frame().
  Reorder initialization timing to reuse same values (sp).
* compile.c (rb_iseq_compile_node): use
  iseq_set_exception_local_table() for ISEQ_TYPE_DEFINED_GUARD.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-12 18:47:43 +00:00
ko1 731c9288da * vm_core.h: remove rb_call_info_t::aux.opt_pc.
* vm_insnhelper.c: introduce shortcut functions for opt_pc == 0
  because opt_pc is always 0 on shortcut function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-11 18:25:54 +00:00
nobu 9c7bf9494b vm_insnhelper.c: use update argc
* vm_insnhelper.c (vm_invoke_block): use ci->argc updated by
  CALLER_SETUP_ARG().  [Bug #11451]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-21 15:31:39 +00:00
ko1 416aa45918 * vm_insnhelper.c (vm_invoke_block): we should not expect ci->argc is
stable after invoking a block. [Bug #11451]
* test/ruby/test_yield.rb: add a test. This test script is given by
  Alex Dowad.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-21 08:37:46 +00:00
nobu 288f6e1b89 vm_insnhelper.c: suppress a warning
* vm_insnhelper.c (vm_setivar): cast to long both side of a
  conditional expression to suppress a sign-compare warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-26 06:24:18 +00:00
ko1 22be6d06ab * vm_core.h: size should be unsigned.
* rb_call_info_t::index
  * rb_iseq_constant_body::stack_max
  * rb_iseq_constant_body::local_size
  * rb_iseq_constant_body::param::size
  * rb_iseq_constant_body::local_table_size
  * rb_iseq_constant_body::is_size
  * rb_iseq_constant_body::callinfo_size
* iseq.h: same for iseq_catch_table::size.
* compile.c: catch up these fix.
* iseq.c: ditto.
* proc.c: ditto.
* vm.c: ditto.
* vm_args.c: ditto.
* vm_eval.c: ditto.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-24 21:44:14 +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 948bd807c3 * vm_core.h: constify rb_call_info_t::blockiseq and rb_iseq_t::iseq.
* vm.c, vm_insnhelper.c: catch up this fix.
* iseq.c (iseq_data_to_ary): constify the first iseq parameter.
* vm_insnhelper.c (vm_make_proc_with_iseq): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21 21:28:43 +00:00
ko1 c5618920ed * method.h: constify rb_method_iseq_t::iseqptr.
* proc.c (rb_method_entry_min_max_arity): catch up this fix.
* vm_insnhelper.c (def_iseq_ptr): constify.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-21 21:19:02 +00:00
nobu 1b8ff4f799 ruby_vm_throw_flags
* vm_core.h (ruby_vm_throw_flags): constants for throw.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-20 00:08:23 +00:00
ko1 c3e8cca950 * vm_core.h: constify rb_iseq_t::parent_iseq.
rb_iseq_t::local_iseq is not constant data because
  local_iseq::flip_cnt can be modified (commentted).
* compile.c: catch up this fix.
* iseq.c: ditto.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-16 13:13:50 +00:00
ko1 f23adf7459 * vm_insnhelper.c (vm_search_super_method): use CI_SET_FASTPATH().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-09 04:04:30 +00:00
ko1 d53e1a7937 * vm_core.h: remove rb_call_info_t::klass because
rb_callable_method_entry_t has information about defined class.
* vm_insnhelper.c (vm_search_method): don't set ci->klass because
  it is removed.
* vm_insnhelper.c (rb_equal_opt): ditto.
* vm_insnhelper.c (vm_search_superclass): removed because it is too
  simple to write code directly.
* vm_insnhelper.c (vm_defined): don't use vm_search_superclass().
  This fix avoid searching current callable `me' twice.
* vm_insnhelper.c (vm_search_super_method): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-09 02:10:51 +00:00
ko1 02d5868962 * vm_core.h: remove rb_iseq_t::klass to reduce dynamic data.
* internal.h, iseq.c (rb_iseq_klass): remove it because
  rb_iseq_t::klass is removed.
* vm_insnhelper.c (vm_super_outside): do not see cfp->iseq, but
  check callable method entry on a frame.
  This fix simplify the logic to search super class.
* test/ruby/test_method.rb: support super() from Proc.
  Now, [Bug #4881] and [Bug #3136] was solved.
* proc.c (rb_mod_define_method): catch up this change.
* vm.c (vm_define_method): ditto.
* vm_backtrace.c (rb_profile_frames): now, each `frame' objects
  are rb_callable_method_entry_t data or iseq VALUEs.
  This fix introduce minor compatibility issue that
  rb_profile_frame_label() always returns
  rb_profile_frame_base_label().
* test/-ext-/debug/test_profile_frames.rb: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06 18:44:54 +00:00
ko1 c8854d2ca4 * vm_insnhelper.c (vm_search_super_method): do not skip calling
same methods in super.
  [Bug #3351]
* test/ruby/test_super.rb: fix a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-06 09:02:34 +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
ko1 c7edd997e8 * vm.c: use VM_ASSERT instead of assert().
* vm_args.c: ditto.
* vm_insnhelper.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-10 23:42:01 +00:00
ko1 85647d9f2b * vm_core.h: define VM_ASSERT() for assertion
enabled only when (VM_CHECK_MODE > 0).
* vm_insnhelper.c: move definition VM_CHECK_MODE
  from vm_insnhelper.c to vm_core.h.
* vm.c: remove <assert.h>



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-10 23:25:30 +00:00
ko1 62a81ad98c * vm_insnhelper.c (check_frame): check type of cref_or_me first.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-10 21:56:23 +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 b6b76e3a85 * internal.h: move definition of rb_cref_t to method.h.
* eval_intern.h: move definition of rb_scope_visibility_t
  to method.h.
* method.h: change rb_cref_t::scope_visi from VALUE to
  rb_scope_visibility_t.
  [Bug #11219]
* vm.c (vm_cref_new): accept rb_method_visibility_t directly.
* vm_insnhelper.c (rb_vm_rewrite_cref): don't use 0,
  but METHOD_VISI_UNDEF.
* vm_method.c (rb_scope_visibility_set): don't need to use cast.
* vm_method.c (rb_scope_module_func_set): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-05 11:42:34 +00:00
ko1 63e1601049 * vm_insnhelper.c (vm_defined): no need to use cast.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04 16:17:53 +00:00
ko1 54a9ac7655 * vm_insnhelper.c (vm_defined): show additional messages on rb_bug().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04 16:15:13 +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 4ef6a68235 add a fix to last commit
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 20:26:55 +00:00
ko1 bd1e9d638e * vm_insnhelper.c (def_iseq_ptr): `iseqval' is not available any more.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 20:15:24 +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 5ac1972c1a * vm_core.h: rename enum missing_reason to enum method_missing_reason.
* vm_core.h: use enum method_missing_reason for
  rb_thread_t::method_missing_reason.
* vm_eval.c: catch up this fix.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 10:42:18 +00:00
ko1 b5cd6ba214 * method.h: change fileds order to gather frequent acces fields.
* vm_insnhelper.c (vm_call_method): add LIKELY().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 02:48:43 +00:00
ko1 18bbd05709 * method.h: split rb_method_definition_t::flag to several flags.
`flag' contains several categories of attributes and it makes us
  confusion (at least, I had confused).
  * rb_method_visibility_t (flags::visi)
    * NOEX_UNDEF     -> METHOD_VISI_UNDEF     = 0
    * NOEX_PUBLIC    -> METHOD_VISI_PUBLIC    = 1
    * NOEX_PRIVATE   -> METHOD_VISI_PRIVATE   = 2
    * NOEX_PROTECTED -> METHOD_VISI_PROTECTED = 3
  * NOEX_SAFE(flag)) -> safe (flags::safe, 2 bits)
  * NOEX_BASIC       -> basic (flags::basic, 1 bit)
  * NOEX_MODFUNC     -> rb_scope_visibility_t in CREF
  * NOEX_SUPER       -> MISSING_SUPER (enum missing_reason)
  * NOEX_VCALL       -> MISSING_VCALL (enum missing_reason)
  * NOEX_RESPONDS    -> BOUND_RESPONDS (macro)
  Now, NOEX_NOREDEF is not supported (I'm not sure it is needed).
  Background:
    I did not know what "NOEX" stands for.
    I asked Matz (who made this name) and his answer was "Nothing".
    "At first, it meant NO EXport (private), but the original
    meaning was gone."
    This is why I remove the mysterious word "NOEX" from MRI.
* vm_core.h: introduce `enum missing_reason' to represent
  method_missing (NoMethodError) reason.
* eval_intern.h: introduce rb_scope_visibility_t to represent
  scope visibility.
  It has 3 method visibilities (public/private/protected)
  and `module_function`.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 01:39:16 +00:00
nagachika 4fc87d4cb5 * vm_insnhelper.c: fix a typo. [ci skip]
check_resopnd_to_missing -> check_respond_to_missing

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 20:03:54 +00:00
ko1 a54da1c050 * vm_insnhelper.c (vm_defined): check respond_to_missing?
at defined?(func()).
* test/ruby/test_defined.rb: add a test for this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 19:49:22 +00:00
ko1 5bcae57c6f * vm_insnhelper.c (vm_defined): skip respond_to_missing? when
a method is available.
  [Bug #11211]
* test/ruby/test_defined.rb: add a test for this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 19:36:43 +00:00
ko1 15164bf33c * insns.def (defined), vm_insnhelper.c (vm_defined):
move instruction body to the vm_defined() function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 19:15:29 +00:00
ko1 57b817f4c5 * method.h: make rb_method_entry_t a VALUE.
Motivation and new data structure are described in [Bug #11203].
  This patch also solve the following issues.
  * [Bug #11200] Memory leak of method entries
  * [Bug #11046] __callee__ returns incorrect method name in orphan
                 proc
* test/ruby/test_method.rb: add a test for [Bug #11046].
* vm_core.h: remvoe rb_control_frame_t::me. me is located at value
  stack.
* vm_core.h, gc.c, vm_method.c: remove unlinked_method... codes
  because method entries are simple VALUEs.
* method.h:  Now, all method entries has own independent method
  definititons. Strictly speaking, this change is not essential,
  but for future changes.
  * rb_method_entry_t::flag is move to rb_method_definition_t::flag.
  * rb_method_definition_t::alias_count is now
    rb_method_definition_t::alias_count_ptr, a pointer to the counter.
* vm_core.h, vm_insnhelper.c (rb_vm_frame_method_entry) added to
  search the current method entry from value stack.
* vm_insnhelper.c (VM_CHECK_MODE): introduced to enable/disable
  assertions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 04:20:30 +00:00
kazu abe5b048bd fix typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-01 15:00:17 +00:00
ko1 f1d4e8b3b3 * method.h: add VM_METHOD_TYPE_ALIAS rb_method_definition_t::type
to fix [Bug #11173].
  Now, inter class/method alias creates new method entry
  VM_METHOD_TYPE_ALIAS, which has an original method entry.
* vm_insnhelper.c (find_defiend_class_by_owner): added.
  Search corresponding defined_class from owner class/module.
* vm_method.c (rb_method_entry_get_without_cache): return me->klass
  directly for defined_class.
  Now, no need to check me->klass any more.
* vm_method.c (method_entry_set0): separated from method_entry_set().
* vm_method.c (rb_alias): make method entry has VM_METHOD_TYPE_ALIAS.
* vm_method.c (release_method_definition): support VM_METHOD_TYPE_ALIAS.
* vm_method.c (rb_hash_method_definition): ditto.
* vm_method.c (rb_method_definition_eq): ditto.
* vm_method.c (release_method_definition): ditto.
* vm_insnhelper.c (vm_call_method): ditto.
* vm_insnhelper.c (vm_method_cfunc_entry): ditto.
* vm_eval.c (vm_call0_body): ditto.
* gc.c (mark_method_entry): ditto.
* proc.c (method_def_iseq): ditto.
* proc.c (method_cref): ditto.
* proc.c (rb_method_entry_min_max_arity): ditto.
* test/ruby/test_alias.rb: add tests.
* test/ruby/test_module.rb: fix a test to catch up current behavior.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 18:45:28 +00:00
nobu ca61b4c4e0 vm.c: vm_invoke_bmethod
* vm.c (vm_invoke_bmethod): bmethod does not need EXEC_TAG as it
  does not set safe level.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-20 22:03:06 +00:00
nobu c0bf2c5efe vm_core.h: update for OPT_CALL_CFUNC_WITHOUT_FRAME
* vm_eval.c (vm_call0_cfunc): update invoker arguments.
* vm_insnhelper.c (vm_call_cfunc_latter): ditto.
* vm_insnhelper.c (rb_vm_call_cfunc_push_frame): ditto, and prefix
  with rb_.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-03 02:43:20 +00:00