summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
AgeCommit message (Collapse)Author
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
2012-10-16* vm_insnhelper.c (vm_invoke_block): vm_caller_setup_args() can skipko1
when splat flag is not set. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-16* vm_insnhelper.c (vm_getivar, vm_setivar): support index inline cacheko1
with rb_call_info_t to speedup `attr' getter and setter. Cached index is stored in rb_call_info_t::aux::index. `index' == 0 means not cached. `index' > 0 means cached and cached index is `index - 1'. * insns.def ((get|set)instancevariable): use new wrapper functions vm_(get|set)instancevariable() defined in vm_insnhelper.c. * vm_core.h (rb_call_info_t::aux): introduce new union data because opt_pc can share with index. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-15* vm_insnhelper.c (VM_CALLEE_SETUP_ARG): fix wrong condition.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-15* vm_insnhelper.c (vm_call_method): disable CI_SET_FASTPATH() ifko1
this method call needs splat argument because cahced functions (vm_call_attrset, vm_call_ivar, vm_call_cfunc_fast_(unary|binary)) do not check an arity. * bootstraptest/test_method.rb: add a test to check an above issue. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-15* method.h: introduce new method type VM_METHOD_TYPE_CFUNC_FAST.ko1
This method is similar to VM_METHOD_TYPE_CFUNC methods, but called cfunc without building new frame (does not push new control frame). If error is occured in cfunc, the backtrace only shows caller frame and upper. This kind of methods can be added by rb_define_method_fast(). This feature is similar to specialized instructions (opt_plus, etc), but more flexible (but a bit slower). * class.c (rb_define_method_fast): added. Maybe it will be renamed soon. * vm_insnhelper.c (vm_call_method): support method type VM_METHOD_TYPE_CFUNC_FAST. * proc.c (rb_method_entry_arity): catch up new method type. * vm_method.c (rb_add_method_cfunc_fast): added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-15* vm_insnhelper.h (CI_SET_FASTPATH): add new parameter `enabled'.ko1
If `enable' is 0 then CI_SET_FASTPATH() doesn't work. And add new configuration option OPT_CALL_FASTPATH. If this macro was defined by 0, then CI_SET_FASTPATH() doesn't work any more. * vm_insnhelper.c (vm_call_method): Pass `0' for `enabled' parameter of CI_SET_FASTPATH if this method is protected. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-15* vm_core.h (VM_CALL_*): rename VM_CALL_*_BITko1
to VM_CALL_* (remove `_BIT' suffix). Add comments on each macros. Remove unused macro VM_CALL_TAILRECURSION_BIT. * compile.c, iseq.c, insns.def, vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-15vm_insnhelper.c: suppress warningsnobu
* vm_insnhelper.c (vm_callee_setup_arg_complex): suppress shorten-64-to-32 warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-15* vm_insnhelper.c (VM_CALLEE_SETUP_ARG): skip CI_SET_FASTPATH() ifko1
it was called from vm_yield_setup_args(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14* vm_insnhelper.h CI_SET_FASTPATH: introduce new macroko1
`CI_SET_FASTPATH(ci, func)'. This macro set `ci->call' as `func'. `func' (ci->call) is called at the last of `send' (and `invokesuper') instruction. `CI_SET_FASTPATH' does not set `ci->call' when the method (stored in `ci->me') is `protected'. * vm_insnhelper.c (vm_call_method): use `CI_SET_FASTPATH'. After several checking (visibility, argc checking), the result of checking can be reused until re-definition of this method with inline method cache. Note that this optimization is now experimental. If you find any problem about it, please tell us. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14* vm_insnhelper.c: refactoring.ko1
- move all `call' related functions to the last of file. - make functions for respective method types in vm_call_method(). (all functions have same function parameters) * vm_core.h: add `opt_pc' filed in `rb_call_info_t' as temporal variable. * vm_eval.c (vm_call0_body): catch up above cahnges. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-14* insns.def (send, invokesuper, invokeblock, opt_*), vm_core.h:ko1
use only a `ci' (rb_call_info_t) parameter instead of using parameters such as `op_id', 'op_argc', `blockiseq' and flag. These information are stored in rb_call_info_t at the compile time. This technique simplifies parameter passings at related function calls (~10% speedups for simple mehtod invocation at my machine). `rb_call_info_t' also has new function pointer variable `call'. This `call' variable enables to customize method (block) invocation process for each place. However, it always call `vm_call_general()' at this changes. `rb_call_info_t' also has temporary variables for method (block) invocation. * vm_core.h, compile.c, insns.def: introduce VM_CALL_ARGS_SKIP_SETUP VM_CALL macro. This flag indicates that this call can skip caller_setup (block arg and splat arg). * compile.c: catch up above changes. * iseq.c: catch up above changes (especially for TS_CALLINFO). * tool/instruction.rb: catch up above chagnes. * vm_insnhelper.c, vm_insnhelper.h: ditto. Macros and functions parameters are changed. * vm_eval.c (vm_call0): ditto (it will be rewriten soon). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-09* vm_core.h (rb_call_info_t): add new type `rb_call_inf_t'.ko1
This data structure contains information including inline method cache. After that, `struct iseq_inline_cache_entry' does not need to contain inline cache for method invocation. Other information will be added to this data structure. * vm_core.h (rb_iseq_t): add `callinfo_entries' and `callinfo_size' members to `rb_iseq_t'. * insns.def, compile.c: Use CALL_INFO instead of IC. * tool/instruction.rb: support CALL_INFO as operand type. * vm_insnhelper.c, vm_insnhelper.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-08* eval.c, gc.c, iseq.c, node.h, vm_insnhelper.c, vm_insnhelper.h,shugo
vm_method.c: rename omod and overlaid modules to refinements. * eval.c (hidden_identity_hash_new): renamed from identity_hash_new. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-29* vm_insnhelper.c (rb_vm_using_modules): use using_modules beforeshugo
klass to fix method lookup order, and use klass even if klass is not a module to make refinements in class_eval invoked on classes work. * eval.c (rb_using_module): accept a class as the second argument. * eval.c (rb_mod_using, f_using): raise a TypeError if the argument is not a module. * test/ruby/test_refinement.rb: add new tests for the above changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-28* vm_insnhelper.c (vm_setup_method): refactoring.ko1
Remove src_argc and use iseq->arg_size directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-28vm_insnhelper.c: fix typesnobu
* vm_insnhelper.c (vm_setup_method): fix -Wshorten-64-to-32. * vm_insnhelper.c (vm_base_ptr): fix -Wformat git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-28* vm_core.h: remove rb_control_frame_t::bp (bp: base pointer).ko1
`bp' can be calculate by `sp' (stack pointer) of previous frame. Now, `bp_check' field is remained for debug. You can eliminate this field by setting VM_DEBUG_BP_CHECK as 0. * vm_insnhelper.c (vm_base_ptr): add `vm_base_ptr(cfp). This function calculates base pointer from cfp. * vm_insnhelper.c (vm_setup_method): push `recv' value on top of value stack (before method parameters). This change is for keeping consistency with normal method dispatch. * insns.def: fix to use vm_base_ptr(). * vm.c (vm_exec): ditto. * vm_dump.c: remove `bp' related dumps. * cont.c (fiber_init): fix to check VM_DEBUG_BP_CHECK. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-25insns.def: super from at_exitnobu
* insns.def (invokesuper): klass in cfp is not valid in at_exit and END blocks. [ruby-core:47680] [Bug #7064] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-12vm_insnhelper.c: reuse VM stacknobu
* vm_insnhelper.c (vm_method_missing, vm_call_method): reuse arguments on the VM stack and get rid of ALLOCA. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-26suppress warningsnobu
* insns.def (checkmatch): suppress warnings. [ruby-core:47310] [Bug #6930] * vm_core.h (VM_FRAME_TYPE_FINISH_P): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-23remove trailing spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-23* include/ruby/ruby.h: introduce flonum technique forko1
64bit CPU environment (sizeof(double) == sizeof(VALUE)). flonum technique enables to avoid double object creation if the double value d is in range about between 1.72723e-77 < |d| <= 1.15792e+77 or 0.0. flonum Float value is immediate and their lowest two bits are b10. If flonum is activated, then USE_FLONUM macro is 1. I'll write detailed in this technique on https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/Flonum_tech * benchmark/bmx_temp.rb: add an benchmark for simple Float calculation. * gc.c (id2ref, rb_obj_id): add flonum Float support. * include/ruby/intern.h: move decl of rb_float_new(double) to include/ruby/ruby.h. * insns.def, vm.c, vm_insnhelper.c: add flonum optimization and simplify source code. * vm_insnhelper.h (FLONUM_2_P): added. * marshal.c: support flonum output. * numeric.c (rb_float_new_in_heap): added. * parse.y: support flonum. * random.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-22* vm_insnhelper.c (vm_setup_method): fix last commit.ko1
[ruby-dev:46065] [Bug #6901] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-22* vm_insnhelper.c (vm_setup_method): should not enable tail callshugo
optimization for frames with VM_FRAME_FLAG_FINISH. [ruby-dev:46065] [Bug #6901] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-20vm_insnhelper.c: iclass as klass in cfpnobu
* vm_insnhelper.c (vm_call_method): follow iclasses as klass in cfp but not included modules. [ruby-core:47241] [Bug #6891] * vm_insnhelper.c (vm_call_bmethod): pass defined_class to follow proper ancestors. [ruby-core:47241] [Bug #6891] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-08* compile.c, insns.def (checkmatch):ko1
remove checkincludearray instruction and add new instruction checkmatch. This change is to solve [Bug #4438] "rescue args type check omitted". * iseq.c: increment ISEQ_MAJOR_VERSION because removal of checkincludearray instruction. * vm_core.h: add several definitions for the checkmatch instruction. * vm_insnhelper.c (check_match): added. * bootstraptest/test_exception.rb: add a test. * test/ruby/test_exception.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-06* include/ruby/ruby.h, eval.c, vm_insnhelper.c: fix typo.shugo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-03vm_insnhelper.c: no recvnobu
* vm_insnhelper.c (vm_search_normal_superclass): no longer needs receiver, klass is always unique in the ancestors now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02* vm_insnhelper.c (rb_vm_using_modules): fix indent.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02* vm_insnhelper.c (vm_call_method): remove garbage spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02* eval.c (rb_mod_using): new method Module#using. [experimental]shugo
* eval.c (rb_mod_refine): new method Module#refine. [experimental] * eval.c (f_using): new method Kernel#using. [experimental] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-02* class.c, insns.def, method.h, proc.c, vm.c, vm_core.h, vm_eval.c,shugo
vm_insnhelper.c, vm_insnhelper.h, vm_method.c: add klass to rb_control_frame_t to implement super correctly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-01RB_TYPE_P BUILTIN_TYPEnobu
* string.c, vm_insnhelper.c, vm_method.c: use RB_TYPE_P() and BUILTIN_TYPE() if possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-19* thread.c (rb_thread_s_control_interrupt,ko1
rb_thread_s_check_interrupt): added for Thread.control_intgerrupt and Thread.check_interrupt. See details on rdoc. I'll make an ticket for this feature. * test/ruby/test_thread.rb: add a test for Thread.control_intgerrupt. * thread.c (rb_threadptr_raise): make a new exception object even if argc is 0. * thread.c (rb_thread_kill): kill thread immediately if target thread is current thread. * vm_core.h (RUBY_VM_CHECK_INTS_BLOCKING): added. CHECK_INTS while/after blocking operation. * vm_core.h (RUBY_VM_CHECK_INTS): require rb_thread_t ptr. * cont.c (fiber_switch): use replaced RUBY_VM_CHECK_INTS(). * eval.c (ruby_cleanup): ditto. * insns.def: ditto. * process.c (rb_waitpid): ditto. * vm_eval.c (vm_call0): ditto. * vm_insnhelper.c (vm_call_method): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-18vm.c: remove unused variablesnobu
* vm.c (invoke_block_from_c), vm_insnhelper.c (vm_call_cfunc): remove unused variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e