aboutsummaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
Commit message (Collapse)AuthorAgeFilesLines
* vm_insnhelper.c: fix opt_regexpmatch2 instructionrhe2017-09-031-2/+2
| | | | | | | A fix-up for r58390 ("split insns.def into functions", 2017-04-18) which accidentally swapped the arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* signal.c: fatal stacknobu2017-08-221-3/+3
| | | | | | | * signal.c (check_stack_overflow): raise fatal when the last tag is in danger zone. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_core.h: ruby_error_stackfatalnobu2017-08-211-1/+1
| | | | | | | | | | * vm_core.h (ruby_special_exceptions): rename sysstack_gc as stackfatal. * eval.c (Init_eval): modified the message for stackfatal error as "critical region". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c: vm_cfp_consistent_pnobu2017-08-181-3/+13
| | | | | | | * vm_insnhelper.c (vm_cfp_consistent_p): extracted the conditions for cfp consistency. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c: raise ruby_error_sysstack_gcnobu2017-08-181-1/+3
| | | | | | | * vm_insnhelper.c (rb_threadptr_stack_overflow): rb_fatal is not available during GC. raise the preallocated fatal error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c: cfp error at stack overflownobu2017-08-161-1/+3
| | | | | | | | * vm_insnhelper.c (threadptr_stack_overflow): set stack overflow flag until handling execptions, to get rid of cfp consistency error when exec tag was rewound. [ruby-core:80618] [Bug #13412] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rename rb_execution_context_t::stack(_size) to vm_stack(_size).ko12017-08-101-2/+2
| | | | | | | | | * 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
* splat keyword hashnobu2017-08-051-1/+1
| | | | | | | | | | * 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
* visibility of inherited methodnobu2017-07-291-2/+3
| | | | | | | | | | * 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
* adjust indent [ci skip]nobu2017-07-291-38/+38
| | | | | | | * 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
* vm_insnhelper.c: dump iseqnobu2017-06-301-0/+7
| | | | | | | | | * 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
* move fields to ec.ko12017-06-281-1/+1
| | | | | | | | | | * 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
* move fields to ec.ko12017-06-281-4/+4
| | | | | | | | * 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
* fix return in toplevel rescue/ensurenobu2017-06-271-0/+16
| | | | | | | | | | | * 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
* vm_insnhelper.c: break in oncenobu2017-06-271-6/+6
| | | | | | | | | * 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
* move several fields from rb_thread_t to rb_execution_context_t.ko12017-06-261-6/+6
| | | | | | | | * 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
* move "state" to rb_vm_tag.ko12017-06-231-5/+5
| | | | | | | | * 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
* rename th->state to th->tag_state.ko12017-06-231-6/+5
| | | | | | | | * 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
* vm_insnhelper.c: vm_stack_consistency_errornobu2017-06-231-0/+16
| | | | | | | * 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
* Prohibit SystemStackError while GC.ko12017-06-151-1/+4
| | | | | | | * 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
* remove OPT_CALL_CFUNC_WITHOUT_FRAME.ko12017-06-141-76/+0
| | | | | | | | | * 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
* check break target correctly.ko12017-06-081-1/+3
| | | | | | | | | | | | | | | | | | | | | * 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
* remove arg_setup_lambda.ko12017-06-051-1/+1
| | | | | | | | * 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
* * vm_core.h: remove VM_FRAME_MAGIC_LAMBDA and introduceko12017-06-031-6/+4
| | | | | | | | | | 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
* Improve performance of implicit type conversionwatson19782017-05-311-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* add debug counters for local variable (lavr) access.ko12017-05-311-0/+1
| | | | | | | | | | | | * 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
* Symbol support for opt_eql_func toonobu2017-05-261-47/+50
| | | | | | | | | | * 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
* Symbol support for opt_eq_func.ko12017-05-261-0/+5
| | | | | | | | * 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
* vm_insnhelper.c: remove redefinitions and undefine after usednobu2017-05-251-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c: rb_eql_opt should call eql?nobu2017-05-251-5/+45
| | | | | | | * 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
* Improve performance of rb_eql()watson19782017-05-251-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* fixup r58614 for raspi3 and maybe other systems with odd compilenormal2017-05-091-2/+2
| | | | | | [ruby-core:81048] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rb_execution_context_t: move stack, stack_size and cfp from rb_thread_tnormal2017-05-091-21/+21
| | | | | | | | | | 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
* fix infinite recursionnobu2017-04-191-2/+3
| | | | | | | * 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
* refactor extract binop dispatchershyouhei2017-04-191-171/+107
| | | | | | | | | | | | | | | | | | | | | | 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
* fixup! vm_insnhelper.c: adjust indent [ci skip]nobu2017-04-181-12/+12
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c: adjust indent [ci skip]nobu2017-04-181-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tabify (sorry!) [ci skip]shyouhei2017-04-181-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces.svn2017-04-181-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* split insns.def into functionsshyouhei2017-04-181-0/+866
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* vm_insnhelper.c: rb_threadptr_stack_overflownobu2017-04-171-1/+29
| | | | | | | * 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
* Parenthesized CHECK_CFP_CONSISTENCY [ci skip]nobu2017-04-111-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c: CHECK_CFP_CONSISTENCYnobu2017-04-111-6/+6
| | | | | | | * 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
* vm_args.c: arity check of lambdanobu2017-03-191-6/+0
| | | | | | | | | | | | * 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
* vm.c: guard arguments [EXPERIMENTAL]nobu2017-03-181-0/+4
| | | | | | | * 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
* vm_insnhelper.c: adjust indent [ci skip]nobu2017-03-151-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * remove trailing spaces.svn2017-03-151-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add several counters to analyze ivar inline caches.ko12017-03-151-9/+18
| | | | | | | | | | | | | | | | | | | | | | * 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
* vm_insnhelper.c: undef BUILTIN_CLASS_P tookazu2017-03-141-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* opt_eq_func refactornobu2017-03-061-22/+19
| | | | | | | | | | * 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