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

324 Коммитов

Автор SHA1 Сообщение Дата
naruse 28f5e12c24 * configure.in: check function attirbute const and pure,
and define CONSTFUNC and PUREFUNC if available.
  Note that I don't add those options as default because
  it still shows many false-positive (it seems not to consider
  longjmp).

* vm_eval.c (stack_check): get rb_thread_t* as an argument
  to avoid duplicate call of GET_THREAD().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-08 17:44:51 +00:00
nobu 84f94652b0 use TH_JUMP_TAG
* vm_eval.c (rb_eval_cmd, rb_catch_obj): use TH_JUMP_TAG with the
  same rb_thread_t used for TH_PUSH_TAG, instead of JUMP_TAG with
  the current thread global variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-05 03:22:20 +00:00
nobu d7935475fc remove rb_thread_t::parse_in_eval
* parse.y (struct parser_params): move parse_in_eval flag from
  rb_thread_t.
* parse.y (rb_parser_set_context): set parsing context, not only
  mild error flag.
* iseq.c (rb_iseq_compile_with_option): the parser now refers no
  thread local states to be restored.
* vm_eval.c (eval_string_with_cref): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-28 21:39:24 +00:00
nobu bc343b851d SyntaxError message at iseq compile
* iseq.c (rb_iseq_compile_with_option): make the parser in mild
  error.
* load.c (rb_load_internal0): ditto.
* parse.y (yycompile0): return the error message within the error
  to be raised.  [Feature #11951]
* parse.y (parser_compile_error): accumulate error messages in the
  error_buffer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-19 05:46:20 +00:00
nobu 12ec73ad92 Malformed RDoc syntax in catch [ci skip]
* vm_eval.c (rb_f_catch): [DOC] fix malformed RDoc syntax, "+...+"
  cannot enclose non-identifier characters.
  a patch by Sebastian S in [ruby-core:74278].  [Bug#12170]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-12 00:50:29 +00:00
nobu 0534b970bc vm_eval.c: call method_missing by method entry
* vm_eval.c (method_missing): call by found method entry and get
  rid of searching the same method entry twice.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-02 07:28:50 +00:00
nobu be8005b977 vm_eval.c: method_missing by method_missing
* vm_eval.c (vm_call0_body): calling method_missing method is
  method_missing().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-02 07:18:31 +00:00
nobu 4d9f5482ae NoMethodError#private_call?
* error.c (nometh_err_initialize): add private_call? parameter.
* error.c (nometh_err_private_call_p): add private_call? method,
  to tell if the exception raised in private form FCALL or VCALL.
  [Feature #12043]
* vm_eval.c (make_no_method_exception): append private_call?
  argument.
* vm_insnhelper.c (ci_missing_reason): copy FCALL flag.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-28 04:41:38 +00:00
nobu 7cb7b5f7f2 Fix Module#module_eval rdoc [ci skip]
* vm_eval.c (rb_mod_module_eval): [DOC] Fix documentation
  signature for Module#module_eval.  [Fix GH-1258]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-20 05:44:52 +00:00
nobu 6bc6708b97 vm_eval.c: argument names
* vm_eval.c (make_no_method_exception): enumerate argument
  meanings instead of a magic number.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-03 07:21:48 +00:00
nobu 6ee8ec7069 vm_eval.c: fix hook call
* vm_eval.c (rb_check_funcall_with_hook): also should call the
  given hook before returning Qundef when overridden respond_to?
  method returned false.  [ruby-core:73556] [Bug #12030]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-30 06:19:13 +00:00
nobu be61b2b12d vm_eval.c: fstring format
* vm_eval.c (make_no_method_exception): make format string
  fstring.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-13 08:05:07 +00:00
nobu 2b988c36be vm_eval.c: hook after method_missing
* vm_eval.c (rb_check_funcall_with_hook): call hook after
  method_missing call when missing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-12 09:51:30 +00:00
nobu 4c6dd77df5 vm_eval.c: make dsym
* vm_eval.c (rb_throw, rb_catch): get rid of making static IDs,
  use dynamic symbos instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-30 04:44:41 +00:00
ko1 c267d24ef0 * vm.c (rb_vm_cref_replace_with_duplicated_cref): added.
CREFs should not be shared by methods between `using'.
  [Bug #11247]

* vm_insnhelper.c (vm_cref_replace_with_duplicated_cref): ditto.

* vm.c (vm_cref_dup): should copy refinements correctly.

* eval.c: use rb_vm_cref_replace_with_duplicated_cref().

* eval_intern.h: add a decl. of
  rb_vm_cref_replace_with_duplicated_cref().

* vm_eval.c (eval_string_with_cref): do not need to pass
  scope's CREF because VM can find out CREF from stack frames.

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




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-20 00:17:25 +00:00
ko1 32a9647264 * refactoring CREF related code.
* eval_intern.h: remove unused setter functions.
  CREF_CLASS_SET()
  CREF_NEXT_SET()
  CREF_SCOPE_VISI_COPY()

* eval_intern.h: rename flags:
  * NODE_FL_CREF_PUSHED_BY_EVAL_ -> CREF_FL_PUSHED_BY_EVAL
  * NODE_FL_CREF_OMOD_SHARED_ -> CREF_FL_OMOD_SHARED
  and use IMEMO_FL_USER1/2.

* vm.c (vm_cref_new): accept push_by_eval parameter.

* vm.c (vm_cref_new_use_prev): added for rb_vm_rewrite_cref().

* vm_insnhelper.c (vm_cref_push): accept pushed_by_eval parameter.

* vm_insnhelper.h: remove unused macros:
  COPY_CREF_OMOD() and COPY_CREF().

* vm_eval.c, insns.def: catch up this fix.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-13 20:02:19 +00:00
nobu 9cf1136481 vm_eval.c: skip internal names
* vm_eval.c (local_var_list_add): skip internal local variable
  name by its type but not if it has a name.  internal local
  variable names are just unique per frame, not globally.
  [ruby-core:71437] [Bug #11674]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-11 08:38:27 +00:00
nobu 748abedf9b vm_eval.c: rb_check_funcall_default
* vm_eval.c (rb_check_funcall_default): split from
  rb_check_funcall to return the given fallback value.
* object.c (rb_obj_dig): use rb_check_funcall_default so that tail
  call optimization will be possible.  [Feature #11643]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-09 12:48:20 +00:00
nobu 1546ffed49 use rb_source_loc and rb_source_location
* error.c, eval.c, eval_error.c, gc.c, variable.c, vm.c,
  vm_eval.c, vm_trace.c: use rb_source_loc/rb_source_location
  instead of combination of rb_sourcefile/rb_sourcefilename and
  rb_sourceline.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-31 01:02:26 +00:00
nobu 438f36dd2d vm_insnhelper.c: use enum and fix typo
* vm_insnhelper.c (VM_PROFILE_UP): use enum.

* vm_insnhelper.c (vm_profile_show_result): fix typo, "r->c" at
  the last should be "c->c".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-29 06:03:17 +00:00
nobu 5bf61f4540 error.c: separate class names
* error.c (name_err_mesg_to_str): separate class names from the
  receiver description.
* vm_eval.c (make_no_method_exception, raise_method_missing): add
  format specifiers for class names.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23 12:10:40 +00:00
knu f4c487173c Kernel#loop returns the result value of a finished iterator
* vm_eval.c (rb_f_loop): When a loop is stopped by a StopIteration
  exception, return what the enumerator has returned instead of
  nil. [ruby-core:71133] [Feature #11498]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-22 09:58:01 +00:00
ko1 0a40bcb20b * vm_eval.c, internal.h (rb_yield_1): added for performance which
doesn't check Qundef.
* numeric.c (int_dotimes): use rb_yield_1.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-10 21:22:54 +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 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
nobu 8b4cf7b708 eval_intern.h: pass_passed_block
* eval_intern.h (pass_passed_block): make helper inline function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-05 07:10:21 +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
nobu 2c357a5574 vm_eval.c: should be singular
* vm_eval.c (raise_method_missing): "names" should be singular.
  pointed out by Filip Bartuzi.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-03 08:57:47 +00:00
nobu e26ba49bd1 vm_eval.c: refine messages
* vm_eval.c (raise_method_missing): refine error messages when a
  symbol is not given.  [Fix GH-1013]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-03 01:07:52 +00:00
nobu 2f8a4d317f vm_eval.c: cache results
* vm_eval.c (check_funcall_failed, check_funcall_missing): cache
  results of respond_to? and respond_to_missing?, and search a
  pulibc method only for compatibility with rb_respond_to.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-22 06:43:14 +00:00
nobu 1f557eaea1 vm_eval.c: pass thread too
* vm_eval.c (check_funcall_missing): pass same thread to call.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-22 05:43:59 +00:00
nobu dc9c55d611 vm_eval.c: reuse found method entry
* vm_eval.c (check_funcall_missing): reuse found method entry
  instead of searching same entry repeatedly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-22 02:05:57 +00:00
nobu 629d26ef3a vm_eval.c: share with rb_obj_respond_to
* vm_eval.c (check_funcall_respond_to): share the behavior with
  rb_obj_respond_to.  [ruby-core:70460] [Bug #11465]
* vm_method.c (vm_respond_to): extract from rb_obj_respond_to and
  merge r39881.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-20 05:13:28 +00:00
nobu 149dadf368 vm_eval.c: set method_missing_reason
* vm_eval.c (send_internal): set method_missing_reason before
  invoking overriding method_missing method so that the default
  method_missing can achieve it properly.
  [ruby-core:68515] [Bug #10969]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-29 06:25:21 +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
nobu ab742d9d2e vm_eval.c: safe level 4
* vm_eval.c (rb_eval_cmd): $SAFE=4 has been deprecated.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-17 14:51:34 +00:00
ko1 a82ce7c556 * vm.c: refactoring Proc/Env related code.
* vm_core.h: remove blockprocval field from rb_proc_t and rb_binding_t.
  Instead of this field, mark given block in Proc at rb_env_t::env.
* vm.c (vm_make_env_each): make an Env object with this layout.
  And also simplify parameters.
* proc.c: catch up this fix.
* vm_core.h: remove rb_env_t::local_size because it is not used.
* vm_dump.c (rb_vmdebug_env_dump_raw): catch up this fix.
* vm_core.h (rb_vm_make_env_object): remove rb_vm_make_env_object()
  because it is only refered from vm.c.
* vm_eval.c (eval_string_with_cref): catch up this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-14 16:23:17 +00:00
svn 8895c18dc6 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-03 11:25:29 +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
nobu f94ed2ce4b error.c: remove singleton method
* error.c (rb_name_err_mesg_new): remove singleton method, and
  unused argument.

* vm_eval.c (make_no_method_exception): call rb_name_err_mesg_new
  directly instead of constant lookup and method invocation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-25 07:11:45 +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 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 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
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 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
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 bd872a544c vm_eval.c: resolve refined method entry
* vm_eval.c (rb_method_call_status): resolve refined method entry
  to check if undefined.  [ruby-core:69064] [Bug #11117]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-08 03:11:35 +00:00