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

647 Коммитов

Автор SHA1 Сообщение Дата
nobu df33c063fc literal symbol by intern
* 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-17 09:28:58 +00:00
nobu 08bb3640d7 compile.c: optimize unnecessary concatstrings
* compile.c (iseq_peephole_optimize): optimize away unnecessary
  concatenation of single string, following tostring which always
  puts a String instance.
  https://github.com/ruby/ruby/pull/1626#discussion_r139285653

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-17 09:21:47 +00:00
nobu ad094e3ac3 suppress warnings
* compile.c: suppress maybe-uninitialized warnings by gcc7.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-17 05:51:15 +00:00
nobu ea49381e51 compile.c: iseq_pop_newarray
* compile.c (iseq_pop_newarray): optimize array literal in
  condition.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 08:04:30 +00:00
mame 3c8c17d30d Introduce NODE_UNLESS for branch coverage
`unless` statement was a syntactic sugar for `if` statement,
which made the result of branch coverage hard to understand.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 05:27:02 +00:00
mame 78cf46078e Add method coverage
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 05:12:34 +00:00
mame 1f7abf7283 Add branch coverage for case-when statement
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 04:32:58 +00:00
mame 16ab236b88 Add branch coverage for while and until statements
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 03:36:05 +00:00
mame ce570370f0 Add branch coverage for if statement
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 03:25:36 +00:00
mame d1b290d5ba Add a new instruction `trace2` for hooking with custom data
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-14 01:55:30 +00:00
nobu d446f15c97 compile.c: pop coverage trace
* compile.c (iseq_compile_each0): pop trace for coverage only and
  clear its corresponding line.  [ruby-core:82726] [Bug #13886]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-10 16:19:40 +00:00
nobu 6c3c48e3d5 compile.c: replaced switch by TYPE
* compile.c (int_param): prefer FIXNUM_P and NIL_P to switch by
  TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-09 09:16:56 +00:00
mame 1a643bac88 Remove unneeded trace instruction for coverage
When no instruction is emitted in `iseq_compile_each0`
(i.e., when the line has no significant code), trace
instruction for `RUBY_EVENT_LINE` has been optimized out.
But trace for `RUBY_EVENT_COVERAGE` has not been removed.
Now, it is also removed.

`TestISeq#test_to_a_lines` has failed a long time under
coverage measurement (`make test-all COVERAGE=true`).
This change makes it pass.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-07 12:36:01 +00:00
mame cd6df5fb3c Refactor the internal data format for coverage measurement
To prepare new measuring targets: branch and method coverages.
So far, iseq->coverage was an array of counts executed for line coverage.
Now, it is a three-element array for each measuring target,
whose first element is an array for line coverage.
The second element is planned for branch coverage, and the third will be
for method coverage.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-03 14:26:06 +00:00
nobu b8243bb8f2 compile.c: fix loading pathobj
* compile.c (ibf_load_iseq_each): location.pathobj may not be a
  mere string now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-01 00:58:52 +00:00
nobu d6347a467d compile.c: ensure after toplevel return
* compile.c (iseq_compile_each0): toplevel returns should fire
  ensures.  [ruby-core:82492] [Bug #13844]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-01 00:43:00 +00:00
nobu 4446f52896 compile.c: compile_if
* compile.c (compile_if): extract from iseq_compile_each.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-28 14:21:40 +00:00
nobu a2f5275e0b compile.c: compile_ensure
* compile.c (compile_ensure): extract from iseq_compile_each.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-27 16:18:17 +00:00
nobu 7999209019 compile.c: compile_resbody
* compile.c (compile_resbody): extract from iseq_compile_each.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-27 16:15:19 +00:00
nobu c1b32b5a1b compile.c: compile_rescue
* compile.c (compile_rescue): extract from iseq_compile_each.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-27 16:04:26 +00:00
nobu c0baa381b5 compile.c: unreachable chunk
* compile.c (iseq_peephole_optimize): remove unreachable chunk
  which appeared by useless jump elimination.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-25 03:41:43 +00:00
nobu ed3a575b59 compile.c: useless jump elimination
* compile.c (iseq_peephole_optimize): eliminate useless if/unless
  just before jump.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-25 03:33:32 +00:00
nobu 0faeb9039f compile.c: moved comments [ci skip]
* compile.c (iseq_peephole_optimize): moved comments inside proper
  blocks.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-25 02:37:38 +00:00
nobu 7971a1246b compile.c: show failed instructions
* compile.c (iseq_set_sequence): show failed instructions at
  adjuststack mismatch.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-24 07:31:56 +00:00
nobu 37228c0fe2 compile.c: free before adjust error
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-24 07:26:05 +00:00
nobu 1f89414c20 insns.inc.tmpl: ensure info size
* template/insns.inc.tmpl (ASSERT_VM_INSTRUCTION_SIZE): static
  assertion for VM instruction info tables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-22 03:07:01 +00:00
nobu bc33c5ce0a compile.c: compile_retry
* compile.c (compile_retry): extract from iseq_compile_each.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-15 00:45:14 +00:00
nobu b0e2c2476e compile.c: compile_redo
* compile.c (compile_redo): extract from iseq_compile_each.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-15 00:45:13 +00:00
nobu 7e958b890e compile.c: compile_next
* compile.c (compile_next): extract from iseq_compile_each.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-15 00:18:47 +00:00
nobu 582b7057dc compile.c: compile_break
* compile.c (compile_break): extract from iseq_compile_each.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-14 23:55:34 +00:00
nobu d5b3c0fda6 compile.c: compile_loop
* compile.c (compile_loop): extract from iseq_compile_each.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-14 14:25:27 +00:00
nobu 3bf3108c8e type is invariant inside this block
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-14 14:18:29 +00:00
nobu 03a2862b98 separate hash literal and keyword arguments
* compile.c (compile_array_keyword_arg): separate keyword splat
  inside hash literal from argument list.

* parse.y (rparen): flag hash literal.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-11 01:27:24 +00:00
nobu 059cf260e7 compile.c: fix KW_SPLAT flag condition
* compile.c (compile_array_keyword_arg): fix the condition of
  KW_SPLAT flag.  splat is value node only without key node,
  simple assoc argument is not.  [ruby-core:82291] [Bug #13793]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-10 00:50:45 +00:00
nobu 26aed9c577 splat keyword hash
* 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-08-05 06:58:44 +00:00
nobu 44544c036c compile.c: replace adjuststack
* compile.c (iseq_set_sequence): replace adjuststack with pop, or
  remove if possible instead of two nops.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-30 00:40:43 +00:00
nobu c1d5d16c38 compile.c: fix flip-flop value
* compile.c (iseq_compile_each0): as compile_flip_flop always ends
  with a jump instruction, successive instruction is never reached,
  but caused stack consistency error without peephole optimization.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-29 02:03:11 +00:00
nobu 52bb1dadd5 compile.c: COMPILE_ERROR
* compile.c: raise COMPILE_ERROR instead of compile_bug which is
  very rarely (or never, actually) useful to debug instruction
  sequence.  COMPILE_ERROR is usually SyntaxError, or fatal error
  if compile_debug is enabled,

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-22 06:01:38 +00:00
nobu 86dc8c81ce compile.c: dump iseq at adjust bug
* compile.c (fix_sp_depth): dump instructions at adjust bug too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-21 22:45:13 +00:00
nobu 8c5e7c59ff compile.c: restore stack at return
* compile.c (iseq_compile_each0): restore the stack depth after
  return to the previous depth, to fix the stack depth at
  returning from rescue iseq.  [ruby-core:82108] [Bug #13755]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-20 02:43:45 +00:00
nobu d2dd18ed16 compile.c: simplify defined_expr0
* compile.c (defined_expr0): exapnd defined_expr macro.

* compile.c (defined_expr0): reduce duplicate code.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-10 11:42:07 +00:00
nobu 703675da95 compile.c: dump iseq
* compile.c (append_compile_error): raise a fatal error when
  compile_debug is enabled.

* compile.c (COMPILE_ERROR): dump the disassembled instruction
  instruction sequence always.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-30 02:09:42 +00:00
nobu 0a11abfc7e compile.c: disallow next in once
* compile.c (iseq_compile_each0): turned dregx context in "once"
  into "guarded" type from "block" type, to disallow `next`,
  `break`, `redo` as well as outside "once".
  [ruby-core:81805] [Bug #13690]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-29 04:01:30 +00:00
nobu 5cfda37971 fix return in toplevel ensure
* compile.c (iseq_compile_each0): adjust stack after return in
  toplevel ensure, when the value is used.
  [ruby-core:81777] [Bug #13682]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-27 14:09:08 +00:00
nobu 1474acff3c fix return in toplevel rescue/ensure
* 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-27 06:57:34 +00:00
nobu 72c46d217a compile.c: fix debug print
* compile.c (iseq_compile_each0): debugs/ruby_debug_printf do not
  support PRIsVALUE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-26 00:59:24 +00:00
nobu 04b3328cd9 compile.c: fix_sp_depth
* compile.c (fix_sp_depth): separate fix-up of sp depth from code
  generation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-25 08:55:23 +00:00
nobu 8f1c93f409 compile.c: toplevel return in argument
* compile.c (iseq_compile_each0): adjust the stack before return
  in an evstr/argument (reported by Balazs <balazs@kutilovi.cz>)
  to fix stack consistency error.  [ruby-core:81761] [Bug #13678]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-25 05:10:48 +00:00
nobu af4ba5c12a parse.y: should not warn op method call
* parse.y (void_expr_gen): should warn operator expression style
  calls only, but not method style calls.  [Fix GH-1660]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23 11:56:48 +00:00
ko1 1d248f0429 use NULL instead of 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23 05:55:12 +00:00