aboutsummaryrefslogtreecommitdiffstats
path: root/iseq.c
Commit message (Collapse)AuthorAgeFilesLines
* variable succ_index_table never actually usedshyouhei2018-01-191-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use already casted variablekazu2018-01-181-1/+1
| | | | | | r61883 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: dump as non-trace instructionsnobu2018-01-171-3/+3
| | | | | | | | | * iseq.c (iseq_data_to_ary): when OPT_CALL_THREADED_CODE is used, iseq_encoded is overwritten by instructions with trace and the original_iseq is not stored. convert these instructions to the original instructions as external representation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: flatten TS_NUM operand conditionsnobu2018-01-171-11/+14
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* exclude flexible array size with old compilersnobu2018-01-141-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.h (struct iseq_catch_table_entry, iseq_compile_data_storage): Use ↵mame2018-01-131-2/+2
| | | | | | FLEX_ARY_LEN git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (FLEX_ARY_LEN): Add a macro to define a flexible arraymame2018-01-131-9/+1
| | | | | | Also, use it in iseq.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* flexible array member is a C99ismshyouhei2018-01-131-1/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: child iseq encodingnobu2018-01-111-2/+2
| | | | | | * iseq.c (iseq_inspect): preserve the encoding of child iseqs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: Succinct bitvector now supports 32-bit machinemame2018-01-101-4/+4
| | | | | | Second try of succinct bitvector. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: Add explicit casts from long to int (to pass compile on clang)mame2018-01-091-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: Add a succinct bitvector implementation for insn_info_tablemame2018-01-091-1/+213
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c (iseq_data_to_ary): Avoid direct use of insns_info.positionsmame2018-01-091-20/+20
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Rename code_range to code_locationmame2018-01-091-33/+33
| | | | | | | | | | | Because the name "code_range" is ambiguous with encoding's. Abbreviations ("crange", and "cr") are also renamed to "loc". The traditional "code_location" (a pair of lineno and column) is renamed to "code_position". Abbreviations are also renamed (first_loc to beg_pos, and last_loc to end_pos). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use `getblockparamproxy` to pass blocks.ko12018-01-081-1/+0
| | | | | | | | | | | | | * compile.c (setup_args): use `getblockparamproxy` (`rb_block_param_proxy`) to represent a block parameter passing. * vm_args.c (vm_caller_setup_arg_block): check `rb_block_param_proxy` instead of using `VM_CALL_ARGS_BLOCKARG_BLOCKPARAM` call flag. * vm_core.h (VM_CALL_ARGS_BLOCKARG_BLOCKPARAM): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Make consistent with the terms about code ranges and locationsmame2018-01-081-1/+1
| | | | | | | | | | | | | "loc" was ambiguous; it might refer both a location and a code range. This change uses "loc" for a location, and "crange" or "cr" for a code range. A location (abbr. loc) is a point in a program and consists of line number and column number. A code range (abbr. crange and cr) is a range within a program and consists of a pair of locations which is the first and the last. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.h: remove NODE_PRELUDEmame2018-01-051-2/+5
| | | | | | | | | | | NODE_PRELUDE contains a `BEGIN` node, a main node, and compile_option. This node is assumed that it must be located immediately under the root NODE_SCOPE, but this strange assumption is not so good, IMO. This change removes the assumtion; it integrates the former two nodes by block_append, and moves compile_option into rb_ast_body_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* make rb_iseq_new* accept rb_ast_body_t instead of NODE*mame2018-01-051-9/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.h: define rb_ast_body_t and restructure rb_ast_tmame2018-01-051-5/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Refactor ISEQ_TYPE_DEFINED_GUARD outmame2018-01-051-6/+6
| | | | | | | | | This commit removes ISEQ_TYPE_DEFINED_GUARD because it is no longer needed. And this introduces ISEQ_TYPE_PLAIN which means that the iseq does nothing special but just wrap an expression. Currently, this is used for once execution: `/foo#{ bar }baz/o`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: Refactor out rb_iseq_new_ifunc from rb_iseq_new_with_optmame2018-01-041-3/+18
| | | | | | It is too error-prone to pass IMEMO_IFUNC object as NODE*. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c (rb_iseq_new_with_opt): handle the case where node is imemo_funcmame2018-01-041-1/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* insns_info.inc.tmpl: share large tablesenobu2018-01-041-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_core.h: make the algorithm of get_insn_info selectablemame2018-01-011-7/+25
| | | | | | | | Currently, VM_INSN_INFO_TABLE_IMPL == 0 means linear search, and VM_INSN_INFO_TABLE_IMPL == 1 means binary search. I plan to add succinct bitvector algorithm later. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.h: Extract position array from iseq_insn_info_entrymame2018-01-011-10/+13
| | | | | | | | | | This makes TracePoint a bit fast by reducing cache misses of `get_insn_info_binary_search`. Also, I plan to use succinct bitvector algorithm for `get_insn_info` instead of binary search. This change will make it easy. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: fix build error when VM_CHECK_MODE is enabledmame2018-01-011-1/+1
| | | | | | Follow up of r61534. Sorry. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_core.h: refactoring of insns_infomame2018-01-011-9/+9
| | | | | | | This factors rb_iseq_constant_body#insns_info and #insns_info_size to struct iseq_insn_info. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Disasm output contains code range.ko12017-12-251-2/+6
| | | | | | | | * iseq.c (iseq_inspect): show also code range information. Note that `iseq_inspect` is used only for header of disasm. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove "trace_instruction" compile option.ko12017-12-241-4/+0
| | | | | | | | | * iseq.h (rb_compile_option_struct): trace instruction is removed so that remove the trace_instruction compile option. Don't show warning (just ignore) for Ruby 2.5. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RubyVM::InstructionSequence#trace_points.ko12017-12-231-0/+38
| | | | | | | | | | * iseq.c (iseqw_trace_points): add `RubyVM::InstructionSequence#trace_points` method for tools which want to manipulate ISeq (and traces). * test/ruby/test_iseq.rb: add a test for this method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RubyVM::InstructionSequence#each_child.ko12017-12-231-0/+65
| | | | | | | | | | * iseq.c (iseqw_each_child): add RubyVM::InstructionSequence#each_child method for tools which want to manipulate ISeq. * test/ruby/test_iseq.rb: add a test for this method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: show first_lineno on iseq inspectk0kubun2017-12-231-3/+6
| | | | | | | | | | My motivation was to improve the output of `ruby --dump=insns xxx.rb`. When one file has many iseqs, it's hard to find the one I want to read. So I wanted `iseq_disasm` to show first_lineno. I unified the behavior of `iseqw_disasm` for consistency. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: Remove unused macro in r61395kazu2017-12-231-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: local variable namesnobu2017-12-231-8/+2
| | | | | | | | * iseq.c (rb_insn_operand_intern): simplified the condition for local variable names, assume TS_LINDEX and TS_NUM combinations are only for local variables. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c (rb_insn_operand_intern): needs parenthesiesnobu2017-12-221-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: defined insn operandnobu2017-12-221-13/+35
| | | | | | | * iseq.c (rb_insn_operand_intern): improve operands of defined instruction. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c (rb_iseq_code_range): Remove needless `;`yui-knk2017-12-211-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add experimental API.ko12017-12-211-0/+9
| | | | | | | * iseq.c (rb_iseq_code_range): added to access iseq's code range. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: block param namenobu2017-12-201-1/+2
| | | | | | | * iseq.c (rb_insn_operand_intern): show local variable name at getblockparam/setblockparam too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c (get_insn_info): use binary search instead of linear searchmame2017-12-201-5/+66
| | | | | | | | | This change introduces get_insn_info_binary_search, which is (should be) equivalent to the old get_insn_info. The old get_insn_info is renamed to get_insn_info_linear_search. When VM_CHECK_MODE > 0, the equivalence is validated at finish_iseq_build. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: add a RUBY_EVENT_COVERAGE_LINE event for line coveragemame2017-12-201-12/+0
| | | | | | | | | | | | | | | | | | | 2.5's line coverage measurement was about two times slower than 2.4 because of two reasons; (1) vm_trace uses rb_iseq_event_flags (which takes O(n) currently where n is the length of iseq) to get an event type, and (2) RUBY_EVENT_LINE uses setjmp to call an event hook. This change adds a special event for line coverage, RUBY_EVENT_COVERAGE_LINE, and adds `tracecoverage` instructions where the event occurs in iseq. `tracecoverage` instruction calls an event hook without vm_trace. And, RUBY_EVENT_COVERAGE_LINE is an internal event which does not use setjmp. This change also cancells lineno change due to the deletion of trace instructions [Feature #14104]. So fixes [Bug #14191]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c (finish_iseq_build): fix coverage leakage [Bug #14191]mame2017-12-181-0/+12
| | | | | | | | | | Before this change, coverage.so had failed to measure some multiple-line code fragments. This is because removing trace instructions (#14104) changed TracePoint's lineno (new lineno), and coverage counter array was based on old lineno. This change initializes coverage counter array based on new lineno. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: dump type of branchiftype on disasmk0kubun2017-12-131-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes easier to debug scripts related to r59950. * before $ ./ruby --dump=insns -e '"#{a}"' == disasm: #<ISeq:<main>@-e>============================================ 0000 putobject "" ( 1)[Li] 0002 putself 0003 opt_send_without_block <callinfo!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0006 dup 0007 branchiftype 5, 15 0010 dup 0011 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache> 0014 tostring 0015 concatstrings 2 0017 leave * after $ ./ruby --dump=insns -e '"#{a}"' == disasm: #<ISeq:<main>@-e>============================================ 0000 putobject "" ( 1)[Li] 0002 putself 0003 opt_send_without_block <callinfo!mid:a, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache> 0006 dup 0007 branchiftype T_STRING, 15 0010 dup 0011 opt_send_without_block <callinfo!mid:to_s, argc:0, FCALL|ARGS_SIMPLE>, <callcache> 0014 tostring 0015 concatstrings 2 0017 leave git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* do not disable `trace_` prefix insns.ko12017-12-111-2/+2
| | | | | | | | | | | | | | | | * vm.c: introduce `ruby_vm_event_enabled_flags` which represents which event flags are enabled before. * vm_trace.c: do not turn off `trace_` prefix instructions because turn on overhead is a matter if a program repeats turn on and turn off frequently. * iseq.c (finish_iseq_build): respect `ruby_vm_event_enabled_flags`. * vm_insnhelper.c (vm_trace): check `ruby_vm_event_flags` and disable lazy trace-off technique (do not disable traces). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread.c (update_line_coverage): Use RUBY_EVENT_LINEmame2017-12-061-1/+0
| | | | | | | | This change makes coverage use the general event type RUBY_EVENT_LINE instead of a special event type RUBY_EVENT_COVERAGE. Just a refactoring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c (iseq_load, iseq_data_to_ary): Fix a type error (for clang)mame2017-12-051-8/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Hide ISeq#loadmame2017-12-051-1/+1
| | | | | | I disclosed it incorrectly at r61025. Sorry. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_core.h (rb_iseq_locatoin_t): add a field `code_range`mame2017-12-051-7/+32
| | | | | | | This change makes each ISeq keep NODE's code range. This information is needed for method coverage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Relax `rb_bug()` condition.ko12017-11-271-3/+4
| | | | | | | | | | * iseq.c (rb_iseq_trace_set): simply return immediately if ISeq::compile_data is available. Not sure why this state is allowed, but exception during compile (or `ISeq::load`) can make such states. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* check invariant.ko12017-11-211-0/+3
| | | | | | | | * iseq.c (rb_iseq_trace_set): at this point ISEQ_USE_COMPILE_DATA should not be set. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e