summaryrefslogtreecommitdiff
path: root/eval.c
AgeCommit message (Collapse)Author
2015-07-06* vm_core.h: remove rb_iseq_t::defined_method_id because it is notko1
needed. * eval.c (frame_func_id): simplify. rb_callable_method_entry_t has enough information. * eval.c (frame_called_id): ditto. * iseq.c (prepare_iseq_build): catch up this fix. * proc.c (rb_mod_define_method): ditto. * vm.c (vm_define_method): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-03* method.h: introduce rb_callable_method_entry_t to removeko1
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-06-29* eval.c (add_activated_refinement): should not include the originalshugo
class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-02* method.h: make rb_method_entry_t a VALUE.ko1
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-03-11* eval.c (frame_called_id): it should use vm_ifunc type.ko1
* eval.c (frame_func_id): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-10* vm_insnhelper.h: define struct THROW_DATA to representko1
throwing data. Also define accessor functions. * eval_intern.h: move related changes into vm_insnhelper.h. Now these MACROs (functions) are only used in vm*.c. There is only THROW_DATA_P(err) to check this data type or not. * vm.c: catch up these changes. * vm_eval.c: ditto. * vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08* internal.h: define rb_cref_t and change to use it.ko1
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* internal.h: define CREF accessor macros.ko1
* 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-05* internal.h: remove struct method_table_wrapper.ko1
struct method_table_wrapper was introduced to avoid duplicate marking for method tables. For example, `module M1; def foo; end; end` make one method table (mtbl) contains a method `foo`. M1 (T_MODULE) points mtbl. Classes C1 and C2 includes M1, then two T_ICLASS objects are created and they points mtbl too. In this case, three objects (one T_MODULE and two T_ICLASS objects) points same mtbl. On marking phase, these three objects mark same mtbl. To avoid such duplication, struct method_table_wrapper was introduced. However, created two T_ICLASS objects have same or shorter lifetime than M1 (T_MODULE) object. So that we only need to mark mtbl from M1, not from T_ICLASS objects. This patch tries marking only from M1. Note that one `Module#prepend` call creates two T_ICLASS objects. One for refering to a prepending Module object, same as `Module#include`. We don't nedd to care this T_ICLASS. One for moving original mtbl from a prepending class. We need to mark such mtbl from this T_ICLASS object. To mark the mtbl, we need to use `RCLASS_ORIGIN(klass)` on marking from a prepended class `klass`. * class.c: ditto. * eval.c (rb_using_refinement): ditto. * gc.c: ditto. * include/ruby/ruby.h: define m_tbl directly. The definition of struct RClass should be moved to (srcdir)/internal.h. * method.h: remove decl of rb_free_m_tbl_wrapper(). * object.c: use RCLASS_M_TBL() directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-24eval.c: use the given threadnobu
* eval.c (setup_exception): use the given thread instead of implicit current thread. * load.c (rb_load_internal0): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-23eval.c: static IDsnobu
* eval.c (ruby_static_id_signo, ruby_static_id_status): add static IDs, signo and status. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-02* eval.c (ruby_init): Print ruby_setup() error only in debug mode.akr
Unsupressable error message is not a good idea. Note that the message is printed sometimes with following code (highly timing dependent, though): pid = spawn("ruby -e ''"); Process.kill(:TERM, pid) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-09thread.c: get rid of invalid ID symbolnobu
* eval.c (rb_frame_last_func): return the most recent frame method name. * thread.c (recursive_list_access): use the last method name, instead of the current method name which can be unset in some cases, not to use a symbol by the invalid ID. [ruby-core:66742] [Bug #10579] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18* internal.h: Gather declarations in non-header files.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-16id.def: move IDs for exceptionnobu
* defs/id.def: add :mesg and :exception and move from other sources. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15* internal.h: Include ruby.h and ruby/encoding.h to beakr
includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13eval.c: obsolete comment [ci skip]nobu
* eval.c (rb_ensure): remove obsolete prot_tag comment. patch by Jack Danger at [ruby-core:66238]. [misc #10502] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-30protoize no-arguments functionsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-13eval.c: fix message as same as previous versionsnobu
* eval.c (rb_frozen_class_p): fix message for singleton class of class/module as same as previous versions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-12ruby/ruby.h: freeze singleton classnobu
* include/ruby/ruby.h (rb_obj_freeze_inline): propagate freezing to the singleton class if it is existing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-12vm_method.c: should not modify frozen objectsnobu
* 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-11* vm.c (rb_vm_register_special_exception): make new function toko1
make and register special exceptions. * vm.c (rb_vm_mark): do not need to mark special exceptions because they are registerd by rb_gc_register_mark_object(). * eval.c (Init_eval): use rb_vm_register_special_exception(). * gc.c (Init_GC): ditto. * proc.c (Init_Proc): ditto. * thread.c (Init_Thread): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-29string.c: move frozen_strings table to rb_vm_tnormal
Cleanup in case MVM development proceeds. * string.c: remove static frozen_strings * string.c (Init_frozen_strings): new function * string.c (rb_fstring): remove check for frozen strings, use per-VM table * string.c (rb_str_free): use per-VM table * string.c (Init_String): use per-VM table * vm_core.h (rb_vm_t): add frozen_strings table * internal.h (Init_frozen_strings): new function prototype * eval.c (ruby_setup): call Init_frozen_strings [Feature #10182] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47310 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-28eval.c: no overwrite SystemStackError backtracenobu
* eval.c (setup_exception): should not overwrite SystemStackError backtrace if set already. [ruby-core:63377] [Feature #6216] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-28eval.c: no method calls at stack overflownobu
* eval.c (setup_exception): get rid of method calls before raising stack overflow, not to cause stack overflow again. * defs/id.def: add IDs for backtraces. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-27eval.c: reduce machine stack overflow backtracenobu
* eval.c (setup_exception): revert r46531 to reduce backtrace at machine stack overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-26eval.c: suppress a warningnobu
* eval.c (setup_exception): suppress a maybe-uninitialized false warning by gcc 4.8. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23* eval.c (setup_exception): "mesg == sysstack_error" andnaruse
sysstack_error_p(mesg) are duplicated. r46502 seems to want to use latter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-23Backtrace for SystemStackErrornobu
* eval.c (setup_exception): set backtrace in system stack error other than the pre-allocated sysstack_error. [Feature #6216] * proc.c (Init_Proc): freeze the pre-allocated sysstack_error. * vm_insnhelper.c (vm_stackoverflow): raise new instance for each times without calling any methods to keep the backtrace with no further stack overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-19* vm.c (rb_vm_rewind_cfp): add new function to rewind specified cfpko1
with invoking RUBY_EVENT_C_RETURN. [Bug #9961] * vm_core.h: ditto. * eval.c (rb_protect): use it. * eval.c (rb_rescue2): ditto. * vm_eval.c (rb_iterate): ditto. * test/ruby/test_settracefunc.rb: add a test. * vm_core.h (rb_name_err_mesg_new): git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18constify parametersnobu
* 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-17eval.c: pass unknown optionsnobu
* eval.c (extract_raise_opts): pass unknown options to the exception, so that exception class can receive a hash argument. [ruby-core:63203] [Feature #8257] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-02* eval.c (rb_using_refinement): add write-barriers forko1
cref->nd_refinements. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-06eval.c: method namenobu
* eval.c (setup_exception): add the method name to system stack error message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-04vm.c: Init_vm_objectsnobu
* vm.c (Init_vm_objects): initialize VM internal objects, after heap initialized. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-20* include/ruby/intern.h (rb_obj_call_init, rb_class_new_instance):ko1
constify a parameter (VALUE *). I believe this incompatibility doesn't break any code. However, if you have trouble, please tell us. * eval.c, object.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-09* eval.c: remove needless space.hsbt
[ruby-dev:48026] [Bug #9615] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-26eval.c: suppress a warningnobu
* eval.c (setup_exception): suppress a "clobbered" warning by gcc 4.9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-26eval.c: preserve encodingnobu
* eval.c (setup_exception): preserve exception class name encoding in debug mode messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-26eval.c: preserve errinfonobu
* eval.c (setup_exception): preserve errinfo across calling #to_s method on the exception. [ruby-core:61091] [Bug #9568] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-26eval.c: remove unneeded GC guardnobu
* eval.c (setup_exception): remove RB_GC_GUARD which is no longer needed since r41598. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-17eval.c: singleton class constantsnobu
* eval.c (rb_mod_s_constants): return its own constants for other than Module itself. [ruby-core:59763] [Bug #9413] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-09* vm.c (rb_vm_pop_cfunc_frame): added. It cares c_return event.ko1
The patch base by drkaes (Stefan Kaes). [Bug #9321] * variable.c (rb_mod_const_missing): use rb_vm_pop_cfunc_frame() instead of rb_frame_pop(). * vm_eval.c (raise_method_missing): ditto. * vm_eval.c (rb_iterate): ditto. * internal.h (rb_vm_pop_cfunc_frame): add decl. * test/ruby/test_settracefunc.rb: add tests. provided by drkaes (Stefan Kaes). * vm.c, eval.c, include/ruby/intern.h (rb_frame_pop): move definition of rb_frame_pop() and deprecate it. It doesn't care about `return' events. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-01eval.c: extra modifiernobu
* eval.c (rb_longjmp): remove an extra modifier from the forward declaration to match the actual definition. [ruby-core:59451] [Bug #9338] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-31eval.c: raise with causenobu
* eval.c (rb_f_raise): add cause: optional keyword argument. [ruby-core:58610] [Feature #8257] [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-24eval.c: unused declarationnobu
* eval.c (rb_vm_get_cref): remove unused declaration. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13eval.c: reuse tagnobu
* eval.c (rb_rescue2): reuse tags pushed for body proc to protect rescue proc too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13* error.c: add Exception#backtrace_locations.ko1
Now, there are no setter and independent from Exception#backtrace. [Feature #8960] * eval.c (setup_exception): set backtrace locations for `bt_location' special attribute. * vm_backtrace.c (rb_backtrace_to_location_ary): added. * internal.h: ditto. * test/ruby/test_backtrace.rb: add a test for Exception#backtrace_locations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13eval.c: clear cachenobu
* eval.c (rb_using_module): clear method cache after applying refinements. * eval.c (mod_using, top_using): remove redundant type checks. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13eval.c: indentnobu
* eval.c (using_module_recursive): adjust indent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e