Граф коммитов

827 Коммитов

Автор SHA1 Сообщение Дата
mame 100bf27574 compile.c: remove tracecoverage instruction for line coverage
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
2018-08-22 11:09:47 +00:00
mame d65f7458bc parse.y: remove coverage-related code fragments
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
2018-08-22 10:38:56 +00:00
nobu af2e98ae80 Optimization for case when with splat operator
[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
2018-08-12 08:10:53 +00:00
nobu fe781af377 compile.c: use EXPECT_NODE macro
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-12 04:50:48 +00:00
nobu e7f88ff684 compile.c: check error in when_vals
* 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
2018-08-12 04:50:14 +00:00
mame 2138f24c70 insns.def (invokesuper): remove a dummy receiever flag hack for ZSUPER
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
2018-08-10 07:45:16 +00:00
tenderlove d8583b132c Remove redundant code in the compiler.
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
2018-07-09 20:01:54 +00:00
tenderlove 162cbfe631 Remove test code. ISE generation should not impact write barrier
orz!

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-09 19:20:27 +00:00
tenderlove 7aab72f736 Fix crash when loading iseq from an array
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
2018-07-09 17:47:37 +00:00
nobu 5e7167f8fb compile.c: remove unreachable jump only
* 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
2018-07-06 08:01:58 +00:00
mame 727ceb2a95 Fix a bug of peephole optimization
```
  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
2018-07-06 04:52:33 +00:00
nobu aec14b33d4 vm.c: simplified core#hash_merge_kwd
* 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
2018-07-03 23:56:11 +00:00
mame 606d6b3470 Revert "range.c: prohibit `(1..nil)`"
This reverts commit a44c010764a16ae09aaed49d76eec055ca0057c8.
Refs #14845.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-13 11:00:28 +00:00
mame 48de2ea5f9 range.c: prohibit `(1..nil)`
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
2018-06-13 09:04:32 +00:00
normal 609939f8c6 rb_vm_insn_addr2insn: use st to perform addr2insn mapping
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
2018-06-06 20:57:48 +00:00
nobu a12bfb3bbd iseq body local variables
* 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
2018-05-16 01:40:44 +00:00
yui-knk 8b88f70a84 compile.c: Fix segfault when VM_INSN_INFO_TABLE_IMPL is not 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
2018-05-13 12:31:38 +00:00
nobu 5afd479de6 compile.c: suppress a warning
* 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
2018-05-09 17:17:06 +00:00
shyouhei 75d5cf55de RSTRING_PTR is not guaranteed to be VALUE-aligned (retry)
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
2018-05-09 05:42:06 +00:00
k0kubun 14a3499c4f compile.c: mark catch_except_p of iseq
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-05-02 12:55:57 +00:00
nobu 067066fc9b compile.c: fix unconditional branch optimization
* 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-25 06:45:05 +00:00
nobu 4cae5353c0 compile.c: copy a short insn with leave
* 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-23 12:51:18 +00:00
nobu c6ad7a6272 compile.c: insn before pop
* 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-23 09:52:23 +00:00
nobu fde115b13c compile.c: optimize checktype
* 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-21 10:52:53 +00:00
nobu a3fe1034c4 insns.def: checktype
* 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-21 10:52:52 +00:00
nobu c458aeffd1 compile.c: renamed macro arguments
* 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-21 07:48:36 +00:00
nobu 58a2084483 compile.c: align range
* 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-16 12:46:08 +00:00
tenderlove 5bafb6c596 Add write barrier calls for direct marking objects.
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-13 21:36:51 +00:00
nobu 610dc339b6 compile.c: disable debug prints on sparc
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-08 11:17:45 +00:00
nobu fda1837e49 compile.c: fix an exception argument
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-08 11:12:17 +00:00
nobu a72a50b15c compile.c: suppress warnings
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-08 08:28:40 +00:00
nobu 0f8368ca32 compile.c: align ibf_object_header
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-08 08:20:11 +00:00
nobu 89a6a4ec8c compile.c: debug prints in ibf_load_object
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-08 07:42:23 +00:00
nobu b6185e175c compile.c: align IBF dumped data
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-08 05:22:49 +00:00
nobu ba267bce47 compile.c: refine debug prints
* 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-07 09:44:30 +00:00
nobu 7084c015bf compile.c: fix positions encode
* 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-05 13:13:00 +00:00
nobu d1c9c0add4 compile.c: do not dump pointers
* 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-05 12:46:46 +00:00
nobu e9c2fe4e95 compile.c: clear padding
* 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-05 12:03:36 +00:00
nobu bc6e61f149 compile.c: do not dump pointers
* 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-05 07:04:39 +00:00
nobu 04dfc46ad0 compile.c: zero fill
* 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-04-05 07:00:08 +00:00
nobu baabfa3fa2 compile.c: compile_evstr
* 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-31 15:48:59 +00:00
nobu 6b346a7c85 compile.c: end_label
* 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-31 15:48:57 +00:00
nobu 484cc6b3bc compile.c: do not dump unused callinfos
* 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-30 05:15:07 +00:00
nobu 4a145f6ea8 compile.c: split add_insn_info
* 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-24 11:15:10 +00:00
nobu afa1d5080f compile.c: suppress missing-noreturn
* 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-24 11:04:37 +00:00
nobu b4b3de3e7c node.c: predicates for special NODEs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-20 13:30:57 +00:00
nobu ce848356ae compile.c: fix ibf_load_code
* 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-20 08:36:42 +00:00
tenderlove 9e26858e8c Reverting r62775, this should fix i686 builds
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-19 18:21:54 +00:00
nobu 9720136d9c compile.c: arg var index
* 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-19 04:08:19 +00:00
nobu 0140921523 compile.c: fix function name [ci skip]
* 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-18 10:41:53 +00:00