aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
Commit message (Collapse)AuthorAgeFilesLines
* * expand tabs.svn2018-10-171-5/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove the level information from throw instructionmame2018-10-171-10/+7
| | | | | | It is no longer used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Prefer `rb_fstring_lit` over `rb_fstring_cstr`nobu2018-10-131-2/+2
| | | | | | | The former states explicitly that the argument must be a literal, and can optimize away `strlen` on all compilers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-09-261-7/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r64847, r64846 and r64839k0kubun2018-09-261-7/+9
| | | | | | because r64849 seems to fix issues which we were confused about. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-09-261-7/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r64838 and r64839k0kubun2018-09-261-3/+7
| | | | | | because some build failures persisted git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* insns.def: drop bitblt insnk0kubun2018-09-251-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | as a workaround to fix the build pipeline broken by r64824, because optimizing Ruby should be prioritized higher than supporting unused jokes. In the current build system, exceeding 200 insns somehow crashes C extension build on some of MinGW environments like "mingw32-make[1]: *** No rule to make target 'note'. Stop." https://ci.appveyor.com/project/ruby/ruby/build/9725/job/co4nu9jugm8qwdrp and on some of Linux environments like "cannot load such file -- stringio (LoadError)" ``` build_install /home/ko1/ruby/src/trunk_gcc5/lib/rubygems/specification.rb:18:in `require': cannot load such file -- stringio (LoadError) from /home/ko1/ruby/src/trunk_gcc5/lib/rubygems/specification.rb:18:in `<top (required)>' from /home/ko1/ruby/src/trunk_gcc5/lib/rubygems.rb:1365:in `require' from /home/ko1/ruby/src/trunk_gcc5/lib/rubygems.rb:1365:in `<module:Gem>' from /home/ko1/ruby/src/trunk_gcc5/lib/rubygems.rb:116:in `<top (required)>' from /home/ko1/ruby/src/trunk_gcc5/tool/rbinstall.rb:24:in `require' from /home/ko1/ruby/src/trunk_gcc5/tool/rbinstall.rb:24:in `<main>' make: *** [do-install-nodoc] Error 1 ``` http://ci.rvm.jp/results/trunk_gcc5@silicon-docker/1353447 This commit removes "bitblt" and "trace_bitblt" insns, which reduces the number of insns from 202 to 200 and fixes at least the latter build failure. I hope this fixes the MinGW build failure as well. Let me confirm the situation on AppVeyor CI. Note that this is hard to fix because some MinGW environments (MSP-Greg's MinGW CI on AppVeyor) don't reproduce this and some Linux environments (including my local machine) don't reproduce it either. Make sure you have the reproductive environment and confirm it's fixed when reverting this commit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Revert r64824 to fix build failure on AppVeyor"k0kubun2018-09-251-0/+2
| | | | | | | This reverts commit r64829. I'll prepare another temporary fix, but I'll separately commit that to make it easier to revert that later. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert r64824 to fix build failure on AppVeyork0kubun2018-09-251-2/+0
| | | | | | | | | AppVeyor msys2/MinGW build started to fail like: https://ci.appveyor.com/project/ruby/ruby/build/9722/job/b94kixi004klmye3 Until I can investigate that, I revert this for now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* insns.def: optimize & and | of Integer [experimental]k0kubun2018-09-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | not optimizing Array#& and Array#| because vm_insnhelper.c can't easily inline it (large amount of array.c code would be needed in vm_insnhelper.c) and the method body is a little complicated compared to Integer's ones. So I thought only Integer#& and Integer#| have a significant impact, and eliminating unnecessary branches would contribute to JIT's performance. vm_insnhelper.c: ditto tool/transform_mjit_header.rb: make sure these instructions are inlined on JIT. compile.c: compile vm_opt_and and vm_opt_or. id.def: define id for them to be used in compile.c and vm*.c vm.c: track redefinition of Integer#& and Integer#| vm_core.h: allow detecting redefinition of & and | test/ruby/test_jit.rb: test new insns test/ruby/test_optimization.rb: ditto * Optcarrot benchmark This is a kind of experimental thing but I'm committing this since the performance impact is significant especially on Optcarrot with JIT. $ benchmark-driver benchmark.yml --rbenv 'before::before --disable-gems;before+JIT::before --disable-gems --jit;after::after --disable-gems;after+JIT::after --disable-gems --jit' -v --repeat-count 24 before: ruby 2.6.0dev (2018-09-24 trunk 64821) [x86_64-linux] before+JIT: ruby 2.6.0dev (2018-09-24 trunk 64821) +JIT [x86_64-linux] after: ruby 2.6.0dev (2018-09-24 opt_and 64821) [x86_64-linux] last_commit=opt_or after+JIT: ruby 2.6.0dev (2018-09-24 opt_and 64821) +JIT [x86_64-linux] last_commit=opt_or Calculating ------------------------------------- before before+JIT after after+JIT Optcarrot Lan_Master.nes 51.460 66.315 53.023 71.173 fps Comparison: Optcarrot Lan_Master.nes after+JIT: 71.2 fps before+JIT: 66.3 fps - 1.07x slower after: 53.0 fps - 1.34x slower before: 51.5 fps - 1.38x slower [close https://github.com/ruby/ruby/pull/1963] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (compile_case): emit opt_case_dispatch only on optimized modemame2018-09-201-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use opt_{aref,aset} over opt_{aref,aset}_withnobu2018-09-151-0/+2
| | | | | | | | | | | | * compile.c (iseq_compile_each0): Use `opt_aref`/`opt_aset` over `opt_aref_with`/`opt_aset_with` when frozen_string_literal: true, not to resurrect the index string on non-Hash receiver. [Fix GH-1957] From: chopraanmol1 <chopraanmol1@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: prefix rb_ to non-static iseq functionsk0kubun2018-09-131-8/+8
| | | | | | | | | | I assume we always prefix rb_ to non-static functions to avoid conflict. These functions are not exported and safe to be renamed. iseq.h: ditto compile.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* make opt_str_freeze leafshyouhei2018-09-121-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | Simply use DISPATCH_ORIGINAL_INSN instead of rb_funcall. This is, when possible, overall performant because method dispatch results are cached inside of CALL_CACHE. Should also be good for JIT. ---- trunk: ruby 2.6.0dev (2018-09-12 trunk 64689) [x86_64-darwin15] ours: ruby 2.6.0dev (2018-09-12 leaf-insn 64688) [x86_64-darwin15] last_commit=make opt_str_freeze leaf Calculating ------------------------------------- trunk ours vm2_freezestring 5.440M 31.411M i/s - 6.000M times in 1.102968s 0.191017s Comparison: vm2_freezestring ours: 31410864.5 i/s trunk: 5439865.4 i/s - 5.77x slower git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* make opt_case_dispatch leafshyouhei2018-09-121-13/+43
| | | | | | | | | | | | | | | | | | | | | | | | | This instruction can be written without rb_funcall. It not only boosts performance of case statements, but also makes room of future JIT improvements. Because opt_case_dispatch is about optimization this should not be a bad thing to have. ---- trunk: ruby 2.6.0dev (2018-09-05 trunk 64634) [x86_64-darwin15] ours: ruby 2.6.0dev (2018-09-12 leaf-insn 64688) [x86_64-darwin15] last_commit=make opt_case_dispatch leaf Calculating ------------------------------------- trunk ours vm2_case_lit 1.366 2.012 i/s - 1.000 times in 0.731839s 0.497008s Comparison: vm2_case_lit ours: 2.0 i/s trunk: 1.4 i/s - 1.47x slower git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: add a map from encoded insn to insn datamame2018-08-231-29/+0
| | | | | | | | | | This enhances rb_vm_insn_addr2insn which retrieves a decoded insn number from encoded insn. The insn data table include not only decoded insn number, but also its len, trace and non-trace version of encoded insn. This table can be used to simplify trace instrumentation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: drop unused arraynobu2018-08-231-0/+5
| | | | | | | * compile.c (iseq_peephole_optimize): drop unused dynamic array literal, without concatenation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: drop unused stringnobu2018-08-231-0/+9
| | | | | | | * compile.c (iseq_peephole_optimize): drop unused dynamic string literal, without concatenation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* remove `const` warning.ko12018-08-231-1/+1
| | | | | | | | * compile.c (iseq_ibf_load): remove `const` to pass iseq as no `const` parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* check trace flags at loading [Bug #14702]ko12018-08-231-0/+2
| | | | | | | | | | | | * iseq.c (iseq_init_trace): at ISeq loading time, we need to check `ruby_vm_event_enabled_flags` to turn on trace instructions. Seprate this checking code from `finish_iseq_build()` and make new function. `iseq_ibf_load()` calls this funcation after loading. * test/ruby/test_iseq.rb: add a test for this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: pop literal object in conditionnobu2018-08-221-0/+7
| | | | | | | * compile.c (compile_branch_condition): pop dynamic literal object, which is never nil/false, as the branch condition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: remove tracecoverage instruction for line coveragemame2018-08-221-23/+9
| | | | | | | Line coverage was based on special instruction "tracecoverage". Now, instead, it uses the mechanism of trace hook [Feature #14104]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: remove coverage-related code fragmentsmame2018-08-221-0/+1
| | | | | | | | | | | | | The code fragments that initializes coverage data were scattered into both parse.y and compile.c. parse.y allocated a coverage data, and compile.c initialize the data. To remove this cross-cutting concern, this change moves the allocation from "coverage" function of parse.y to "rb_iseq_new_top" of iseq.c. For the sake, parse.y just counts the line number of the original source code, and the number is passed via rb_ast_body_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Optimization for case when with splat operatornobu2018-08-121-4/+42
| | | | | | | | [Fix GH-1928] [Feature #14984] From: chopraanmol1 <chopraanmol1@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: use EXPECT_NODE macronobu2018-08-121-5/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: check error in when_valsnobu2018-08-121-1/+2
| | | | | | | | * compile.c (when_vals): return a negative value on error. * compile.c (compile_case): check error in when_vals(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* insns.def (invokesuper): remove a dummy receiever flag hack for ZSUPERmame2018-08-101-3/+2
| | | | | | | | | | | | | | | This is just a refactoring. The receiver of "invokesuper" was a boolean to represent if it is ZSUPER or not. This was used in vm_search_super_method to prohibit ZSUPER call in define_method. (It is currently prohibited because of the limitation of the implementation.) This change removes the hack by introducing an explicit flag, VM_CALL_SUPER, to signal the information. Now, the implementation of "invokesuper" is consistent with "send" instruction. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove redundant code in the compiler.tenderlove2018-07-091-21/+4
| | | | | | | | | | | During instruction translation (linked list -> iseq generation), we can treat `TS_VALUE` and `TS_ISEQ` the same as they are just embedded in the generated sequences. The only difference between `TS_ISE` and `TS_IC` is that an inline storage entry may contain a markable `VALUE` pointer at some point, so we need to flag the iseq as containing markable objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove test code. ISE generation should not impact write barriertenderlove2018-07-091-1/+0
| | | | | | orz! git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix crash when loading iseq from an arraytenderlove2018-07-091-4/+10
| | | | | | | | Objects loaded during iseq deserialization using arrays need to be added to the compile time mark array so that they stay alive until iseqs finish loading. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: remove unreachable jump onlynobu2018-07-061-3/+9
| | | | | | | | | * compile.c (iseq_peephole_optimize): remove unreachable jump instruction only. if it is labeled and referred from other instructions, it is reachable and must not be removed. [ruby-core:87830] [Bug #14897] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix a bug of peephole optimizationmame2018-07-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | ``` if L1 L0: jump L2 L1: ... L2: ``` was wrongly optimized to: ``` unless L2 L0: L1: ... L2: ``` To make it conservative, this optimization is now disabled when there is any label between `if` and `jump` instructions. Fixes [Bug #14897]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm.c: simplified core#hash_merge_kwdnobu2018-07-031-3/+2
| | | | | | | | | | | * vm.c (core_hash_merge_kwd): simplified to merge the second hash into the first hash. * compile.c (compile_array): call core#hash_merge_kwd with 2 hashes always, by passing an new empty hash to at the first iteration. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "range.c: prohibit `(1..nil)`"mame2018-06-131-2/+2
| | | | | | | This reverts commit a44c010764a16ae09aaed49d76eec055ca0057c8. Refs #14845. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* range.c: prohibit `(1..nil)`mame2018-06-131-2/+2
| | | | | | | | | | Now endless range can be created by either a literal `(1..)` or explicit range creation `Range.new(1, nil)`. [Bug #14845] This change is intended for "early failure"; for example, `(1..var).to_a` causes out of memory if `var` is inadvertently nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rb_vm_insn_addr2insn: use st to perform addr2insn mappingnormal2018-06-061-7/+21
| | | | | | | | | | | | | | | | | The current VM_INSTRUCTION_SIZE is 198, so the linear search painful during a major GC phase. I noticed rb_vm_insn_addr2insn2 showing up at the top of some profiles while working on some malloc-related stuff, so I decided to attack it. Most notably, the benchmark/bm_vm3_gc.rb improves by over 40%: https://80x24.org/spew/20180602220554.GA9991@whir/raw [ruby-core:87361] [Feature #14814] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq body local variablesnobu2018-05-161-150/+167
| | | | | | | * compile.c, iseq.c: extract body and param.keyword in iseq as local variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: Fix segfault when VM_INSN_INFO_TABLE_IMPL is not 2yui-knk2018-05-131-2/+2
| | | | | | | | | | * compile.c (ibf_dump_iseq_each): Fix a range of a conditional. `positions` is only used when VM_INSN_INFO_TABLE_IMPL is 2. And always `dump_body` is expected to be initialized by `iseq->body`. For example, `dump_body->insns_info.size` is used in `ibf_dump_insns_info_positions`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: suppress a warningnobu2018-05-091-1/+2
| | | | | | | * compile.c (iseq_peephole_optimize): initialize dniobj first, to suppress a false warning by gcc 8.1.0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RSTRING_PTR is not guaranteed to be VALUE-aligned (retry)shyouhei2018-05-091-1/+1
| | | | | | | | Don't abuse struct RString to hold arbitrary memory region. Raw pointer should just suffice. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: mark catch_except_p of iseqk0kubun2018-05-021-10/+8
| | | | | | | | | | which has throw insn, not only ancestor iseqs of it. I think we should remove catch_except_p flag and try to simplify the catch table itself, to prevent similar bugs in the future. test_jit.rb: add test to prevent the bug git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: fix unconditional branch optimizationnobu2018-04-251-0/+4
| | | | | | | | * compile.c (iseq_peephole_optimize): add dummy `putnil` after a `jump` replacing an unconditional branch, to adjust removed `dup`. [ruby-core:86666] [Bug #14708] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: copy a short insn with leavenobu2018-04-231-4/+14
| | | | | | | * compile.c (iseq_peephole_optimize): copy not only `leave`, with a non-operand instruction, which are not longer than `jump`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: insn before popnobu2018-04-231-0/+5
| | | | | | | * compile.c (iseq_peephole_optimize): more eliminatable instructions before `pop` without side effects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: optimize checktypenobu2018-04-211-0/+98
| | | | | | | * compile.c (optimize_checktype): optimize `checktype` instruction on a literal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* insns.def: checktypenobu2018-04-211-2/+2
| | | | | | | * insns.def (checktype): split branchiftype to checktype and branchif, to make branch condition negation possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: renamed macro argumentsnobu2018-04-211-6/+6
| | | | | | | * compile.c (INSERT_BEFORE_INSN, INSERT_BEFORE_INSN1): rename argument `prev` as `next`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: align rangenobu2018-04-161-1/+2
| | | | | | | * compile.c (ibf_dump_object_struct): align range elements. [ruby-core:86548] [Bug #14689] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add write barrier calls for direct marking objects.tenderlove2018-04-131-6/+25
| | | | | | | | | | | | | This commit adds write barriers for objects marked from `rb_iseq_mark`. r62851 introduced direct marking from iseqs to: * keyword arg default values * catch table iseqs * VALUEs embedded in encoded instructions This patch adds missing write barrier calls to those references. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e