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
* 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
* 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
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
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
* 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
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
* 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
`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
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
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
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
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
* 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
* 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
* 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
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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
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
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