aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
Commit message (Collapse)AuthorAgeFilesLines
* configure.in: assume stdarg.h existsKazuki Yamaguchi2017-09-091-1/+1
| | | | It is part of C89.
* Remove unneeded trace instruction for coveragemame2017-09-071-0/+5
| | | | | | | | | | | | | | 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
* Refactor the internal data format for coverage measurementmame2017-09-031-1/+2
| | | | | | | | | | | 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
* compile.c: fix loading pathobjnobu2017-09-011-1/+19
| | | | | | | * 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
* compile.c: ensure after toplevel returnnobu2017-09-011-2/+2
| | | | | | | * 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
* compile.c: compile_ifnobu2017-08-281-37/+44
| | | | | | * 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
* compile.c: compile_ensurenobu2017-08-271-50/+57
| | | | | | * 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
* compile.c: compile_resbodynobu2017-08-271-50/+57
| | | | | | * 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
* compile.c: compile_rescuenobu2017-08-271-28/+35
| | | | | | * 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
* compile.c: unreachable chunknobu2017-08-251-1/+3
| | | | | | | * 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
* compile.c: useless jump eliminationnobu2017-08-251-3/+20
| | | | | | | * 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
* compile.c: moved comments [ci skip]nobu2017-08-251-24/+24
| | | | | | | * 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
* compile.c: show failed instructionsnobu2017-08-241-2/+6
| | | | | | | * 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
* compile.c: free before adjust errornobu2017-08-241-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* insns.inc.tmpl: ensure info sizenobu2017-08-221-1/+1
| | | | | | | * 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
* compile.c: compile_retrynobu2017-08-151-14/+22
| | | | | | * 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
* compile.c: compile_redonobu2017-08-151-68/+76
| | | | | | * 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
* compile.c: compile_nextnobu2017-08-151-72/+79
| | | | | | * 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
* compile.c: compile_breaknobu2017-08-141-62/+70
| | | | | | * 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
* compile.c: compile_loopnobu2017-08-141-82/+92
| | | | | | * 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
* type is invariant inside this blocknobu2017-08-141-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* separate hash literal and keyword argumentsnobu2017-08-111-1/+1
| | | | | | | | | * 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
* compile.c: fix KW_SPLAT flag conditionnobu2017-08-101-2/+5
| | | | | | | | * 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
* splat keyword hashnobu2017-08-051-8/+13
| | | | | | | | | | * 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
* compile.c: replace adjuststacknobu2017-07-301-13/+17
| | | | | | | * 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
* compile.c: fix flip-flop valuenobu2017-07-291-1/+0
| | | | | | | | * 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
* compile.c: COMPILE_ERRORnobu2017-07-221-51/+70
| | | | | | | | | * 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
* compile.c: dump iseq at adjust bugnobu2017-07-211-0/+1
| | | | | | * 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
* compile.c: restore stack at returnnobu2017-07-201-0/+3
| | | | | | | | * 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
* compile.c: simplify defined_expr0nobu2017-07-101-18/+14
| | | | | | | | * 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
* compile.c: dump iseqnobu2017-06-301-11/+5
| | | | | | | | | | * 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
* compile.c: disallow next in oncenobu2017-06-291-1/+4
| | | | | | | | | * 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
* fix return in toplevel ensurenobu2017-06-271-3/+4
| | | | | | | | * 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
* fix return in toplevel rescue/ensurenobu2017-06-271-4/+12
| | | | | | | | | | | * 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
* compile.c: fix debug printnobu2017-06-261-2/+2
| | | | | | | * 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
* compile.c: fix_sp_depthnobu2017-06-251-39/+111
| | | | | | | * 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
* compile.c: toplevel return in argumentnobu2017-06-251-0/+1
| | | | | | | | * 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
* parse.y: should not warn op method callnobu2017-06-231-2/+4
| | | | | | | * 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
* use NULL instead of 0.ko12017-06-231-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: dump and error before allocationnobu2017-06-141-3/+4
| | | | | | | * compile.c (iseq_set_sequence): separate instruction dump and error, before allocation of sequence. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* simply call xfree().ko12017-06-141-2/+2
| | | | | | | | * compile.c (BADINSN_ERROR): mixing (void) and (int) will fail solaris compiler. [ruby-core:81668], [Bug #13658] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * compile.c (dump_disasm_list_with_cursor): replace withnobu2017-06-131-12/+8
| | | | | | dump_disasm_list_with_cursor_dest. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix to free unallocated memory.ko12017-06-131-4/+4
| | | | | | | | * compile.c (iseq_set_sequence): initialize with NULL for line_info_table and generated_iseq and check NULL at BADINSN_ERROR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: refine error messagenobu2017-06-131-7/+14
| | | | | | | * compile.c (insn_set_sc_state): dump the whole instructions and mark the destination when label state mismatch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: refine error messagesnobu2017-06-131-10/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* expand ruby_sourcefilenobu2017-06-111-3/+2
| | | | | | | * compile.c: expand ruby_sourcefile not to evaluate twice in RSTRING_PTR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* check break target correctly.ko12017-06-081-4/+7
| | | | | | | | | | | | | | | | | | | | | * compile.c (iseq_compile_each0): save target child_iseq in the catch-table for break. This iseq is not for continuation, but for search key at vm_throw_start(). * vm_insnhelper.c (vm_throw_start): check saved iseq first. * iseq.h: add comment for it. * test/ruby/test_iterator.rb (test_ljump): add a test for the issue: def call b; b.call; end call(Proc.new{break}){} #=> (1) should raise LocalJumpError call(Proc.new{break}) #=> (2) shoudd raies LocalJumpError, too. but (1) doesn't raise LocalJumpError. This issue is reported by Matz. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use NULL instead of 0.ko12017-06-081-10/+7
| | | | | | | | * compile.c: use NULL instead of 0 for ADD_CATCH_ENTRY() to specify don't pass iseq. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rename absolute_path to realpath internally and introduce pathobj.ko12017-06-011-20/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * vm_core.h: rename absolute_path to realpath because it is expected name. external APIs (#absolute_path methods) are remained. * vm_core.h: remove rb_iseq_location_struct::path and rb_iseq_location_struct::absolute_path and introduce pathobj. if given path equals to given absolute_path (and most of case it is true), pathobj is simply given path String. If it is not same, pathobj is Array and pathobj[0] is path and pathobj[1] is realpath. This size optimization reduce 8 bytes and sizeof(struct rb_iseq_constant_body) is 200 bytes -> 192 bytes on 64bit CPU. To support this change, the following functions are introduced: * pathobj_path() (defined in vm_core.h) * pathobj_realpath() (ditto) * rb_iseq_path() (decl. in vm_core.h) * rb_iseq_realpath() (ditto) * rb_iseq_pathobj_new() (ditto) * rb_iseq_pathobj_set() (ditto) * vm_core.h (rb_binding_t): use pathobj instead of path. If binding is given at eval methods, realpath (absolute_path) was caller's realpath. However, they should use binding's realpath. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Improve performance of implicit type conversionwatson19782017-05-311-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To convert the object implicitly, it has had two parts in convert_type() which are 1. lookink up the method's id 2. calling the method Seems that strncmp() and strcmp() in convert_type() are slightly heavy to look up the method's id for type conversion. This patch will add and use internal APIs (rb_convert_type_with_id, rb_check_convert_type_with_id) to call the method without looking up the method's id when convert the object. Array#flatten -> 19 % up Array#+ -> 3 % up [ruby-dev:50024] [Bug #13341] [Fix GH-1537] ### Before Array#flatten 104.119k (± 1.1%) i/s - 525.690k in 5.049517s Array#+ 1.993M (± 1.8%) i/s - 10.010M in 5.024258s ### After Array#flatten 124.005k (± 1.0%) i/s - 624.240k in 5.034477s Array#+ 2.058M (± 4.8%) i/s - 10.302M in 5.019328s ### Test Code require 'benchmark/ips' class Foo def to_ary [1,2,3] end end Benchmark.ips do |x| ary = [] 100.times { |i| ary << i } array = [ary] x.report "Array#flatten" do |i| i.times { array.flatten } end x.report "Array#+" do |i| obj = Foo.new i.times { array + obj } end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e