summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
AgeCommit message (Collapse)Author
2017-08-10rename rb_execution_context_t::stack(_size) to vm_stack(_size).ko1
* vm_core.h: Ruby processes run with two stacks, a machine stack and a VM stack. To make it clear, this fix renames rb_execution_context_t::stack(_size) to vm_stack(_size). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-05splat keyword hashnobu
* compile.c (compile_array_keyword_arg): set keyword splat flag if explicitly splatted. [ruby-core:68124] [Bug #10856] * vm_args.c (setup_parameters_complex): try keyword hash splat if given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-29visibility of inherited methodnobu
* vm_insnhelper.c (vm_call_method_each_type): honor the original visibility of inherited methods when a refinement is defined but not activated. [ruby-core:82209] [Bug #13776] Author: Mon_Ouie (Mon ouïe) <mon.ouie@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-29adjust indent [ci skip]nobu
* vm_insnhelper.c (vm_call_method_each_type): adjust indent of a block in switch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-30vm_insnhelper.c: dump iseqnobu
* vm_insnhelper.c (vm_stack_consistency_error): raise a fatal error with the disassembled instruction sequence, in the development version, instead of very rarely useful rb_bug in such case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28move fields to ec.ko1
* vm_core.h (rb_thread.h): move errinfo and trace_arg to rb_execution_context_t. * cont.c (fiber_switch, rb_cont_call): do not restore "trace_arg" here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28move fields to ec.ko1
* vm_core.h (rb_thread_t): move root_lep, root_svar and ensure_list to rb_execution_context_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-27fix return in toplevel rescue/ensurenobu
* compile.c (iseq_compile_each0): throw TAG_RETURN at return in toplevel rescue/ensure to adjust VM stack properly. [ruby-core:81777] [Bug #13682] * vm_insnhelper.c (vm_throw_start): allow return in toplevel rescue/ensure. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-27vm_insnhelper.c: break in oncenobu
* vm_insnhelper.c (vm_throw_start): size of catch table has been included in iseq_catch_table struct, which could be NULL, since 2.2. e.g., proc-closure in `once'. [ruby-core:81775] [Bug #13680] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-26move several fields from rb_thread_t to rb_execution_context_t.ko1
* vm_core.h (rb_thread_t): move several fields which are copied at cont.c to rb_execution_context_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23move "state" to rb_vm_tag.ko1
* vm_core.h (rb_thread_t::tag_state): move to "rb_vm_tag::state". Lifetime of "state" should be same as current tag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23rename th->state to th->tag_state.ko1
* vm_core.h (rb_thread_t): rename rb_thread_t::state to tag_state to make it clear. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23vm_insnhelper.c: vm_stack_consistency_errornobu
* vm_insnhelper.c (vm_stack_consistency_error): extracted from insns.def for further info in the future. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-15Prohibit SystemStackError while GC.ko1
* vm_insnhelper.c (rb_threadptr_stack_overflow): fatal on GC [Bug #13662] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-14remove OPT_CALL_CFUNC_WITHOUT_FRAME.ko1
* vm_core.h (OPT_CALL_CFUNC_WITHOUT_FRAME): removed because nobody use it. This optimization tries to call C-methods without pushing VM frames, however no big improvements compare with this complexity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-08check break target correctly.ko1
* compile.c (iseq_compile_each0): save target child_iseq in the catch-table for break. This iseq is not for continuation, but for search key at vm_throw_start(). * vm_insnhelper.c (vm_throw_start): check saved iseq first. * iseq.h: add comment for it. * test/ruby/test_iterator.rb (test_ljump): add a test for the issue: def call b; b.call; end call(Proc.new{break}){} #=> (1) should raise LocalJumpError call(Proc.new{break}) #=> (2) shoudd raies LocalJumpError, too. but (1) doesn't raise LocalJumpError. This issue is reported by Matz. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-05remove arg_setup_lambda.ko1
* vm_args.c (enum arg_setup_type): remove arg_setup_lambda because it is same as arg_setup_method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-03* vm_core.h: remove VM_FRAME_MAGIC_LAMBDA and introduceko1
VM_FRAME_FLAG_LAMBDA. So that lambda block frame is VM_FRAME_MAGIC_BLOCK | VM_FRAME_FLAG_LAMBDA. * vm_core.h: remvoe VM_FRAME_MAGIC_PROC because nobody uses it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-31Improve performance of implicit type conversionwatson1978
To convert the object implicitly, it has had two parts in convert_type() which are 1. lookink up the method's id 2. calling the method Seems that strncmp() and strcmp() in convert_type() are slightly heavy to look up the method's id for type conversion. This patch will add and use internal APIs (rb_convert_type_with_id, rb_check_convert_type_with_id) to call the method without looking up the method's id when convert the object. Array#flatten -> 19 % up Array#+ -> 3 % up [ruby-dev:50024] [Bug #13341] [Fix GH-1537] ### Before Array#flatten 104.119k (± 1.1%) i/s - 525.690k in 5.049517s Array#+ 1.993M (± 1.8%) i/s - 10.010M in 5.024258s ### After Array#flatten 124.005k (± 1.0%) i/s - 624.240k in 5.034477s Array#+ 2.058M (± 4.8%) i/s - 10.302M in 5.019328s ### Test Code require 'benchmark/ips' class Foo def to_ary [1,2,3] end end Benchmark.ips do |x| ary = [] 100.times { |i| ary << i } array = [ary] x.report "Array#flatten" do |i| i.times { array.flatten } end x.report "Array#+" do |i| obj = Foo.new i.times { array + obj } end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-31add debug counters for local variable (lavr) access.ko1
* debug_counter.h: add the following counters: * lvar_get: counter for lvar get. * lvar_get_dynamic: counter for lvar get from upper frames. * lvar_set: coutner for lvar set. * lvar_set_dynamic: coutner for lvar set from upper frames. * lvar_set_slowpath: counter for lavr set using slowpath. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26Symbol support for opt_eql_func toonobu
* vm_insnhelper.c (comparable_by_identity): extract the condition where comparable by identity. currently both are same types, Fixnum, Flonum, or Symbol. * vm_insnhelper.c (opt_eql_func): support Symbol too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26Symbol support for opt_eq_func.ko1
* vm_insnhelper.c (opt_eq_func): optimize for symbol comparison. [Bug #13330] [fix GH-1540] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-25vm_insnhelper.c: remove redefinitions and undefine after usednobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-25vm_insnhelper.c: rb_eql_opt should call eql?nobu
* vm_insnhelper.c (rb_eql_opt): should call #eql? on Float and String, not #==. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-25Improve performance of rb_eql()watson1978
This improvement is similar with https://github.com/ruby/ruby/pull/1552 internal.h: add declaration of rb_eql_opt() API. vm_insnhelper.c (rb_eql_opt): add rb_eql_opt() API which provides optimized path for #eql? method such as rb_equal_opt(). object.c (rb_eql): optimize using rb_eql_opt() such as rb_equal(). Array#eql? and some methods have used rb_eql() and Array#eql? will be faster around 20%. [ruby-core:80761] [Bug #13447] [Fix GH-#1589] ### Before user system total real 1.570000 0.000000 1.570000 ( 1.569754) ### After user system total real 1.300000 0.000000 1.300000 ( 1.303624) ### Test code require 'benchmark' Benchmark.bmbm do |x| ary1 = Array.new(1000) { rand(1000) } ary2 = Array.new(1000) { rand(1000) } x.report do 5000000.times do ary1.eql?(ary2) end end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-09fixup r58614 for raspi3 and maybe other systems with odd compilenormal
[ruby-core:81048] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-09rb_execution_context_t: move stack, stack_size and cfp from rb_thread_tnormal
The goal is to reduce rb_context_t and rb_fiber_t size by removing the need to store the entire rb_thread_t in there. [ruby-core:81045] Work-in-progress: soon, we will move more fields here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-19fix infinite recursionnobu
* vm_insnhelper.c (vm_once_dispatch): no guarantee that tail call is always optimized away. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-19refactor extract binop dispatchershyouhei
Those opt_something instructions are worth refactoring. They tend to have similar ways of executions. By extracting the common part, generated vm_exec_core function shrinks from 26,816 bytes to 26,256 bytes (according to nm(1)). This changeset introduces negligible performance impact. 3 repeated runs of optcarrot benchmark on my machine resulted in: before this: 28.813363684823557, 27.523907198440366, 27.292766121965400 after this: 28.174038497265080, 28.999513875020405, 29.621399800428065 in fps (greater==faster). ---- * vm_insnhelper.c (vm_opt_binop_dispatch): new function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18fixup! vm_insnhelper.c: adjust indent [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18vm_insnhelper.c: adjust indent [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18tabify (sorry!) [ci skip]shyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18split insns.def into functionsshyouhei
Contemporary C compilers are good at function inlining. They fold multiple functions into one. However they are not yet smart enough to unfold a function into several ones. So generally speaking, it is wiser for a C programmer to manually split C functions whenever possible. That should make rooms for compilers to optimize at will. Before this changeset insns.def was converted into single HUGE function called vm_exec_core(). By moving each instruction's core into individual functions, generated C source code is reduced from 3,428 lines to 2,847 lines. Looking at the generated assembly however, it seems my compiler (gcc 6.2) is extraordinary smart so that it inlines almost all functions I introduced in this changeset back into that vm_exec_core. On my machine compiled machine binary of the function does not shrink very much in size (28,432 bytes to 26,816 bytes, according to nm(1)). I believe this change is zero-cost. Several benchmarks I exercised showed no significant difference beyond error mergin. For instance 3 repeated runs of optcarrot benchmark on my machine resulted in: before this: 28.330329285707490, 27.513378371065920, 29.40420215754537 after this: 27.107195867280414, 25.549324021385907, 30.31581919050884 in fps (greater==faster). ---- * internal.h (rb_obj_not_equal): used from vm_insnhelper.c * insns.def: move vast majority of lines into vm_insnhelper.c * vm_insnhelper.c: moved here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-17vm_insnhelper.c: rb_threadptr_stack_overflownobu
* vm_insnhelper.c (rb_threadptr_stack_overflow): move from thread.c and integrate with vm_stackoverflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-11Parenthesized CHECK_CFP_CONSISTENCY [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-11vm_insnhelper.c: CHECK_CFP_CONSISTENCYnobu
* vm_insnhelper.c (CHECK_CFP_CONSISTENCY): make [BUG] messages consistent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-19vm_args.c: arity check of lambdanobu
* vm_eval.c (rb_yield_lambda): new function which yields an array to a proc and splat to a lambda. mainly for Enumerable only. * vm_args.c (setup_parameters_complex): remove special lambda splatting for [Bug #9605]. [ruby-core:77065] [Bug #12705] * vm_insnhelper.c (vm_callee_setup_block_arg): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-18vm.c: guard arguments [EXPERIMENTAL]nobu
* vm.c (invoke_iseq_block_from_c): guard arguments on stack, not to be clobbered during splatting. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-15vm_insnhelper.c: adjust indent [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-15* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-15add several counters to analyze ivar inline caches.ko1
* debug_counter.h: add (and renamed) several counters: ivar_get_ic_hit ivar_get_ic_miss ivar_get_ic_miss_serial ivar_get_ic_miss_unset ivar_get_ic_miss_noobject ivar_set_ic_hit ivar_set_ic_miss ivar_set_ic_miss_serial ivar_set_ic_miss_unset ivar_set_ic_miss_oorange ivar_set_ic_miss_noobject ivar_get_base ivar_set_base See related source code to know what counters mean. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-14vm_insnhelper.c: undef BUILTIN_CLASS_P tookazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-06opt_eq_func refactornobu
* vm_insnhelper.c (opt_eq_func): method to dispatch is resolved by only the receiver's class, not including the argument class. even if basic operation is redefined, other class conditions never meet. optimize Float and non-Float case, delegate to rb_float_equal directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-21add performance counting mechanism for MRI debug/tuning purpose.ko1
* How to enable this feature? * define USE_DEBUG_COUNTER as 1. * you can disable to output the result with RUBY_DEBUG_COUNTER_DISABLE environment variable even if USE_DEBUG_COUNTER == 1. * How to add new counter? * add COUNTER(<name>) line on debug_counter.h. * include "debug_counter.h" * insert RB_DEBUG_COUNTER_INC(<name>) line on your favorite place. * counter output example: [RUBY_DEBUG_COUNTER] mc_inline_hit 999 [RUBY_DEBUG_COUNTER] mc_inline_miss 3 [RUBY_DEBUG_COUNTER] mc_global_hit 23 [RUBY_DEBUG_COUNTER] mc_global_miss 273 [RUBY_DEBUG_COUNTER] mc_global_state_miss 3 [RUBY_DEBUG_COUNTER] mc_class_serial_miss 0 [RUBY_DEBUG_COUNTER] mc_cme_complement 0 [RUBY_DEBUG_COUNTER] mc_cme_complement_hit 0 [RUBY_DEBUG_COUNTER] mc_search_super 1384 [RUBY_DEBUG_COUNTER] ivar_get_hit 0 [RUBY_DEBUG_COUNTER] ivar_get_miss 0 [RUBY_DEBUG_COUNTER] ivar_set_hit 0 [RUBY_DEBUG_COUNTER] ivar_set_miss 0 [RUBY_DEBUG_COUNTER] ivar_get 431 [RUBY_DEBUG_COUNTER] ivar_set 465 * mc_... is related to method caching. * ivar_... is related to instance variable accesses. * compare with dtrace/system tap features, there are completely no performacne penalties when it is disabled. * This feature is supported only on __GNUC__ compilers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-19vm_insnhelper.c: super to module in refinementnobu
* vm_insnhelper.c (vm_call_zsuper): method defined in module in refinement is not callable as-is. dispatch again. [ruby-core:79588] [Bug #13227] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-16use rb_iseq_check() for USE_LAZY_LOAD, too.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-24eval.c: copy special exceptionnobu
* eval.c (setup_exception): make unfrozen copy of special exception before setting up a cause. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-09vm_insnhelper.c: block argument at tailcallnobu
* vm_insnhelper.c (vm_call_iseq_setup_tailcall): check interrupts after set up the new frame, not the passed block to be clobbered by invoked finalizers and so on. [ruby-core:78981] [Bug #13107] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-08vm_insnhelper.c: zsuper in refinementsnobu
* vm_insnhelper.c (vm_call_zsuper): prevent infinite recursion zsuper in refinements. [ruby-core:77161] [Bug #12729] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e