summaryrefslogtreecommitdiff
path: root/compile.c
AgeCommit message (Collapse)Author
2018-05-02compile.c: mark catch_except_p of iseqk0kubun
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
2018-04-25compile.c: fix unconditional branch optimizationnobu
* 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
2018-04-23compile.c: copy a short insn with leavenobu
* 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
2018-04-23compile.c: insn before popnobu
* 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
2018-04-21compile.c: optimize checktypenobu
* 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
2018-04-21insns.def: checktypenobu
* 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
2018-04-21compile.c: renamed macro argumentsnobu
* 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
2018-04-16compile.c: align rangenobu
* 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
2018-04-13Add write barrier calls for direct marking objects.tenderlove
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
2018-04-08compile.c: disable debug prints on sparcnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-08compile.c: fix an exception argumentnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-08compile.c: suppress warningsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-08compile.c: align ibf_object_headernobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-08compile.c: debug prints in ibf_load_objectnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-08compile.c: align IBF dumped datanobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-07compile.c: refine debug printsnobu
* compile.c (ibf_load_iseq_complete): use alternate hexadecimal form for offset. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-05compile.c: fix positions encodenobu
* compile.c (ibf_load_iseq_each): iseq_size necessary to encode positions is set in ibf_load_code(). [Bug #14660] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-05compile.c: do not dump pointersnobu
* compile.c (ibf_dump_iseq_each): ensure succ_index_table pointer field to be 0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-05compile.c: clear paddingnobu
* compile.c (IBF_ZERO): clear padding of struct not to include garbages in dumped binary data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-05compile.c: do not dump pointersnobu
* compile.c (ibf_dump_iseq_each): do not dump succ_index_table pointer. positions are dumped as integer arrays. pointer values are meaningless outside the process. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-05compile.c: zero fillnobu
* compile.c (ibf_dump_align): fill padding with zero, instead of resizing only, not to leave garbages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-31compile.c: compile_evstrnobu
* compile.c (compile_evstr): extract from iseq_compile_each. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-31compile.c: end_labelnobu
* compile.c (compile_if): branch to end_label is not used if else_seq is not used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-30compile.c: do not dump unused callinfosnobu
* compile.c (compile_if): rewind callinfo indexes used in unreachable paths, to get rid of dumping unused callinfos. [ruby-core:86399] [Bug #14553] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-24compile.c: split add_insn_infonobu
* compile.c (add_insn_info, add_adjust_info): split for each list->type, to remove unnecessary repeated conditions and casts. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-24compile.c: suppress missing-noreturnnobu
* compile.c (add_insn_info): move return statement to suppress missing-noreturn warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-20node.c: predicates for special NODEsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-20compile.c: fix ibf_load_codenobu
* compile.c (ibf_load_iseq_each): manage iseq_size to point loaded objects in iseq_encoded. now marking iseq scans iseq_encoded directly. * test/ruby/test_iseq.rb (test_to_binary_with_objects): skip for now, but fix argument order of assert_equal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-19Reverting r62775, this should fix i686 buildstenderlove
We need to mark default values for kwarg methods. This also fixes Bootsnap. IBF iseq loading needed to mark iseqs as "having markable objects". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-19compile.c: arg var indexnobu
* compile.c (iseq_set_arguments): determine argument variable indexes by the order, not by just IDs. arguments begin with `_` can be duplicate, so by-ID index may result in a wrong value. [ruby-core:86159] [Bug #14611] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-18compile.c: fix function name [ci skip]nobu
* compile.c (ibf_dump_object_object): fix a probable typo in the function name, s/lbf/ibf/. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-17compile.c: resize to align offsetsnobu
* compile.c (ibf_dump_align): resize the dump buffer. rb_str_modify_expand expands the buffer but not set the length. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-17debugging SEGV on Solaris11snobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-17compile.c: align offsetsnobu
* compile.c (ibf_dump_align): expand the buffer for alignment. * compile.c (ibf_dump_iseq_list, ibf_dump_object_list): align as ibf_offset_t. not all processors do not allow unaligned word, or larger, access. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-17debugging SEGV on Solaris11snobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-16debugging SEGV on Solaris11snobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-16debugging SEGV on Solaris11snobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-16Revert "Add direct marking on iseq operands"naruse
This reverts commit r62706. It causes SEGV on i686-linux (debian) and armv7l-linux-eabihf: http://www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20180309T204300Z.diff.html.gz http://rubyci.s3.amazonaws.com/scw-9d6766/ruby-trunk/log/20180309T211706Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-16Revert "Fix error: implicit conversion loses integer precision"naruse
This reverts commit r62708. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-16compile.c: fix load_from_binarynobu
* compile.c (ibf_load_iseq_each): realpath may be nil. follow up r59709. [fix https://github.com/Shopify/bootsnap/issues/132] From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-15Revert r62617 "compile.c: fix load_from_binary"naruse
It breaks Solaris: http://rubyci.s3.amazonaws.com/unstable11s/ruby-trunk/log/20180301T012502Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-10compile.c: mark all ISeq ancestors as catch_except_pk0kubun
This change assumes that continuously reading `parent_iseq` from block ISeq would reach non-block ISeq finally. test/ruby/test_jit.rb: add test that catches 2-depth exception Combination of r62654 and r62678 caused following error in this test. -e:12:in `wrapper': Stack consistency error (sp: 14, bp: 13) (fatal) == disasm: #<ISeq:wrapper@-e:10 (10,0)-(12,3)> (catch: FALSE)=========== local table (size: 2, argc: 2 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 2] paths<Arg> [ 1] prefixes<Arg> 0000 putself ( 11)[LiCa] 0001 getlocal_WC_0 paths 0003 getlocal_WC_0 prefixes 0005 opt_send_without_block <callinfo!mid:catch_true, argc:2, FCALL|ARGS_SIMPLE>, <callcache> 0008 leave ( 12)[Re] As you can see, it says `catch: FALSE`, but obviously it catches exception raised from `return path`. As of r62655, it was kind of intentional because I only cared about expiration of JIT-ed frame and I've thought calling `vm_exec` is only needed once for it. So r62654 was NOT actually checking if it may catch exception. But for r62678, obviously we should set catch_except_p=TRUE for all ISeqs which may catch exception. Otherwise catch table lookup would fail. With this bugfix, code generated by r62655 might be worse, but at least while loop can be marked as `catch: FALSE` as expected. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-10Fix error: implicit conversion loses integer precisionkazu
http://ci.rvm.jp/results/trunk_clang_50@silicon-docker/627906 ``` iseq.h:41:36: error: implicit conversion loses integer precision: 'rb_num_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32] int cnt = iseq->body->variable.flip_count; ~~~ ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-09Add direct marking on iseq operandstenderlove
Directly marking iseq operands allows us to eliminate the "mark array" stored on ISEQ objects, which will reduce the amount of memory ISEQ objects consume. This patch changes the iseq mark function to: * Directly marks ISEQ operands * Iterate over and mark child ISEQs It also introduces two flags on the ISEQ object. In order to mark instruction operands, we have to disassemble the instructions and find the instruction parameters and types. Instructions may also be translated to jump addresses. Instruction sequences may get marked by the GC *while* they're mid flight (being compiled). The `ISEQ_TRANSLATED` flag is used to indicate whether or not the instructions have been translated to jump addresses so that when we decode the instructions we know whether or not we need to go from jump location back to original instruction or not. Not all ISEQ objects have any markable objects embedded in their instructions. We can detect whether or not an ISEQ has markable objects in the instructions at compile time. If the instructions contain markable objects, we set a flag `ISEQ_MARKABLE_ISEQ` on the ISEQ object. This means that during the mark phase, we can skip decompilation if the flag is *not* set. In other words, we can avoid decompilation of we know in advance there is nothing to mark. `once` instructions have an operand that contains the result of a one-time compilation of a regex. Before this patch, that operand was called an "inline cache", even though the struct was actually an "inline storage". This patch changes the operand to be an "inline storage" so that we can differentiate between caches that need marking (the inline storage) and caches that don't need marking (inline cache). [ruby-core:84909] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-04compile.c: set catch_except_p flagk0kubun
to be used for MJIT's optimization. It's not used for optimization in this commit yet. vm_core.h: added catch_except_p field. iseq.c: show the flag in ISeq disasm for debugging. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-01compile.c: raise on invalid inputnobu
* compile.c (ibf_load_object_unsupported, ibf_load_object_class): should raise an exception. rejection of invalid input is not a bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-01compile.c: do not truncate VALUE to longnobu
* compile.c (ibf_dump_object_regexp): do not truncate VALUE to long. it makes invalid VALUE on IL32LLP64 platforms where long is shorter than VALUE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-01compile.c: fix load_from_binarynobu
* compile.c (ibf_load_iseq_each): realpath may be nil. follow up r59709. [fix https://github.com/Shopify/bootsnap/issues/132] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-28Revert r61936 "compile.c: use ALLOCV_N"nobu
* compile.c (ibf_dump_object_list): `dump->obj_list` is not fixed yet, as new objects are pushed by lbf_dump_object_object. fixes crash by buffer overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-16compile.c: keep debug infonobu
* compile.c (iseq_peephole_optimize): keep freezestring insn with debug info. [Bug #14475] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e