summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
AgeCommit message (Collapse)Author
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
2012-11-18* vm_core.h, probes_helper.h (RUBY_DTRACE_FUNC_ENTRY_HOOK,ngoto
RUBY_DTRACE_FUNC_RETURN_HOOK): move from vm_core.h to new file probes_helper.h for narrowing dependency to probes.h. * common.mk (VM_CORE_H_INCLUDES): remove dependency to probes.h. * common.mk (vm.$(OBJEXT)): add dependency to probes_helper.h. * vm.c, vm_insnhelper.c: include probes_helper.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-13* vm_insnhelper.c (vm_call_cfunc_with_frame): don't use ci afterko1
EXEC_EVENT_HOOK because ci can be overridden. * vm_eval.c: ditto. * method.h: change invoker's parameters types. * vm_method.c (call_cfunc_invoker_func): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-13* vm_insnhelper.c (vm_caller_setup_args): save and restoreko1
ci->argc and ci->blockptr before and after method invocations because these method dispatches override call_info. * bootstraptest/test_method.rb: add tests for this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12* probes.d: add DTrace probe declarations. [ruby-core:27448]tenderlove
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe. * compile.c (rb_insns_name): allowing DTrace probes to access instruction sequence name. * Makefile.in: translate probes.d file to appropriate header file. * common.mk: declare dependencies on the DTrace header. * configure.in: add a test for existence of DTrace. * eval.c (setup_exception): add a probe for when an exception is raised. * gc.c: Add DTrace probes for mark begin and end, and sweep begin and end. * hash.c (empty_hash_alloc): Add a probe for hash allocation. * insns.def: Add probes for function entry and return. * internal.h: function declaration for compile.c change. * load.c (rb_f_load): add probes for `load` entry and exit, require entry and exit, and wrapping search_required for load path search. * object.c (rb_obj_alloc): added a probe for general object creation. * parse.y (yycompile0): added a probe around parse and compile phase. * string.c (empty_str_alloc, str_new): DTrace probes for string allocation. * test/dtrace/*: tests for DTrace probes. * vm.c (vm_invoke_proc): add probes for function return on exception raise, hash create, and instruction sequence execution. * vm_core.h: add probe declarations for function entry and exit. * vm_dump.c: add probes header file. * vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on function entry and return. * vm_exec.c: expose instruction number to instruction name function. * vm_insnshelper.c: add function entry and exit probes for cfunc methods. * vm_insnhelper.h: vm usage information is always collected, so uncomment the functions. 12 19:14:50 2012 Akinori MUSHA <knu@iDaemons.org> * configure.in (isinf, isnan): isinf() and isnan() are macros on DragonFly which cannot be found by AC_REPLACE_FUNCS(). This workaround enforces the fact that they exist on DragonFly. 12 15:59:38 2012 Shugo Maeda <shugo@ruby-lang.org> * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo), vm_insnhelper.c (vm_search_method): revert r37616 because it's too slow. [ruby-dev:46477] * test/ruby/test_refinement.rb (test_inline_method_cache): skip the test until the bug is fixed efficiently. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo),shugo
vm_insnhelper.c (vm_search_method): revert r37616 because it's too slow. [ruby-dev:46477] * test/ruby/test_refinement.rb (test_inline_method_cache): skip the test until the bug is fixed efficiently. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-11* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo):shugo
add a new field for inline method cache. * vm_insnhelper.c (vm_search_method): check rb_call_info_t::refinements not to confuse inline method cache when module_eval is used with refinements. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06adjust stylenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27vm_insnhelper.c: fix indentationko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-24vm_insnhelper.c: inlinenobu
* vm_insnhelper.c: declare as inline, to match with the definitions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-23* vm_insnhelper.c (vm_call_method): remove `default' andko1
add a case for `VM_METHOD_TYPE_UNDEF'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-23* vm_core.h, vm_insnhelper.c, vm_eval.c (OPT_CALL_CFUNC_WITHOUT_FRAME):ko1
add a new otpimization and its macro `OPT_CALL_CFUNC_WITHOUT_FRAME'. This optimization makes all cfunc method calls `frameless', which is fster than ordinal cfunc method call. If `frame' is needed (for example, it calls another method with `rb_funcall()'), then build a frame. In other words, this optimization delays frame building. However, to delay the frame building, we need additional overheads: (1) Store the last call information. (2) Check the delayed frame buidling before the frame is needed. (3) Overhead to build a delayed frame. rb_thread_t::passed_ci is storage of delayed cfunc call information. (1) is lightweight because it is only 1 assignment to `passed_ci'. To achieve (2), we modify GET_THREAD() to check `passed_ci' every time. It causes 10% overhead on my envrionment. This optimization only works for cfunc methods which do not need their `frame'. After evaluation on my environment, this optimization does not effective every time. Because of this evaluation results, this optimization is disabled at default. * vm_insnhelper.c, vm.c: add VM_PROFILE* macros to measure behaviour of VM internals. I will extend this feature. * vm_method.c, method.h: change parameters of the `invoker' function. Receive `func' pointer as the first parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-19* method.h (rb_method_cfunc_t::invoker): add new field (func ptr)ko1
`invoker'. `invoker' function invoke cfunc body (rb_method_cfunc_t::func). `invoker' is set at method definition timing. With this change, the big `switch' (branch) in `call_cfunc()' is no longer needed. However, the performance benefit is only a bit. * vm_core.h (rb_call_info_t::aux::func): add a new field to store cfunc body function pointer. * vm_method.c (call_cfunc_invoker_func): add a new function which returns a suitable invoke function. * vm_method.c (setup_method_cfunc_struct): added. * vm_method.c (rb_add_method): fix to set `invoker'. * vm_eval.c (vm_call0_body): catch up above changes. * vm_insnhelper.c (call_cfunc): removed. * vm_insnhelper.c (vm_call_cfunc): fix to call cfunc body with `invoker' function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-19* vm_insnhelper.c (vm_search_method): remove needless local variable.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-18* insns.def (send): remove unused condition.ko1
This condition will be true after r37258. * vm_insnhelper.c (vm_caller_setup_args): remove `UNLIKELY' on checking blockiseq (it seems `LIKELY'). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-18* vm_insnhelper.c: add `inline' keyword to several functions.ko1
Compilers (gcc) are conservative than I expected. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-18* class.c (rb_define_frameless_method): rename fromko1
rb_define_method_fast(). Defined method with this C API does not make a method frame. It is bit lightweight than ordinal C functions. Now only 0 or 1 argc are permitted. * method.h (VM_METHOD_TYPE_CFUNC_FRAMELESS): rename macro name from VM_METHOD_TYPE_CFUNC_FAST. * vm_insnhelper.c, vm_method.c: rename related functions. * proc.c (rb_method_entry_arity): catch up above changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-17* vm_insnhelper.c (vm_getivar): fix to use `aux.index' instead ofko1
`aux.opt_pc'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-17* vm_insnhelper.c (vm_call_method_missing): make a refactoringko1
about method_missing process. Use `vm_call_method()' to invoke `method_missing' method instead of `rb_funcall2()'. In `vm_call_method()', set fastpath to `vm_call_method_missing()' if it can be cached. * vm_core.h (rb_call_info_t): add new field `rb_call_info_t::aux::missing_reasion' to pass the reason to `vm_call_method_missing()'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-17* vm_insnhelper.c (vm_search_method): fix a build error that occursshugo
when OPT_INLINE_METHOD_CACHE is 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-16* vm_insnhelper.c (vm_call_method): fix to return value immediately.ko1
Remove CHECK_INTS() after that method dispatch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-16* vm_insnhelper.c (vm_call_iseq_setup_2): separate tailcall and normalko1
method frame setup functions. Add checking interrupts at the tailcall setup function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e