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

404 Коммитов

Автор SHA1 Сообщение Дата
nobu a15028bc38 proc.c: super_method of included method
* proc.c (method_super_method): search the next super method along
  the included ancestor chain.  [ruby-core:83114] [Bug #13973]

* vm_method.c (rb_callable_method_entry_without_refinements):
  return the defined class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-06 05:55:11 +00:00
nobu 0db193f98d vm_method.c: alias warning at refined method
* vm_method.c (rb_method_entry_make): suppress a warning at
  refined method which will not be redefined.
  [ruby-core:82385] [Bug #13817]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-17 14:58:11 +00:00
nobu 2b582b7ca6 UNALIGNED_MEMBER_ACCESS
* eval_intern.h (UNALIGNED_MEMBER_ACCESS): suppress
  address-of-packed-member warnings by clang 4.0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-30 14:48:45 +00:00
ko1 478003f6df rename absolute_path to realpath internally and introduce pathobj.
* vm_core.h: rename absolute_path to realpath because it is expected name.
  external APIs (#absolute_path methods) are remained.

* vm_core.h: remove rb_iseq_location_struct::path and
  rb_iseq_location_struct::absolute_path and introduce pathobj.
  if given path equals to given absolute_path (and most of case
  it is true), pathobj is simply given path String. If it is not same,
  pathobj is Array and pathobj[0] is path and pathobj[1] is realpath.

  This size optimization reduce 8 bytes and
  sizeof(struct rb_iseq_constant_body) is 200 bytes -> 192 bytes
  on 64bit CPU.

  To support this change, the following functions are introduced:
    * pathobj_path() (defined in vm_core.h)
    * pathobj_realpath() (ditto)
    * rb_iseq_path() (decl. in vm_core.h)
    * rb_iseq_realpath() (ditto)
    * rb_iseq_pathobj_new() (ditto)
    * rb_iseq_pathobj_set() (ditto)

* vm_core.h (rb_binding_t): use pathobj instead of path. If binding
  is given at eval methods, realpath (absolute_path) was caller's
  realpath. However, they should use binding's realpath.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-01 00:05:33 +00:00
normal 9d09240d9e rb_execution_context_t: move stack, stack_size and cfp from rb_thread_t
The goal is to reduce rb_context_t and rb_fiber_t size
by removing the need to store the entire rb_thread_t in
there.

[ruby-core:81045] Work-in-progress: soon, we will move more fields here.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-09 05:06:41 +00:00
ko1 76c4cca19c add performance counting mechanism for MRI debug/tuning purpose.
* How to enable this feature?
  * define USE_DEBUG_COUNTER as 1.
  * you can disable to output the result with
    RUBY_DEBUG_COUNTER_DISABLE environment variable
    even if USE_DEBUG_COUNTER == 1.

* How to add new counter?
  * add COUNTER(<name>) line on debug_counter.h.
  * include "debug_counter.h"
  * insert RB_DEBUG_COUNTER_INC(<name>) line on your favorite place.

* counter output example:
  [RUBY_DEBUG_COUNTER]    mc_inline_hit   999
  [RUBY_DEBUG_COUNTER]    mc_inline_miss  3
  [RUBY_DEBUG_COUNTER]    mc_global_hit   23
  [RUBY_DEBUG_COUNTER]    mc_global_miss  273
  [RUBY_DEBUG_COUNTER]    mc_global_state_miss    3
  [RUBY_DEBUG_COUNTER]    mc_class_serial_miss    0
  [RUBY_DEBUG_COUNTER]    mc_cme_complement       0
  [RUBY_DEBUG_COUNTER]    mc_cme_complement_hit   0
  [RUBY_DEBUG_COUNTER]    mc_search_super 1384
  [RUBY_DEBUG_COUNTER]    ivar_get_hit    0
  [RUBY_DEBUG_COUNTER]    ivar_get_miss   0
  [RUBY_DEBUG_COUNTER]    ivar_set_hit    0
  [RUBY_DEBUG_COUNTER]    ivar_set_miss   0
  [RUBY_DEBUG_COUNTER]    ivar_get        431
  [RUBY_DEBUG_COUNTER]    ivar_set        465

  * mc_... is related to method caching.
  * ivar_... is related to instance variable accesses.

* compare with dtrace/system tap features, there are completely
  no performacne penalties when it is disabled.

* This feature is supported only on __GNUC__ compilers.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-21 08:18:15 +00:00
nobu 556a1352e4 backward.h: 2.2 deprecated features
* include/ruby/backward.h (DECLARE_DEPRECATED_FEATURE): move
  features deprecated at 2.2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-21 05:17:41 +00:00
nobu 6877de73de DEPRECATED_INTERNAL_FEATURE
* error.c (ruby_deprecated_internal_feature): renamed, to
  explicitly represent deprecation.

* internal.h (DEPRECATED_INTERNAL_FEATURE): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-17 05:45:44 +00:00
naruse f34d0ba3eb More description about the protected attribute of a method
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-19 09:34:30 +00:00
nobu b38823ceca vm_method.c: resolve refined method to undef
* vm_method.c (rb_undef): resolve the method entry which refines a
  prepended method entry.  [ruby-core:78944] [Bug #13096]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-18 05:23:53 +00:00
rhe c54ede0560 proc.c: assume rb_iseq_location_t::first_lineno is always a Fixnum
Do not check for the value of rb_iseq_constant_body::line_info_table as
it is no longer related. The checks seem to be the remains from the day
before the dedicated 'first_lineno' field was introduced. Remove them.

Note, rb_iseq_constant_body::line_info_table can be NULL only when the
iseq does not contain any instructions that originate from Ruby code,
for example, an iseq created with 'proc {}' under a non-default compile
options where trace instructions are disabled.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-20 05:26:07 +00:00
ktsj 8004ad33bc * eval.c, method.h, proc.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_method.c:
TracePoint#method_id should return method_id, not callee_id.
  [ruby-core:77241] [Feature #12747]

* test/ruby/test_settracefunc.rb: change accordingly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05 13:15:26 +00:00
nobu a23878c3f5 vm_method.c: update assertion [ci skip]
* vm_method.c (prepare_callable_method_entry): update assertion
  as defined_class may be T_MODULE not only I_ICLASS since r56213.
  [Feature #12534]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-09 02:57:29 +00:00
shugo 5a121a4f0b * vm_method.c (make_method_entry_refined): fix wrong use of ||.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-23 14:59:26 +00:00
shugo a463ab1f05 * eval.c (rb_mod_refine): refine modules as well.
[ruby-core:76199] [Feature #12534]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-23 11:46:33 +00:00
nobu c463366dfd rb_funcallv
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions
  which are/will be/may be gems.  [Fix GH-1406]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-29 11:57:14 +00:00
ko1 9f60791a04 * vm_core.h: revisit the structure of frame, block and env.
[Bug #12628]

  This patch introduce many changes.

  * Introduce concept of "Block Handler (BH)" to represent
    passed blocks.

  * move rb_control_frame_t::flag to ep[0] (as a special local
    variable). This flags represents not only frame type, but also
    env flags such as escaped.

  * rename `rb_block_t` to `struct rb_block`.

  * Make Proc, Binding and RubyVM::Env objects wb-protected.

  Check [Bug #12628] for more details.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-28 11:02:30 +00:00
ko1 bebb62e01b * vm_method.c (method_entry_get_without_cache): check
undefined method even if ruby_running is FALSE.

  We haven't call "undef"ed methods before ruby_running.
  So that this issue does not make troubles.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-13 05:19:12 +00:00
nobu b51174a6b0 No respond_to? as if the default definition
* vm_method.c (vm_respond_to): try method_missing if respond_to?
  is undefined, as if it is the default definition.
  [ruby-core:75377] [Bug #12353]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-06-24 17:33:35 +00:00
nobu d226ce8dec internal.h: ONLY_FOR_INTERNAL_USE
* error.c (ruby_only_for_internal_use): raise fatal error when
  deprecated function only for internal use is called, not just a
  warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-27 05:29:49 +00:00
nobu 6cde2d359a vm_method.c: fix aliased original name
* vm_method.c (rb_alias): the original name should be properly
  available method_added method, set the name before calling the
  hook.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-08 15:29:48 +00:00
nobu 58f7563dc6 vm_method.c: fix assertion
* vm_method.c (prepare_callable_method_entry): assert same
  condition only once for each case, not twice for module instance
  method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-01 14:43:34 +00:00
nobu 0cd34e9639 vm_method.c: for hidden object
* vm_method.c (rb_method_basic_definition_p): methods of hidden
  objects cannot be overridden, return TRUE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-24 02:38:43 +00:00
hsbt 389a84fdbf * vm_method.c: fix grammar in respond_to? warning.
[fix GH-1047]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-19 00:39:12 +00:00
yui-knk 5cf9b65aa3 Use `rb_method_visibility_t` instead of `int` in `rb_print_undef`
* eval_error.c (rb_print_undef): Use `rb_method_visibility_t`
  instead of `int`.
* eval_intern.h (rb_print_undef): ditto
* proc.c (mnew_internal): ditto
* vm_method.c (rb_export_method): ditto
  [Misc #11649] [ruby-core:71311] [fix GH-1078]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-03 04:59:54 +00:00
shugo f211abcb9c * vm_method.c (rb_method_entry_make, check_override_opt_method):
should check whether a newly created method override a optimize
  method in case the method is defined in a prepended module of a
  built-in class.
  [ruby-core:72226] [Bug #11836]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-18 02:32:17 +00:00
ko1 fa3affad9a * vm_method.c (rb_class_clear_method_cache): should clear all
RCLASS_CALLABLE_M_TBLs of all sub-classes (T_ICLASS).

  RCLASS_CALLABLE_M_TBL() caches complemented method entries.
  It should be cleared when the modules are cleared.
  On previous version clears only for direct children.
  It is enough for normal modules because corresponding T_ICLASSes
  are direct children.

  However, refinements create complex data structure. So that
  we need to clear all children (and descendants).
  [ruby-core:71423] [Bug #11672]

* vm_method.c (rb_clear_method_cache_by_class): rb_mKernel
  doesn't call rb_class_clear_method_cache, so that
  clear child T_ICLASSes.

* test/ruby/test_refinement.rb: enable disabled test.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-18 13:59:57 +00:00
ko1 03efb7def9 * vm_method.c (prepare_callable_method_entry): use
RCLASS_CALLABLE_M_TBL() instead of accessing a filed directly.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-18 12:10:07 +00:00
ko1 3f7c0e9fd5 * method.h: introduce the folliwing field and macros.
* rb_method_definition_t::complemented_count to count shared method
    entries because of complemented method entries and separate from
    alias_count.

    Shared `def' only by complemented method entries should not prevent
    method re-definition warning.

  * METHOD_ENTRY_COMPLEMENTED(me) to represent complemented method entry.
  * METHOD_ENTRY_COMPLEMENTED_SET(me) to check it as  complemented me.

* vm_insnhelper.c (aliased_callable_method_entry): should also
  check me->def->complemented_count.

* vm_method.c (method_definition_addref_complement): add to count
  complemented method entries number.

* vm_method.c (rb_method_definition_release): release `def' iff
  alias_count == 0 and complemented_count == 0.

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




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-18 08:15:51 +00:00
ko1 6a533a3ecc revert r52614, r52615, r52617 because they cause serious errors
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17 13:18:19 +00:00
ko1 551ae37ba3 * 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().




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17 10:39:30 +00:00
ko1 fa4e516db9 * 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. Complented methods 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.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-17 09:42:39 +00:00
nobu 4ea616b387 vm_method.c: check if frozen [Fix GH-1096]
* vm_method.c (set_method_visibility): should fail if the receiver
  is frozen.  [ruby-core:71489] [Bug #11687]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-15 09:28:45 +00:00
ko1 25f5dd6799 * vm.c (vm_define_method): do not use current CREF immediately,
but check CREF in environment or methods. Methods defined in methods
  should be public.
  [Bug #11571]

* vm_method.c (rb_scope_module_func_check): check CREF in env or me.
  if CREF is contained by `me', then return FALSE.

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




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-13 17:38:12 +00:00
ko1 dd4cec36ca * method.h: constify rb_cref_t::scope_visi;
* eval_intern.h (CREF_SCOPE_VISI_COPY): catch up this fix.

* vm_method.c: ditto.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-13 17:20:11 +00:00
nobu 9d64a54209 internal.h: RUBY_DTRACE_HOOK
* internal.h (RUBY_DTRACE_HOOK): extract from
  RUBY_DTRACE_CREATE_HOOK for other type hooks.

* gc.c (RUBY_DTRACE_GC_HOOK): ditto.

* parse.y (RUBY_DTRACE_PARSE_HOOK): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-31 01:02:29 +00:00
hsbt 8d4dff2c18 * vm_method.c: added documentation of protected/private methods.
[fix GH-1072]
* test/ruby/test_module.rb: added testcase for method_defined?
  [fix GH-1071]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-30 03:36:21 +00:00
nobu 72ff61f4a8 NameError#receiver of uninitialized constant
* error.c (name_err_mesg_to_str): quote the name if unprintable.
* object.c (check_setter_id): use rb_check_id to convert names.
* variable.c (uninitialized_constant): use NameError::message to
  keep the receiver of uninitialized constant.  [Feature #10881]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-28 06:24:12 +00:00
sorah 9b425061da * vm_method.c(rb_method_entry_make):
[DOC] [ci skip] Remove a needless space from comment
  [Fixes GH-1069] Patch by @yui-knk

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-26 09:38:22 +00:00
nobu 136b5b752d vm_method.c: remove common code
* vm_method.c (rb_undef): remove code almost common to proc.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-24 07:35:57 +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 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 0970a928ef vm_eval.c: redefined respond_to_missing?
* vm_method.c (basic_obj_respond_to): call respond_to_missing?
  only when redefined.  [ruby-core:70460] [Bug #11465]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-20 13:19:21 +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 24da2db3e1 vm_method.c: reuse method entry
* vm_method.c (rb_obj_respond_to): reuse found method entry
  instead of searching same entry repeatedly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-19 23:53:12 +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
hsbt 0e8d7f89e6 * vm_method.c: typo fix [fix GH-993][ci skip] Patch by @0x0dea
* test/ruby/test_refinement.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-11 01:33:32 +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 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 051a749919 vm_method.c: remove unused code
* vm_method.c (rb_method_entry_make): remove unused code to
  prohibit method re-definition, introduced at r34983.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-01 09:55:57 +00:00
nobu e13f05f9e6 vm_method.c: no NOEX macros
* vm_method.c (rb_method_entry_make): NOEX macros are no longer
  defined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-01 08:18:18 +00:00
nobu f35b09c108 vm_method.c: orignial visibilities
* vm_method.c (Init_eval_method): copy the orignial visibilities,
  instead of setting explicitly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-01 08:17:58 +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
ko1 7bba6adc56 * vm_method.c (rb_method_entry_create): need to call
method_definition_reset() if def is given.
  Actually, `me' is a new object, so we don't need to call it.
  It is just to make sure.
* vm_method.c (method_definition_reset): remove duplicated insertion.
* vm_method.c (rb_method_entry_clone): assgine dst->def here,
  not in method_definition_reset().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-25 08:37:27 +00:00
ko1 f4d71ad509 * vm_method.c: make a rb_method_definition_t data (def) *after* making
a rb_method_entry_t data (me).
  Normally, `me' points `def'. Some Ruby objects pointed from `def'
  and objects are marked by `me' (mark_method_entry() in gc.c).
  However, `def' is built before making a `me', then nobody can mark
  objects pointed from `def' before making (and pointing from) `me'.
  I hope this patch solve #11244.
* vm_method.c: remove `rb_' prefix from some static functions.
* method.h (rb_method_entry_create): constify
* gc.c (mark_method_entry): add checking `def' and
  `def->body.iseq.iseqptr' availability because they can be NULL.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-25 07:59:23 +00:00
ko1 988267d462 * vm_method.c (rb_method_definition_reset): need a WB for
VM_METHOD_TYPE_ATTRSET.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-24 21:44:58 +00:00
nobu 220f9d5053 vm_method.c: use the current visibility
* vm_method.c (rb_attr): simply use the current visibility,
  instead of tests for each visibilities.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-24 08:31:43 +00:00
nobu d92b0dc58a vm_method.c: remove redundant check
* vm_method.c (rb_attr): remove redundant check.  attribute names
  given in ruby level should be checked before calling this
  function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-24 08:29:03 +00:00
ko1 a5fa5f34b0 * method.h: embed rb_method_entry_t::attr::flags (5 bits) into
rb_method_entry_t::flags to make one word spare space.
  Add some macros to access these flags.
* vm_method.c: use these macros.
* internal.h: define IMEMO_FL_USHIFT and IMEMO_FL_USER[0-4]
  for T_IMEMO local flags.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-10 23:55:33 +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 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 0f419d39b4 * vm_method.c (rb_add_method_iseq): use intermediate struct to
avoid initializing struct with variables.
  [Bug #11217]
* method.h: add a comment about it.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04 16:08:40 +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 4ab762de21 * vm_method.c: rename `rb_frame_...' to `rb_scope_...'.
* eval_intern.h: move decl. of rb_scope_visibility_set() to method.h.
* load.c: catch up this fix.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 14:07:24 +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
mame ea0bc53ec3 * vm_method.c (rb_method_definition_set): remove a double assignment.
Coverity Scan found this bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 16:28:50 +00:00
ko1 721e096ffd * vm_method.c (rb_alias): rename parameter names.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 15:06:29 +00:00
ko1 ac88162198 * method.h: remove rb_method_iseq_t::iseqval.
While making a r50728, iseqval is needed (to mark correctly),
  but now just iseqptr is enough.
* class.c: catch up this fix.
* gc.c: ditto.
* proc.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02 14:32:33 +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
ko1 7221252ab1 * vm_method.c (rb_method_entry_make): do not show warning message
when method_entry is an alias.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-01 10:26:05 +00:00
ko1 cd909b553f * class.c: remove needless include pragmra for method.h.
* struct.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-01 06:44:16 +00:00
nobu 473427a391 vm_method.c: suppress warning
* vm_method.c (rb_frame_visibility_check): suppress comparison
  warning by gcc 4.8 and 4.9.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-31 23:06:25 +00:00
ko1 1611735b29 * eval_intern.h, vm_method.c: move macros to functions.
* SCOPE_TEST(f)  -> rb_frame_visibility_test(flag).
  * SCOPE_CHECK(f) -> rb_frame_visibility_check(flag).
  * SCOPE_SET(f)   -> rb_frame_visibility_set(flag).
* load.c (load_ext): use it.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-31 20:44:56 +00:00
ko1 9794af357e fix indent
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 19:58:08 +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
ko1 255c16b598 * vm_method.c (rb_unlink_method_entry): make it static.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 18:35:21 +00:00
ko1 9cf6751f83 * method.h, vm_method.c (rb_free_method_entry): constify a parameter.
* vm_method.c (rb_unlink_method_entry): constify a parameter.
* vm_core.h: remove useless declaration about rb_unlink_method_entry().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-30 18:30:42 +00:00
shugo 834d2bbe4d * vm_method.c (rb_alias): should resolve refined methods.
[ruby-core:69360] [Bug #11182]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-26 13:16:18 +00:00
ko1 7239111ef5 * iseq.c: constify.
* iseq.h: ditto.
* method.h: ditto.
* proc.c: ditto.
* vm_method.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 09:01:44 +00:00
zzak 32a5a098e3 * vm_method.c: Remove private attribute warning [Bug #10967]
Patch by @spastorino [Fixes GH-849]
  https://github.com/ruby/ruby/pull/849

* test/ruby/test_module.rb: Update test for changes


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-21 06:40:27 +00:00
ko1 8dced4d2c0 * internal.h: define rb_cref_t and change to use it.
rb_cref_t is data type of CREF. Now, the body is still NODE.
  It is easy to understand what is CREF and what is pure NODE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08 21:22:43 +00:00
ko1 ae166317a4 * internal.h: define CREF accessor macros.
* CREF_CLASS(cref)
  * CREF_NEXT(cref)
  * CREF_VISI(cref)
  * CREF_VISI_SET(cref, v)
  * CREF_REFINEMENTS(cref)
  * CREF_PUSHED_BY_EVAL(cref)
  * CREF_PUSHED_BY_EVAL_SET(cref)
  * CREF_OMOD_SHARED(cref)
  * CREF_OMOD_SHARED_SET(cref)
  * CREF_OMOD_SHARED_UNSET(cref)
  This is process to change CREF data type from NODE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08 19:50:37 +00:00
ko1 d84f9b1694 * fix namespace issue on singleton class expressions. [Bug #10943]
* vm_core.h, method.h: remove rb_iseq_t::cref_stack. CREF is stored
  to rb_method_definition_t::body.iseq_body.cref.
* vm_insnhelper.c: modify SVAR usage.
  When calling ISEQ type method, push CREF information onto method
  frame, SVAR located place. Before this fix, SVAR is simply nil.
  After this patch, CREF (or NULL == Qfalse for not iseq methods)
  is stored at the method invocation.
  When SVAR is requierd, then put NODE_IF onto SVAR location,
  and NDOE_IF::nd_reserved points CREF itself.
* vm.c (vm_cref_new, vm_cref_dump, vm_cref_new_toplevel): added.
* vm_insnhelper.c (vm_push_frame): accept CREF.
* method.h, vm_method.c (rb_add_method_iseq): added. This function
  accepts iseq and CREF.
* class.c (clone_method): use rb_add_method_iseq().
* gc.c (mark_method_entry): mark method_entry::body.iseq_body.cref.
* iseq.c: remove CREF related codes.
* insns.def (getinlinecache/setinlinecache): CREF should be cache key
  because a different CREF has a different namespace.
* node.c (rb_gc_mark_node): mark NODE_IF::nd_reserved for SVAR.
* proc.c: catch up changes.
* struct.c: ditto.
* insns.def: ditto.
* vm_args.c (raise_argument_error): ditto.
* vm_eval.c: ditto.
* test/ruby/test_class.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-06 12:24:58 +00:00
nobu 4194ca02fb revert r45487
* variable.c (rb_alias_variable): IDs are always immportal now, no
  pin down is needed.

* vm_method.c (rb_method_entry_make): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-06 02:33:47 +00:00
shugo 525f515f9a * vm_method.c (remove_method): When remove refined
method, raise a NameError if the method is not
  defined in refined class.

  But if the method is defined in refined class,
  it should keep refined method and remove original
  method.

  Patch by Seiei Higa. [ruby-core:67722] [Bug #10765]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-03 06:26:48 +00:00
nobu 0fb2cd458b class.c: add callback argument
* class.c (rb_class_foreach_subclass): add argument for callback
  function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-19 14:09:20 +00:00
nobu dd1baaabcd vm_method.c: method defined should not use refinements.
* vm_method.c (check_definition): Module#public_method_defined?,
  Module#private_method_defined?, Module#protected_method_defined?
  should not use refinements. [ruby-core:67656] [Bug #10753]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-18 06:57:34 +00:00
nobu a11e25432b method.h: UNDEFINED_REFINED_METHOD_P
* method.h (UNDEFINED_REFINED_METHOD_P): macro to tell if refined
  original method is defined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-12 08:18:10 +00:00
nobu 1abd51ad91 vm_method.c: NameError at refined method alias
* vm_method.c (rb_alias): raise a NameError when creating alias to
  a refined method if the original method of the refined method is
  not defined.  [ruby-core:67523] [Bug #10731]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-12 07:45:49 +00:00
nobu 3f8ceab90e vm_method.c: no super klass, no original method entry
* vm_method.c (rb_method_entry): if no super class, no original
  method entry.  [ruby-core:67389] [Bug #10707]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-08 08:05:03 +00:00
nobu 459894160e vm_method.c: fix change refined new method visibility
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-08 07:31:45 +00:00
nobu 91e2cd34d4 vm_method.c: preserve encodings
* vm_method.c (rb_mod_remove_method): preserve encodings of method
  name and class name in error messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-25 18:58:05 +00:00
nobu f2fc80cebe vm_method.c: preserve encodings
* vm_method.c (rb_method_entry_make): preserve encodings of
  constant names in warning messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-25 18:44:12 +00:00
nobu 4b8cb23a36 intern.h: deprecate disable and enable super
* include/ruby/intern.h (rb_disable_super, rb_enable_super): warn
  as deprecated at build time, instead of ignoring silently or
  warning at runtime only.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-05 08:20:31 +00:00
nobu 2c8db2c24c vm_method.c: get rid of cache
* vm_method.c (rb_method_entry_make): get rid of storing method
  cache, so that the added method will be called later.
  [ruby-dev:48691] [Bug #10421]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-23 16:02:46 +00:00
nobu 8dc89b34c1 vm_method.c: no redefinition warnings for undefined methods
* vm_method.c (rb_method_entry_make): warn redefinition only for
  already defined methods, but not for undefined methods.
  [ruby-dev:48691] [Bug #10421]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-23 10:13:29 +00:00
nobu 4cd2a4d74a vm_method.c: configurable global method cache size
* vm_method.c (Init_Method): make global method cache size
  configurable by environment variable
  "RUBY_GLOBAL_METHOD_CACHE_SIZE"  [Fix GH-719]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-18 00:36:37 +00:00
nobu f2f81900ce vm_method.c: single expression
* vm_method.c (GLOBAL_METHOD_CACHE): make a single expression.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-17 00:54:10 +00:00
nobu b41909f603 vm_method.c: should not modify frozen objects
* vm_method.c (rb_method_entry_make, remove_method): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-12 08:13:28 +00:00
normal 5ab146166e vm_method.c (release_method_definition): use rb_free_method_entry
We are not currently avoiding recursion by calling
release_method_definition, so use rb_free_method_entry directly
to make changing code easier in case we change the way
rb_method_entry_t is allocated.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-12 01:17:17 +00:00
nobu 00b040b8d5 thread.c, vm_method.c: avoid inadvertent pin-down
* thread.c (rb_thread_variable_set): get rid of inadvertent dynamic
  symbol pin-down.

* vm_method.c (obj_respond_to): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-30 12:36:34 +00:00
ko1 76a929a7fc * parse.y: change Symbol <-> ID relationship to avoid
exposing IDs from collectable symbols.
  [Bug #10014]
  Now, rb_check_id() returns 0 if corresponding symbol is
  pinned dynamic symbol.
  There is remaining intern_cstr_without_pindown(), it can return
  IDs from collectable symbols. We must be careful to use it
  (only used in parse.y).  I think it should be removed if
  it does not have impact for performance.
* parse.y:
  add:
  * STATIC_SYM2ID()
  * STATIC_ID2SYM()
  rename:
  * rb_pin_dynamic_symbol() -> dsymbol_pindown()
* internal.h:
  remove:
  * rb_check_id_without_pindown()
  * rb_sym2id_without_pindown()
  add:
  * rb_check_symbol()
  * rb_check_symbol_cstr()
* load.c: use rb_check_id() or rb_check_id_cstr().
* object.c: ditto.
* struct.c: ditto.
* thread.c: ditto.
* vm_method.c: ditto.
* string.c (sym_find): use only rb_check_symbol().
* sprintf.c (rb_str_format): use rb_check_symbol_cstr().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-09 06:14:41 +00:00
nobu e99ee55abc constify parameters
* include/ruby/intern.h: constify `argv` parameters.

* include/ruby/ruby.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18 06:16:39 +00:00
nobu 3a206c9124 vm_method.c: no RTEST on mere flag
* vm_method.c (basic_obj_respond_to): `priv` is not a VALUE but a
  mere flag, so cannot call RTEST() on it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-16 08:03:42 +00:00
nobu 800c7af73c vm_method.c: separate ID selection
* vm_method.c (rb_method_entry_make): separate selection of IDs to
  be private from condition of method to be defined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-15 13:21:21 +00:00
nobu 6b9b85318a variable.c, vm_method.c: pin down
* variable.c (rb_alias_variable): ensure pinned down.

* vm_method.c (rb_method_entry_make): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-31 14:38:38 +00:00
nari 90b7073842 * parse.y: support Symbol GC. [ruby-trunk Feature #9634]
See this ticket about Symbol GC.

* include/ruby/ruby.h:
  Declare few functions.
  * rb_sym2id: almost same as old SYM2ID but support dynamic symbols.
  * rb_id2sym: almost same as old ID2SYM but support dynamic symbols.
  * rb_sym2str: almost same as `rb_id2str(SYM2ID(sym))` but not
    pin down a dynamic symbol.
  Declare a new struct.
  * struct RSymbol: represents a dynamic symbol as object in
    Ruby's heaps.
  Add few macros.
  * STATIC_SYM_P: check a static symbol.
  * DYNAMIC_SYM_P: check a dynamic symbol.
  * RSYMBOL: cast to RSymbol

* gc.c: declare RSymbol. support T_SYMBOL.

* internal.h: Declare few functions.
  * rb_gc_free_dsymbol: free up a dynamic symbol. GC call this
    function at a sweep phase.
  * rb_str_dynamic_intern: convert a string to a dynamic symbol.
  * rb_check_id_without_pindown: not pinning function.
  * rb_sym2id_without_pindown: ditto.
  * rb_check_id_cstr_without_pindown: ditto.

* string.c (Init_String): String#intern and String#to_sym use
  rb_str_dynamic_intern.

* template/id.h.tmpl: use LSB of ID as a flag for determining a
  static symbol, so we shift left other ruby_id_types.

* string.c: use rb_sym2str instead `rb_id2str(SYM2ID(sym))` to
  avoid pinning.

* load.c: use xx_without_pindown function at creating temporary ID
  to avoid pinning.

* object.c: ditto.

* sprintf.c: ditto.

* struct.c: ditto.

* thread.c: ditto.

* variable.c: ditto.

* vm_method.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 04:57:47 +00:00
nobu 0ab88d13a1 vm_method.c fix commit miss
* vm_method.c (rb_method_entry_get_without_cache): fix commit miss.
  remove extra !.  [Bug #9663]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-23 02:05:52 +00:00
nobu bedc6fdf88 vm_method.c: check if klass is 0
* vm_method.c (rb_method_entry_get_without_cache): me->klass is 0
  for a method aliased in a module.  [ruby-core:61636] [Bug #9663]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-23 02:03:51 +00:00
nobu 3453070fbc vm_method.c: fix infinite recursion
* vm_method.c (rb_method_entry_get_without_cache): get rid of
  infinite recursion at aliases in a subclass and a superclass.
  return actually defined class for other than singleton class.
  [ruby-core:60431] [Bug #9475]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-20 03:31:28 +00:00
nobu 053ead3679 vm_method.c: cast via VALUE
* vm_method.c (rb_add_method, rb_attr): cast between pointer and
  ID via VALUE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-15 02:19:32 +00:00
normal 4e12ff9225 vm_method.c: disable GMC writing if GMC is disabled
* vm_method.c (rb_method_entry_get_without_cache): disable GMC
  writing if GMC is disabled
  [ruby-core:61218]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02 23:24:38 +00:00
shugo 4d33c0e965 * vm_insnhelper.c (vm_call_method): should check ci->me->flag of
a refining method in case the method is private.
  [ruby-core:60111] [Bug #9452]

* vm_method.c (make_method_entry_refined): set me->flag of a refined
  method entry to NOEX_PUBLIC in case the original method is private
  and it is refined as a public method.  The original flag is stored
  in me->def->body.orig_me, so it's OK to make a refined method
  entry public.  [ruby-core:60111] [Bug #9452]

* test/ruby/test_refinement.rb: related tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-13 14:44:41 +00:00
tmm1 96225160f6 vm_method.c: use RCLASS_SERIAL macro instead of direct access
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 22:40:53 +00:00
tmm1 6944b38f7f fix typo: s/POWOR/POWER/
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 21:07:00 +00:00
nobu eda9023335 vm_method: set automatically
* vm_method.c (GLOBAL_METHOD_CACHE_MASK): set from
  GLOBAL_METHOD_CACHE_SIZE automatically.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 10:01:14 +00:00
ko1 f11b54213a * vm_method.c: check definition of
GLOBAL_METHOD_CACHE_SIZE and GLOBAL_METHOD_CACHE_MASK.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 08:57:24 +00:00
ko1 c702005a7b * include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN into
RB_OBJ_WRITE and RB_OBJ_WRITTEN.
* array.c, class.c, compile.c, hash.c, internal.h, iseq.c,
  proc.c, process.c, re.c, string.c, variable.c, vm.c,
  vm_eval.c, vm_insnhelper.c, vm_insnhelper.h,
  vm_method.c: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20 08:07:47 +00:00
ko1 d8eb7f3c0d * vm_method.c (rb_method_entry_make): fix WB miss.
Note that rb_method_entry_t::klass is not constified.
  We may  constify this field.
* test/ruby/test_alias.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-16 07:46:48 +00:00
nobu b71956d12b proc.c, vm_method.c: fix super and alias
* proc.c (method_owner): return the class where alias is defined, not
  the class original method is defined.
* vm_method.c (rb_method_entry_make, rb_alias): store the originally
  defined class in me.  [Bug #7993] [Bug #7842] [Bug #9236]
* vm_method.c (rb_method_entry_get_without_cache): cache included
  module but not iclass.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13 13:29:23 +00:00
nobu f2c319395d vm.c: reduce clearing method cache
* vm_method.c (rb_add_method, rb_alias): rb_method_entry_set()
  already clears method cache.

* vm_method.c (rb_export_method): ditto by rb_add_method().

* vm_method.c (set_method_visibility): ditto by rb_export_method().

* vm.c (vm_define_method): ditto by rb_add_method().

* vm.c (m_core_undef_method): ditto by rb_add_method() in rb_undef().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13 03:23:42 +00:00
tmm1 4092574257 vm_method.c: add new ruby::method-cache-clear dtrace probe
* vm_method.c (rb_clear_method_cache_by_class): fire
  ruby::method-cache-clear probe on global or klass-level method cache
  clear [Bug #9190]
* probes.d (provider ruby): new dtrace probe
* doc/dtrace_probes.rdoc: docs for new probe
* test/dtrace/test_method_cache.rb: test for new probe

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-09 22:50:44 +00:00
charliesome c039c70815 * internal.h (RCLASS_SERIAL): Add RCLASS_SERIAL as a convenience
accessor for RCLASS_EXT(klass)->class_serial.

* class.c, vm_insnhelper.c, vm_method.c: Use RCLASS_SERIAL

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-09 11:00:23 +00:00
charliesome 7df9798126 * compile.c, insns.def, test/ruby/test_rubyvm.rb, vm.c, vm_core.h,
vm_insnhelper.c, vm_insnhelper.h, vm_method.c: Rename method_serial
  to global_method_state and constant_serial to global_constant_state
  after discussion with ko1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-09 10:51:02 +00:00
charliesome 8b0771b014 * class.c: unify names of vm state version counters to 'serial'.
This includes renaming 'vm_state_version_t' to 'rb_serial_t',
  'method_state' to 'method_serial', 'seq' to 'class_serial',
  'vmstat' to 'constant_serial', etc.

* insns.def: ditto
* internal.h: ditto
* vm.c: ditto
* vm_core.h: ditto
* vm_insnhelper.c: ditto
* vm_insnhelper.h: ditto
* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 03:34:49 +00:00
ko1 667a519db3 * vm_method.c (rb_method_entry_make): fix to pass an ISeq value.
OBJ_WRITTEN() accepts only VALUE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-31 05:26:00 +00:00
charliesome 7fafa8f376 * insns.def, vm.c, vm_insnhelper.c, vm_insnhelper.h, vm_method.c: split
ruby_vm_global_state_version into two separate counters - one for the
  global method state and one for the global constant state. This means
  changes to constants do not affect method caches, and changes to
  methods do not affect constant caches. In particular, this means
  inclusions of modules containing constants no longer globally
  invalidate the method cache.

* class.c, eval.c, include/ruby/intern.h, insns.def, vm.c, vm_method.c:
  rename rb_clear_cache_by_class to rb_clear_method_cache_by_class

* class.c, include/ruby/intern.h, variable.c, vm_method.c: add
  rb_clear_constant_cache

* compile.c, vm_core.h, vm_insnhelper.c: rename vmstat field in
  rb_call_info_struct to method_state

* vm_method.c: rename vmstat field in struct cache_entry to method_state

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 00:52:38 +00:00
shugo f8e0e1647e * vm_insnhelper.c (vm_call_method): set ci->me to 0 when the
original method of a refined method is undef to avoid SEGV.

* vm_method.c (rb_method_entry_without_refinements): return 0 when
  the original method of a refined method is undef to avoid SEGV.

* test/ruby/test_refinement.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-17 08:44:26 +00:00
ko1 86b2e9d090 * vm_method.c (rb_gc_mark_unlinked_live_method_entries):
revert last commit to introduce debug prints.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 18:26:00 +00:00
ko1 9d70a17541 revert r43259 because it is possible to mark miss classes defined in C-exts. Thanks charliesome.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 18:03:43 +00:00
nobu 24cf72029f object.c: avoid inadvertent symbol creation
* object.c (id_for_attr): avoid inadvertent symbol creation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-09 14:57:04 +00:00
nobu e70f74c3d2 vm_method.c: preserve encoding
* vm_method.c (rb_attr): preserve encoding of the attribute ID in
  error message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-09 09:03:07 +00:00
ko1 40b1aa9adf * proc.c: catch up last commit.
Type of return value of rb_iseq_first_lineno() is now VALUE.
* vm_insnhelper.c (argument_error): ditto.
* vm_method.c (rb_method_entry_make): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-07 05:31:47 +00:00
ko1 12f368d6a4 * iseq.c, internal.h: change to public (but internal) functions
* VALUE rb_iseq_path(VALUE iseqval);
* VALUE rb_iseq_absolute_path(VALUE iseqval);
* VALUE rb_iseq_label(VALUE iseqval);
* VALUE rb_iseq_base_label(VALUE iseqval);
* VALUE rb_iseq_first_lineno(VALUE iseqval);
  And new (temporary) function:
* VALUE rb_iseq_klass(VALUE iseqval);
* iseq.c. vm_core.h (int rb_iseq_first_lineno): remove
  function `int rb_iseq_first_lineno(const rb_iseq_t *iseq)'.
  Use `VALUE rb_iseq_first_lineno(VALUE iseqval)' instead.
* proc.c. vm_insnhelper.c, vm_method.c: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-07 05:12:08 +00:00
shugo 59f5fa102a * vm_method.c (rb_undef): raise a NameError if the original method
of a refined method is not defined.

* vm_insnhelper.c (rb_method_entry_eq): added NULL check to avoid SEGV.

* test/ruby/test_refinement.rb: related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-30 01:49:21 +00:00
charliesome 4cf9b6694f * gc.c (free_method_cache_entry_i): unused function
* gc.c (rb_free_mc_table): ditto

* internal.h (method_cache_entry_t): unused struct

* vm_method.c (verify_method_cache): remove unused variable

* vm_method.c (rb_method_entry): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-24 05:09:57 +00:00
charliesome f088828106 * class.c (class_alloc): remove mc_tbl
* gc.c (obj_free): ditto

* internal.h (struct rb_classext_struct): ditto

* method.h (rb_method_entry): remove ent param

* vm_method.c: restore the global method cache. Per class cache tables
  turned out to be far too slow.

  [ruby-core:57289] [Bug #8930]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-24 05:02:13 +00:00
nobu 9d9dfc2172 vm_method.c: constify
* vm_method.c (rb_resolve_refined_method): constify.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-10 03:39:28 +00:00
nobu a71ee2ce41 vm_method.c: clear cache after refine method
* vm_method.c (rb_add_refined_method_entry): clear cache in the
  refined class since refining a method entry is modifying the class.
  [ruby-core:57079] [Bug #8880]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-09 07:56:02 +00:00
nobu eeb39e0152 vm.c: prototype
* vm.c (rb_next_class_sequence): use ANSI style definition and
  prorotype declaration, instead of old-K&R style.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 07:18:24 +00:00
charliesome 2f522b9cc6 * class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h,
  vm_method.c: Implement class hierarchy method cache invalidation.

  [ruby-core:55053] [Feature #8426] [GH-387]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 05:25:06 +00:00
nobu 07bf69b085 vm_method.c: [DOC] example of respond_to_missing?
* vm_method.c (obj_respond_to_missing): [DOC] respond_to_missing? is
  used in the example of BasicObject.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-31 04:30:18 +00:00
ktsj fe360c463c * variable.c, vm_method.c: remove dead code.
* test/ruby/test_fiber.rb, test/ruby/test_thread.rb:
  change accordingly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-18 11:27:42 +00:00
ko1 7da562e740 * class.c (rb_include_class_new), eval.c (rb_using_refinement):
make classes/modules (who share method table) shady.
  If module `a' and `b' shares method table m_tbl and new method
  with iseq is added, then write barrier is applied only `a' or `b'.
  To avoid this issue, shade such classes/modules.
* vm_method.c (rb_method_entry_make): add write barriers.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 20:48:35 +00:00
ko1 4223f00713 * include/ruby/ruby.h (OBJ_WRITE): cast to (VALUE *) for second
parameter `slot'. You don't need to write a cast (VALUE *) any more.
* class.c, compile.c, hash.c, iseq.c, proc.c, re.c, variable.c,
  vm.c, vm_method.c: remove cast expressions for OBJ_WRITE().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 19:52:40 +00:00
ko1 87a120fbdc * class.c, include/ruby/ruby.h: add write barriers for T_CLASS,
T_MODULE, T_ICLASS.
* constant.h: constify rb_const_entry_t::value and file to detect
  assignment.
* variable.c, internal.h (rb_st_insert_id_and_value, rb_st_copy):
  added. update table with write barrier.
* method.h: constify some variables to detect assignment.
* object.c (init_copy): add WBs.
* variable.c: ditto.
* vm_method.c (rb_add_method): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-14 09:23:54 +00:00
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
nobu 64ed7df543 vm_method.c: change argument of set_visibility
* vm_method.c (set_visibility): use rb_method_flag_t as well as
  set_method_visibility() and rename argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-06 14:40:35 +00:00