summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
AgeCommit message (Collapse)Author
2017-10-06proc.c: super_method of included methodnobu
* proc.c (method_super_method): search the next super method along the included ancestor chain. [ruby-core:83114] [Bug #13973] * vm_method.c (rb_callable_method_entry_without_refinements): return the defined class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-18intern instructionnobu
* insns.def (intern): new instruction to turn string into symbol. opt_call_c_function can not dump. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-17literal symbol by internnobu
* compile.c (iseq_compile_each0): literal symbol should not be affected by redefinition of String#intern method. * vm_insnhelper.c (rb_vm_str_intern): intern a string into a symbol directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-10store ec instead of thread in rb_context_t.ko1
* cont.c (rb_context_t): introduce saved_ec instaad of saved_thread. We only need to transfer ec data (not all of thread data). Introduce `thread_value` field to point creation thread. To acccess this field, `cont_thread_value()` is introduced. * vm.c (rb_execution_context_mark): remove `static` and use it from cont.c (use this function instead of `rb_thread_mark`). * vm_insnhelper.c (rb_vm_push_frame): accept ec instead of th. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-03vm_insnhelper.c: fix opt_regexpmatch2 instructionrhe
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
2017-08-22signal.c: fatal stacknobu
* 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
2017-08-21vm_core.h: ruby_error_stackfatalnobu
* 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
2017-08-18vm_insnhelper.c: vm_cfp_consistent_pnobu
* 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
2017-08-18vm_insnhelper.c: raise ruby_error_sysstack_gcnobu
* 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
2017-08-16vm_insnhelper.c: cfp error at stack overflownobu
* 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
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