summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
AgeCommit message (Collapse)Author
2013-08-09* vm_insnhelper.c (vm_invoke_block): returning from lambda procktsj
now always exits from the Proc. [ruby-core:56193] [Feature #8693] * NEWS, test/ruby/test_lambda.rb: ditto. Patch by nobu. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-06* vm_insnhelper.c (vm_push_frame): change type of stack_max to size_t.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-06* vm_insnhelper.c (vm_push_frame): fix stack overflow check codes.ko1
Stack overflow check should be done *after* pushing a stack frame. However, some stack overflow checking codes checked *before* pushing a stack frame with iseq->stack_max. To solve this problem, add a new parameter `stack_max' to specify a possible consuming stack size. * vm_core.h (CHECK_VM_STACK_OVERFLOW0): add to share the stack overflow checking code. * insns.def: catch up this change. * vm.c, vm_eval.c: ditto. * test/ruby/test_exception.rb: add a stack overflow test. This code is reported by nobu. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-24* vm_insnhelper.c (vm_expandarray): use RARRAY_RAWPTR() instead ofko1
RARRAY_PTR() because there is no new reference. * vm_insnhelper.c (vm_caller_setup_args): ditto. * vm_insnhelper.c (vm_yield_setup_block_args): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18* vm_insnhelper.c (vm_call_method): ensure methods of typecharliesome
VM_METHOD_TYPE_ATTR_SET are called with 1 argument * test/ruby/test_module.rb (class TestModule): add test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-17* include/ruby/ruby.h, vm_eval.c (rb_funcall_with_block):ktsj
new function to invoke a method with a block passed as an argument. * string.c (sym_call): use the above function to avoid a block sharing. [ruby-dev:47438] [Bug #8531] * vm_insnhelper.c (vm_yield_with_cfunc): don't set block in the frame. * test/ruby/test_symbol.rb (TestSymbol#test_block_given_to_proc): run related tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12* safe.c (rb_set_safe_level, safe_setter): raise an ArgumentErrorshugo
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-04Add more comment about r41041naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-03* vm_insnhelper.c (vm_yield_setup_block_args): add comment for r41041.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-02* vm_insnhelper.c (vm_yield_setup_block_args): partially revert r41019.naruse
The code is not useless. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-01vm_insnhelper.c: extract keyword arguments after splatnobu
* vm_insnhelper.c (vm_yield_setup_block_args): split single parameter if any keyword arguments exist, and then extract keyword arguments. [ruby-core:55203] [Bug #8463] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-01vm_insnhelper.c: add commentsnobu
* vm_insnhelper.c (vm_yield_setup_block_args): break a long line and add comments. remove useless code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-30* vm_insnhelper.c (vm_callee_setup_keyword_arg,mame
vm_callee_setup_arg_complex): consider a hash argument for keyword only when the number of arguments is more than the expected mandatory parameters. [ruby-core:53199] [ruby-trunk - Bug #8040] * test/ruby/test_keyword.rb: update a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27vm_insnhelper.c: suppress warningnobu
* vm_insnhelper.c (vm_callee_setup_keyword_arg): suppress -Wsign-compare warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26* hash.c (rb_hash_tbl_raw), internal.h: added.ko1
Returns st_table without shading hash. * array.c: use rb_hash_tbl_raw() for read-only purpose. * compile.c (iseq_compile_each): ditto. * gc.c (count_objects): ditto. * insns.def: ditto. * process.c: ditto. * thread.c (clear_coverage): ditto. * vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* gc.c: support RGENGC. [ruby-trunk - Feature #8339]ko1
See this ticet about RGENGC. * gc.c: Add several flags: * RGENGC_DEBUG: if >0, then prints debug information. * RGENGC_CHECK_MODE: if >0, add assertions. * RGENGC_PROFILE: if >0, add profiling features. check GC.stat and GC::Profiler. * include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0). * array.c: add write barriers for T_ARRAY and generate sunny objects. * include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if you want to access raw pointers. If you modify the contents which pointer pointed, then you need to care write barrier. * bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects. * complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX and generate sunny objects. * rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write barriers for T_RATIONAL and generate sunny objects. * internal.h: add write barriers for RBasic::klass. * numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects. * object.c (rb_class_allocate_instance), range.c: generate sunny T_OBJECT objects. * string.c: add write barriers for T_STRING and generate sunny objects. * variable.c: add write barriers for ivars. * vm_insnhelper.c (vm_setivar): ditto. * include/ruby/ruby.h, debug.c: use two flags FL_WB_PROTECTED and FL_OLDGEN. * node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED): move flag bits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-05insns.def: refactor by wanabenobu
* insns.def (defined): use vm_search_superclass() like as normal super call. based on a patch <https://gist.github.com/wanabe/5520026> by wanabe. * vm_insnhelper.c (vm_search_superclass): return error but not raise exceptions. * vm_insnhelper.c (vm_search_super_method): check the result of vm_search_superclass and raise execptions on error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-12vm_insnhelper.c: non-symbol keynobu
* vm_insnhelper.c (vm_callee_setup_keyword_arg): non-symbol key is not a keyword argument, keep it as an positional argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-21vm_insnhelper.c: check required kwarg with resthashnobu
* vm_insnhelper.c (vm_callee_setup_keyword_arg): should check required keyword arguments even if rest hash is defined. [ruby-core:53608] [Bug #8139] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-12required keyword argumentsnobu
* compile.c (iseq_set_arguments, iseq_compile_each): support required keyword arguments. [ruby-core:51454] [Feature #7701] * iseq.c (rb_iseq_parameters): ditto. * parse.y (f_kw, f_block_kw): ditto. this syntax is still experimental, the notation may change. * vm_core.h (rb_iseq_struct): ditto. * vm_insnhelper.c (vm_callee_setup_keyword_arg): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-24vm_insnhelper.c: compare with me in method top cfpnobu
* vm_insnhelper.c (vm_call_method): block level control frame does not have method entry, so obtain the method entry from method top-level control frame to be compared with refined method entry. [ruby-core:52750] [Bug #7925] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-06* vm_insnhelper.c: attr_writer should return its argument [Bug #7773]marcandre
* test/ruby/test_basicinstructions.rb: Test for above git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-10* vm_insnhelper.c (vm_search_super_method): raise a TypeErrorshugo
instead of a NotImplementError if self is not an instance of the current class. [ruby-dev:39772] [Bug #2402] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-07vm_insnhelper.c: keyrest should not overwrite rest argnobu
* vm_insnhelper.c (vm_callee_setup_arg_complex, vm_yield_setup_block_args): set keyrest hash after making rest array, so that the last element will not be overwritten. [ruby-core:51278] [Bug #7665] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-30* vm_insnhelper.c: set keyword hash on Proc/block calls.ktsj
[ruby-core:51172] [Bug #7630] * test/ruby/test_keyword.rb: add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29use RB_TYPE_Pnobu
* enumerator.c (enumerator_initialize), eval.c (rb_using_refinement), (add_activated_refinement), numeric.c (num_interval_step_size), parse.y (arg, match_op_gen, cond0), range.c (range_bsearch), vm_insnhelper.c (vm_get_iclass): use RB_TYPE_P() to optimize. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-28vm_insnhelper.c: no splat single opt argnobu
* vm_insnhelper.c (vm_yield_setup_block_args): pass single argument to single optional parameter unchanged without splatting. [Bug #7621] [ruby-dev:46801] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-25* vm_core.h, eval_intern.h (CHECK_STACK_OVERFLOW): moveko1
CHECK_STACK_OVERFLOW() to vm_core.h and rename to CHECK_VM_STACK_OVERFLOW(). This change is only move and rename. * tool/instruction.rb: catch up above changes. * vm.c, vm_insnhelper.c: ditto. * vm_insnhelper.c (vm_stackoverflow): add a function to unify raising vm stackoverflow exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-17* method.h: remove `VM_METHOD_TYPE_CFUNC_FRAMELESS' method type.ko1
This method type is for optimized CFUNC such as Fixnum#+ and so on. This feature is half-baked and no way to use them. [Background] Now, VM has opt_plus instructions to optimize `+' methods for some Classes (such as Fixnum, Float (flonum)). We call this type of instructions as `specialized instructions'. This simple technique improve simple program dramatically. However, we can make specialized instructions for only several types (classes) and selectors (method names) because a large instruction will be slow. In other words, this technique has no extensibility. To overcome this problem, VM_METHOD_TYPE_CFUNC_FRAMELESS was introduced (r37198). This type is a variant of CFUNC, but called their functiions directly without building a method frame. Any CFUNC method can be defined as frameless methods if a method is not needed to make method frame. Frameless methods are faster as specialized instructions (a bit slower, but no need to care). No problem described at http://charlie.bz/blog/why-do-singleton-methods-make-ruby-slow because this technique doesn't see class, but see method body itself. Alias is also no problem. [Problem] However, we can't set frameless method type for polymorphic methods such as Array#[]. Necessity for method frame depends on which parameter type. For example, Fixnum#+ needs method frame if coerce is needed. Current VM_METHOD_TYPE_CFUNC_FRAMELESS is not flexible and need more tuning to introduce it. Expected behavior of frameless method type may be: result = optimized_cfunc(params); /* call optimized cfunc */ if (result == Qundef) { result = normal_cfunc(); } This is why I say this feature is half-baked. We need to learn primitive method in Smalltalk more. (I heard this name at RubyConf Taiwan this month. Thanks!) [Conclusion] Nobody may use this feature and there is no compatibility issue. This feature goes to next minor (2.1?). * proc.c (rb_method_entry_arity): ditto. * vm_eval.c, vm_insnhelper.c, vm_method.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-14* vm_insnhelper.c (vm_call_super_method): remove volatile introducedshugo
in r38365. * vm_insnhelper.c (vm_call_method): use __forceinline to prevent VC to make vm_call_general and vm_call_super_method as the same method. Thanks, Heesob Park. [Bug #7556] [ruby-core:50867] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13* vm_insnhelper.c (vm_call_super_method): a workaround for theshugo
failure of TestRefinement#test_refine_recursion in Windows. See [ruby-core:50871] for details. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13* method.h: remove "VM_METHOD_TYPE__MAX" from rb_method_type_t.ko1
rb_method_type_t is not a number and "_MAX" causes misunderstanding. * proc.c (rb_method_entry_arity): ditto. * vm_eval.c (vm_call0_body): ditto. * vm_insnhelper.c (vm_call_method): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-12method.h: NOEX_SAFE_SHIFT_OFFSETnobu
* method.h (rb_method_flag_t): name a magic number for NOEX_SAFE and NOEX_WITH as NOEX_SAFE_SHIFT_OFFSET. * method.h (rb_method_type_t, method_optimized_type): C89 forbids a comma after the last element in enum. * proc.c (rb_method_entry_arity), vm_eval.c (vm_call0_body), vm_insnhelper.c (vm_call_method): add VM_METHOD_TYPE__MAX case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-12vm_insnhelper.c: no warnings for non-objectnobu
* vm_insnhelper.c (vm_getivar): no uninitialized instance variables warnings for non-object if attr method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-12vm_insnhelper.c: common codenobu
* vm_insnhelper.c (vm_getivar, vm_setivar): unify common code irrelevant to the condition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-11fix typos for r38298kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-10* fix the behavior when a module is included into a refinement.shugo
This change is a little tricky, so it might be better to prohibit module inclusion to refinements. * include/ruby/ruby.h (RMODULE_INCLUDED_INTO_REFINEMENT): new flag to represent that a module (iclass) is included into a refinement. * class.c (include_modules_at): set RMODULE_INCLUDED_INTO_REFINEMENT if klass is a refinement. * eval.c (rb_mod_refine): set the superclass of a refinement to the refined class for super. * eval.c (rb_using_refinement): skip the above superclass (the refined class) when creating iclasses for refinements. Otherwise, `using Refinement1; using Refinement2' creates iclasses: <Refinement2> -> <RefinedClass> -> <Refinement1> -> RefinedClass, where <Module> is an iclass for Module, so RefinedClass is searched before Refinement1. The correct iclasses should be <Refinement2> -> <Refinement1> -> RefinedClass. * vm_insnhelper.c (vm_search_normal_superclass): if klass is an iclass for a refinement, use the refinement's superclass instead of the iclass's superclass. Otherwise, multiple refinements are searched by super. For example, if a refinement Refinement2 includes a module M (i.e., Refinement2 -> <M> -> RefinedClass, and if refinements iclasses are <Refinement2> -> <M>' -> <Refinement1> -> RefinedClass, then super in <Refinement2> should use Refinement2's superclass <M> instead of <Refinement2>'s superclass <M>'. * vm_insnhelper.c (vm_search_super_method): do not raise a NotImplementError if current_defind_class is a module included into a refinement. Because of the change of vm_search_normal_superclass(), the receiver might not be an instance of the module('s iclass). * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-10compile.c, vm_insnhelper.c: flip-flop without hidden string keynobu
* compile.c (iseq_compile_each): count flip-flop state in local iseq not in each iseqs, so that the keys can be other than hidden strings. [ruby-core:47253] [Bug #6899] * vm_insnhelper.c (lep_svar_get, lep_svar_set, vm_getspecial): store flip-flop states in an array instead of a hash. * iseq.c (set_relation): main iseq also can has local scope. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-09* vm_insnhelper.c (vm_call_opt_send): Kernel#send should not useshugo
refinements. * proc.c (mnew): Kernel#method, Kernel#public_method, Module#instance_method, and Module#public_instance_method should not use refinements. * vm_method.c (rb_method_boundp): Kernel#respond_to? should not use refinements. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-08* vm_insnhelper.c (vm_search_normal_superclass): super in ashugo
refinement always uses the refined class as its superclass. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-08* eval.c (rb_mod_refine): raise an ArgumentError if a givenshugo
block is of a Proc object. * vm_insnhelper.c (vm_call_method): store refined methods in inline cache to improve performance. It's safe now because blocks cannot be yielded with different refinements in the new specification. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-07* vm_eval.c (yield_under, eval_under): do not activate refinementsshugo
of the receiver in module_eval and instance_eval. * eval.c (ruby_Init_refinement): undef Class#refine. * eval.c (ruby_Init_refinement): remove Module#using. * eval.c (ruby_Init_refinement): main.using should be private. * eval.c (rb_mod_refine): the argument of Module#refine should not be a module. * insns.def (defineclass): do not activate refinements in a class or module. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-06* revised r37993 to avoid SEGV/ILL in tests. In r37993, a methodshugo
entry with VM_METHOD_TYPE_REFINED holds only the original method definition, so ci->me is set to a method entry allocated in the stack, and it causes SEGV/ILL. In this commit, a method entry with VM_METHOD_TYPE_REFINED holds the whole original method entry. Furthermore, rb_thread_mark() is changed to mark cfp->klass to avoid GC for iclasses created by copy_refinement_iclass(). * vm_method.c (rb_method_entry_make): add a method entry with VM_METHOD_TYPE_REFINED to the class refined by the refinement if the target module is a refinement. When a method entry with VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with the same name is searched in refinements. If such a method is found, the method is invoked. Otherwise, the original method in the refined class (rb_method_definition_t::body.orig_me) is invoked. This change is made to simplify the normal method lookup and to improve the performance of normal method calls. * vm_method.c (EXPR1, search_method, rb_method_entry), vm_eval.c (rb_call0, rb_search_method_entry): do not use refinements for method lookup. * vm_insnhelper.c (vm_call_method): search methods in refinements if ci->me is VM_METHOD_TYPE_REFINED. If the method is called by super (i.e., ci->call == vm_call_super_method), skip the same method entry as the current method to avoid infinite call of the same method. * class.c (include_modules_at): add a refined method entry for each method defined in a module included in a refinement. * class.c (rb_prepend_module): set an empty table to RCLASS_M_TBL(klass) to add refined method entries, because refinements should have priority over prepended modules. * proc.c (mnew): use rb_method_entry_with_refinements() to get a refined method. * vm.c (rb_thread_mark): mark cfp->klass for iclasses created by copy_refinement_iclass(). * vm.c (Init_VM), cont.c (fiber_init): initialize th->cfp->klass. * test/ruby/test_refinement.rb (test_inline_method_cache): do not skip the test because it should pass successfully. * test/ruby/test_refinement.rb (test_redefine_refined_method): new test for the case a refined method is redefined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01* variable.c (rb_class_path_no_cache): add a function to get the classtenderlove
path without caching the computed path. Some classes are frozen, and will raise an exception without this. * probes.d (cmethod-entry, cmethod-return): separate cmethods from regular methods to match set trace func. * probes_helper.h: refactor macros. Fix probes to avoid calling #inspect when profiling. * insns.def: update for use with new macros. * vm_eval.c: ditto * vm_insnhelper.c: ditto * test/dtrace/test_singleton_function.rb: fix test for new output. * test/dtrace/test_cmethod.rb: test the cmethod probes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30* revert r37993 to avoid SEGV in tests.shugo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29* vm.c: add a return hook when a method raises an exception.tenderlove
* probes_helper.h: look up klass and method if none are provided. * eval.c: update macro usage. * vm_eval.c: ditto. * vm_insnhelper.c: ditto. * test/dtrace/test_function_entry.rb: test for change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-29* vm_method.c (rb_method_entry_make): add a method entry withshugo
VM_METHOD_TYPE_REFINED to the class refined by the refinement if the target module is a refinement. When a method entry with VM_METHOD_TYPE_UNDEF is invoked by vm_call_method(), a method with the same name is searched in refinements. If such a method is found, the method is invoked. Otherwise, the original method in the refined class (rb_method_definition_t::body.orig_def) is invoked. This change is made to simplify the normal method lookup and to improve the performance of normal method calls. * vm_method.c (EXPR1, search_method, rb_method_entry), vm_eval.c (rb_call0, rb_search_method_entry): do not use refinements for method lookup. * vm_insnhelper.c (vm_call_method): search methods in refinements if ci->me is VM_METHOD_TYPE_REFINED. If the method is called by super (i.e., ci->call == vm_call_super_method), skip the same method entry as the current method to avoid infinite call of the same method. * class.c (include_modules_at): add a refined method entry for each method defined in a module included in a refinement. * class.c (rb_prepend_module): set an empty table to RCLASS_M_TBL(klass) to add refined method entries, because refinements should have priority over prepended modules. * proc.c (mnew): use rb_method_entry_with_refinements() to get a refined method. * test/ruby/test_refinement.rb (test_inline_method_cache): do not skip the test because it should pass successfully. * test/ruby/test_refinement.rb (test_redefine_refined_method): new test for the case a refined method is redefined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* probes.d: Change function-entry probe to method-entry.tenderlove
* insns.def: ditto * probes_helper.h: ditto * test/dtrace/test_function_entry.rb: ditto * test/dtrace/test_singleton_function.rb: ditto * vm.c: ditto * vm_eval.c: ditto * vm_insnhelper.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28* vm_insnhelper.c (vm_call_method): fix undefined behavior.ko1
Should not access scope local variable from outer scope. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20* vm_trace.c: add two methods:ko1
(1) TracePoint#return_value which returns return value on the :return and :c_return event. (2) TracePoint#raised_exception which returns raised exception value on the :raise event. Eeach methods raise RuntimeError if it is called at unsupported event. Please review and give us feedback until next preview release (Dec/2012) of Ruby 2.0.0. * insns.def, vm.c, vm_eval.c, vm_insnhelper.c, eval.c, thread.c: ditto. * vm_trace.c, vm_core.h: move definition of rb_trace_arg_t from vm_trace.c to vm_core.h. Caller fills rb_trace_arg_t and pass the pointer of this variable. * test/ruby/test_settracefunc.rb: fix tests to test this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e