summaryrefslogtreecommitdiff
path: root/insns.def
AgeCommit message (Collapse)Author
2017-12-06insns.def (tracebranch): renamed from `trace2`mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16accepts `ec` as first parameter.ko1
* vm_insnhelper.c (vm_check_match): accepts `ec` as first parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-14remove `trace` instruction. [Feature #14104]ko1
* tool/instruction.rb: create `trace_` prefix instructions. * compile.c (ADD_TRACE): do not add `trace` instructions but add TRACE link elements. TRACE elements will be unified with a next instruction as instruction information. * vm_trace.c (update_global_event_hook): modify all ISeqs when hooks are enabled. * iseq.c (rb_iseq_trace_set): added to toggle `trace_` instructions. * vm_insnhelper.c (vm_trace): added. This function is a body of `trace_` prefix instructions. * vm_insnhelper.h (JUMP): save PC to a control frame. * insns.def (trace): removed. * vm_exec.h (INSN_ENTRY_SIG): add debug output (disabled). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07th->ec: dtraceko1
* vm.c (ruby_th_dtrace_setup): rename to rb_dtrace_setup() and accept `ec`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07th->ec: vm_once_dispatch.ko1
* vm_insnhelper.c (vm_once_dispatch): accepts `ec`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-06move rb_thread_t::interrupt_flag and maskko1
to rb_execution_context_t. * vm_core.h (rb_thread_t): move `rb_thread_t::interrupt_flag` and `rb_thread_t::interrupt_mask` to rb_execution_context_t. RUBY_VM_CHECK_INTS() accepts `ec` instead of `th`. * cont.c (rb_fiber_terminate): to propagate interrupt information, add new parameter `need_interrupt`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29EXEC_EVENT_HOOK(ec, ...)ko1
* vm_core.h (EXEC_EVENT_HOOK): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27catch up recent changes for call threaded code VM.ko1
Fix compile errors for OPT_CALL_THREADED_CODE (in vm_opts.h). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27`th` -> `ec` for `rb_insn_func_t`.ko1
* vm_core.h (rb_insn_func_t): accepts `ec` instead of `th`. * vm_insnhelper.c (rb_vm_opt_struct_aref): ditto. * vm_insnhelper.c (rb_vm_opt_struct_aset): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27vm_exec_core() accepts `ec` instead of `th`.ko1
* vm_exec.c (vm_exec_core): accepts `ec` instead of `th`. * vm_args.c (vm_caller_setup_arg_block): also accepts `ec`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27`th` -> `ec` for block related functions.ko1
* vm.c: the following functions accept `ec` instead of `th`. * invoke_block * invoke_bmethod * invoke_iseq_block_from_c * invoke_block_from_c_bh * check_block_handler * vm_yield_with_cref * vm_yield * vm_yield_with_block * vm_yield_force_blockarg * invoke_block_from_c_proc * vm_invoke_proc * vm_invoke_bmethod * rb_vm_invoke_proc * vm_insnhelper.c: ditto. * vm_yield_with_cfunc * vm_yield_with_symbol * vm_callee_setup_block_arg * vm_yield_setup_args * vm_invoke_iseq_block * vm_invoke_symbol_block * vm_invoke_ifunc_block * vm_invoke_block git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27`ec` -> `th`ko1
* vm_exec.h (VM_SP_CNT): accepts `ec` instead of `th`. * vm_insnhelper.c (vm_stack_consistency_error): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27vm_defined() accepts `ec` instead of `th`.ko1
* vm_insnhelper.c (vm_defined): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27vm_search_super_method() accepts `ec` instead of `th`.ko1
* vm_insnhelper.c (vm_search_super_method): accepts `ec` instead of `th`. Surprisingly, it doesn't use `th` (now `ec`) so this patch is for the future extension. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27vm_get_ev_const() accepts `ec` instead of `th`.ko1
* vm_insnhelper.c (vm_get_ev_const): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27vm_throw* accept `ec` instead of `th`.ko1
* vm_insnhelper.c (vm_throw*): accept `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27ec->th for vm_cref_push() and constify.ko1
* vm_insnhelper.c (vm_cref_push): accepts `ec` instead of `th`. * vm_insnhelper.c: consitfy the first parameter (ec): * lep_svar * lep_svar_write * lep_svar_get * lep_svar_set * vm_getspecial and added vm_cref_push. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27Some functions accept `ec` instead of `th`.ko1
* vm_insnhelper.c: The following functions accept `ec` instead of `th`. * lep_svar * lep_svar_write * lep_svar_get * lep_svar_set * vm_getspecial git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26rb_vm_bh_to_procval() accepts `ec` instead of `th`.ko1
* vm_insnhelper.c (rb_vm_bh_to_procval): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26vm_pop_frame() accepts `ec` instead of `th`.ko1
* vm_insnhelper.c (vm_pop_frame): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26vm_push_frame() accepts `ec` instead of `th`.ko1
* vm_insnhelper.c (vm_push_frame): accepts `ec` instead of `th`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26Use rb_execution_context_t instead of rb_thread_tko1
to represent execution context [Feature #14038] * vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer. There are many code using `th` to represent execution context (such as cfp, VM stack and so on). To access `ec`, they need to use `th->ec->...` (adding one indirection) so that we need to replace them by passing `ec` instead of `th`. * vm_core.h (GET_EC()): introduced to access current ec. Also remove `ruby_current_thread` global variable. * cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of rb_context_t::thread_value. * cont.c (ec_set_vm_stack): added to update vm_stack explicitly. * cont.c (ec_switch): added to switch ec explicitly. * cont.c (rb_fiber_close): added to terminate fibers explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24Lazy Proc allocation for block parametersko1
[Feature #14045] * insns.def (getblockparam, setblockparam): add special access instructions for block parameters. getblockparam checks VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM and if it is not set this instruction creates a Proc object from a given blcok and set VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM. setblockparam is similar to setlocal, but set VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM. * compile.c: use get/setblockparm instead get/setlocal instructions. Note that they are used for method local block parameters (def m(&b)), not for block local method parameters (iter{|&b|). * proc.c (get_local_variable_ptr): creates Proc object for Binding#local_variable_get/set. * safe.c (safe_setter): we need to create Proc objects for postponed block parameters when $SAFE is changed. * vm_args.c (args_setup_block_parameter): used only for block local blcok parameters. * vm_args.c (vm_caller_setup_arg_block): if called with VM_CALL_ARGS_BLOCKARG_BLOCKPARAM flag then passed block values should be a block handler. * test/ruby/test_optimization.rb: add tests. * benchmark/bm_vm1_blockparam*: added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60397 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-18refinements in string interpolationnobu
* compile.c (iseq_compile_each0): insert to_s method call, so that refinements activated at the caller should take place. [Feature #13812] * insns.def (tostring): fix up converted object to a string, infect and fallback. * insns.def (branchiftype): new instruction for conversion. branches if TOS is an instance of the given type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14Add a new instruction `trace2` for hooking with custom datamame
This is needed for passing to the hook function the measuring target type (line/branch/method) and the site of coverage event fired. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-05add rb_hash_new_with_size()shyouhei
Sometimes, size of a hash can be calcluated a priori. By providing such info to the constructor we can avoid unnecessary internal re- allocations. This can boost for instance creation of hash literals. [Bug #13861] Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-15Remove not exist arguments from comments of insnsyui-knk
is_local argument was introduced on r11639 and removed on r11813. * insns.def (getinstancevariable, setinstancevariable): Remove a not exist argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59600 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-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-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-25insns.def: [DOC] Fix description of tostringk0kubun
rb_obj_as_string() calls not #to_str (idTo_str) but #to_s (idTo_s). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-08Translate missing rdoc comment for opt_send_without_block.hsbt
fix [GH-1608], Patch by @k0kubun git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-27refactor newhash (revision 58463 another try) [fix GH-1600]shyouhei
* st.c (rb_hash_bulk_insert): new API to bulk insert entries into a hash. Given arguments are first inserted into the table at once, then reindexed. This is faster than inserting things using rb_hash_aset() one by one. This arrangement (rb_ prefixed function placed in st.c) is unavoidable because it both touches table internal and write barrier at once. * internal.h: delcare the new function. * hash.c (rb_hash_s_create): use the new function. * vm.c (core_hash_merge): ditto. * insns.def (newhash): ditto. * test/ruby/test_hash.rb: more coverage on hash creation. * test/ruby/test_literal.rb: ditto. ----------------------------------------------------------- benchmark results: minimum results in each 7 measurements. Execution time (sec) name before after loop_whileloop2 0.136 0.137 vm2_bighash* 1.249 0.623 Speedup ratio: compare with the result of `before' (greater is better) name after loop_whileloop2 0.996 vm2_bighash* 2.004 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-24revert newhash refactoringshyouhei
We need to fix GC bug before merging this. Revert revisions 58452, 58435, 58434, 58428, 58427 in this order. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-21refactor hash literalshyouhei
Same as rb_ary_tmp_new_from_values(), it reduces vm_exec_core binary size from 26,176 bytes to 26,080 bytes. But this time, also with a bit of optimizations: - Because we are allocating a new hash and no back references are introduced at all, we can safely skip write barriers. - Also, the iteration never recurs. We can avoid complicated function callbacks by using st_insert instead of st_update. ---- * hash.c (rb_hash_new_from_values): refactor extract the bulk insert into a function. * hash.c (rb_hash_new_from_object): also refactor. * hash.c (rb_hash_s_create): use the new functions. * insns.def (newhash): ditto. * vm.c (core_hash_from_ary): ditto. * iternal.h: export the new function. ----------------------------------------------------------- benchmark results: minimum results in each 7 measurements. Execution time (sec) name before after loop_whileloop2 0.135 0.134 vm2_bighash* 1.236 0.687 Speedup ratio: compare with the result of `before' (greater is better) name after loop_whileloop2 1.008 vm2_bighash* 1.798 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-20refactor torexp to use routine in array.cshyouhei
Found a part where copy&paste can be eliminated. Reduces vm_exec_core from 26,228 bytes to 26,176 bytes in size on my machine. I believe it does not affect any runtime performance. ---- * array.c (rb_ary_tmp_new_from_values): extend existing rb_ary_new_from_values function so that it can take additional value for klass. * array.c (rb_ary_new_from_values): use the new function. * insns.def (toregexp): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18typo fix (sorry!) [ci skip]shyouhei
Surprisingly this was not a syntax error on my machine. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-18fix compile error.ko1
* insns.def (trace): use cast `flag` to pass compilation with clang on MacOSX. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58394 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-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-03-27fix redefinition optimization for -"literal string" (UMinus)normal
Unfortunately this enlarges insns.def by yet another instruction. However, it is much prettier than opt_str_freeze in use, and maybe we can avoid having so many instructions in the future. [ruby-core:80368] * insns.def (DEFINE_INSN): new instruction: opt_str_uminus (maybe temporary) * compile.c (iseq_compile_each0): split instructions * test/ruby/test_optimization.rb (test_string_uminus): new test * vm.c (vm_init_redefined_flag): set redefinintion flag for uminus * vm_core.h (enum ruby_basic_operators): add BOP_UMINUS git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-09revert RB_FIXABLE related changesets [Bug #13288][Bug #13293][Bug #13294]shyouhei
This commit is auto-generated using following command: svn diff -r57807:57788 include internal.h bignum.c numeric.c compile.c insns.def object.c sprintf.c | patch -p0 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-06optimize FIXABLE macroshyouhei
Looking at the source code, FIXABLE tends to be just before LOING2FIX to check applicability of that operation. Why not try computing first then check for overflow, which should be optimial. I also tried the same thing for unsigned types but resulted in slower execution. It seems RB_POSFIXABLE() is fast enough on modern CPUs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-02Use carry flag to reduce instructionsnaruse
NOTE: (1) Fixnum's LSB is always 1. It means you can always run `x - 1` without overflow. (2) Of course `z = x + (y-1)` may overflow. Now z's LSB is always 1, and the MSB of true result is also 1. You can get true result in long as `(1<<63)|(z>>1)`, and it equals to `(z<<63)|(z>>1)` == `ror(z)`. GCC and Clang have __builtin_add_ovewflow: * https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html * https://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-13insns.def: float comparisonnobu
* insns.def (opt_lt, opt_le, opt_gt, opt_ge): optimize flonum and on-heap float comparison. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-07adjust indent [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-07fix optimization for hash aset/aref with fstringeregon
Patch by Eric Wong [ruby-core:78797]. I don't like the idea of making insns.def any bigger to support a corner case, and "test_hash_aref_fstring_identity" shows how contrived this is. [ruby-core:78783] [Bug #12855] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-28insns.def: adjust index typenobu
* insns.def (checkmatch): adjust type of the index variable, to get rid of (potential) overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-05* vm_trace.c (tracepoint_attr_callee_id, rb_tracearg_callee_id):ktsj
add TracePoint#callee_id. [ruby-core:77241] [Feature #12747] * cont.c, eval.c, gc.c, include/ruby/intern.h, insns.def, thread.c, vm.c, vm_backtrace.c, vm_core.h, vm_eval.c, vm_insnhelper.c, vm_trace.c: ditto. * test/ruby/test_settracefunc.rb: tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e