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

457 Коммитов

Автор SHA1 Сообщение Дата
mame ab2c205c00 iseq.c: Add explicit casts from long to int (to pass compile on clang)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 14:11:39 +00:00
mame 83262f2489 iseq.c: Add a succinct bitvector implementation for insn_info_table
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 14:05:23 +00:00
mame 6d2de83bf0 iseq.c (iseq_data_to_ary): Avoid direct use of insns_info.positions
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 14:05:21 +00:00
mame 4928900814 Rename code_range to code_location
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
2018-01-09 08:45:35 +00:00
ko1 8a83cd100b use `getblockparamproxy` to pass blocks.
* 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
2018-01-08 16:06:33 +00:00
mame 52057336b7 parse.y: Make consistent with the terms about code ranges and locations
"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
2018-01-08 12:56:58 +00:00
mame 38c62063c0 node.h: remove NODE_PRELUDE
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
2018-01-05 08:59:23 +00:00
mame 92b81dc597 make rb_iseq_new* accept rb_ast_body_t instead of NODE*
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 08:59:22 +00:00
mame 503b858cef node.h: define rb_ast_body_t and restructure rb_ast_t
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 08:59:20 +00:00
mame e1428e5c92 Refactor ISEQ_TYPE_DEFINED_GUARD out
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
2018-01-05 00:49:41 +00:00
mame e743a35314 iseq.c: Refactor out rb_iseq_new_ifunc from rb_iseq_new_with_opt
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
2018-01-04 07:07:49 +00:00
mame 1e4be7a852 iseq.c (rb_iseq_new_with_opt): handle the case where node is imemo_func
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-04 04:44:16 +00:00
nobu 9edca48cff insns_info.inc.tmpl: share large tablese
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-04 01:46:01 +00:00
mame 691b05e83c vm_core.h: make the algorithm of get_insn_info selectable
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
2018-01-01 13:18:55 +00:00
mame 295838e6eb iseq.h: Extract position array from iseq_insn_info_entry
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
2018-01-01 12:51:21 +00:00
mame e1fce44ca6 iseq.c: fix build error when VM_CHECK_MODE is enabled
Follow up of r61534.  Sorry.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-01 09:30:06 +00:00
mame fd950df795 vm_core.h: refactoring of insns_info
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
2018-01-01 09:16:27 +00:00
ko1 d7c6776f7c Disasm output contains code range.
* 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
2017-12-25 04:40:42 +00:00
ko1 cbac40b3e5 Remove "trace_instruction" compile option.
* 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
2017-12-24 17:07:53 +00:00
ko1 3044138bd7 RubyVM::InstructionSequence#trace_points.
* 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
2017-12-23 14:46:59 +00:00
ko1 eb8c2773cb RubyVM::InstructionSequence#each_child.
* 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
2017-12-23 12:48:24 +00:00
k0kubun 1942e92547 iseq.c: show first_lineno on iseq inspect
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
2017-12-23 09:10:34 +00:00
kazu a747834a69 iseq.c: Remove unused macro in r61395
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-23 01:53:48 +00:00
nobu 2a723132e9 iseq.c: local variable names
* 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
2017-12-23 00:55:29 +00:00
nobu 6e0074d0ff iseq.c (rb_insn_operand_intern): needs parenthesies
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 01:12:02 +00:00
nobu b4dc51ce10 iseq.c: defined insn operand
* 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
2017-12-22 00:29:38 +00:00
yui-knk 69ae0f0f42 iseq.c (rb_iseq_code_range): Remove needless `;`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-21 07:09:03 +00:00
ko1 e9a184ed63 add experimental API.
* 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
2017-12-21 06:40:28 +00:00
nobu e105ee2bed iseq.c: block param name
* 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
2017-12-20 14:10:06 +00:00
mame be3439026a iseq.c (get_insn_info): use binary search instead of linear search
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
2017-12-20 07:38:24 +00:00
mame c08e8886ba compile.c: add a RUBY_EVENT_COVERAGE_LINE event for line coverage
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
2017-12-20 04:24:14 +00:00
mame 2e24a66b88 iseq.c (finish_iseq_build): fix coverage leakage [Bug #14191]
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
2017-12-18 02:44:36 +00:00
k0kubun f5090e2f5c iseq.c: dump type of branchiftype on disasm
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
2017-12-13 16:07:52 +00:00
ko1 975e3a19a7 do not disable `trace_` prefix insns.
* 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
2017-12-11 19:17:25 +00:00
mame ec02c4861b thread.c (update_line_coverage): Use RUBY_EVENT_LINE
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
2017-12-06 06:39:05 +00:00
mame e5614fbcb0 iseq.c (iseq_load, iseq_data_to_ary): Fix a type error (for clang)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05 09:45:03 +00:00
mame f9c614c668 Hide ISeq#load
I disclosed it incorrectly at r61025.  Sorry.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05 08:58:57 +00:00
mame a5e02f249d vm_core.h (rb_iseq_locatoin_t): add a field `code_range`
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
2017-12-05 08:56:50 +00:00
ko1 9f1c00ce65 Relax `rb_bug()` condition.
* 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
2017-11-27 00:43:23 +00:00
ko1 eb3e32480d check invariant.
* 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
2017-11-21 02:57:01 +00:00
ko1 26451ab3ba introduce `trace_events' info for iseq.
* vm_core.h (rb_iseq_t::aux): add `trace_events` which represents
  which events are enabled on this iseq. With this information,
  we can skip useless trace-on changes for ISeqs.

* vm_trace.c (RUBY_EVENTS_TRACE_BY_ISEQ): moved to iseq.h and rename it
  with ISEQ_TRACE_EVENTS.

* iseq.h: introduce ISEQ_USE_COMPILE_DATA iseq (imemo) flag to represent
  COMPILE_DATA is available. In other words, iseq->aux.trace_events is not
  available when this flag is set.
  * ISEQ_COMPILE_DATA() is changed from a macro.
  * ISEQ_COMPILE_DATA_ALLOC() is added.
  * ISEQ_COMPILE_DATA_CLEAR() is added.

* iseq.c: use them.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-18 09:39:41 +00:00
ko1 d2bb08ecf0 remove a wrong assertion.
* iseq.c (rb_iseq_trace_set): remove a wrong assertion.
  This assertion checked `insn` is `trace_` prefix instruction
  but threaded code `insn` is original code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17 07:29:07 +00:00
ko1 1a96057626 remove `trace_` prefix insns lazily.
* vm_trace.c (update_global_event_hook): set only when tracing is added.
  If tracing was off (event flags are decreased), then ignore them.
  Next `trace_` prefix instruction will trace off itself (lazy tracing off).

* vm_insnhelper.c (vm_trace): trace-off for when trace is not needed.

* iseq.c (rb_iseq_trace_set): fix trace-off process (it was never off tracing).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-17 06:24:55 +00:00
kazu 06ba86c933 Remove redundant last newline [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-15 13:53:15 +00:00
ko1 665ba24b44 remove `trace` instruction. [Feature #14104]
* tool/instruction.rb: create `trace_` prefix instructions.

* compile.c (ADD_TRACE): do not add `trace` instructions but add
  TRACE link elements. TRACE elements will be unified with a next
  instruction as instruction information.

* vm_trace.c (update_global_event_hook): modify all ISeqs when
  hooks are enabled.

* iseq.c (rb_iseq_trace_set): added to toggle `trace_` instructions.

* vm_insnhelper.c (vm_trace): added.
  This function is a body of `trace_` prefix instructions.

* vm_insnhelper.h (JUMP): save PC to a control frame.

* insns.def (trace): removed.

* vm_exec.h (INSN_ENTRY_SIG): add debug output (disabled).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-14 12:58:36 +00:00
nobu 54b8b8e4f7 iseq.c: disasm only once for each iseq
* iseq.c (rb_iseq_disasm): do not dump repeatedly same iseq which
  has been dumped by catch tables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-10 08:26:44 +00:00
ko1 61e4c99962 refactoring about source line.
* iseq.c (find_line_no): renamed to rb_iseq_line_no().

* vm_backtrace.c (calc_lineno): add a comment why we need to use "pos-1".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-10 05:26:52 +00:00
nobu 324b6d306d iseq.c: operand lvar
* iseq.c (rb_insn_operand_intern): show local variable operand
  name in unified instructions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-09 23:08:01 +00:00
ko1 1c5ae5a163 insn_info/insns_info
* iseq.h (iseq_line_info_entry): rename to iseq_insn_info_entry.

* vm_core.h (rb_iseq_constant_body): rename field name line_info_table
  to insns_info and also from line_info_size to insns_info_size.

* compile.c (INSN): add struct insn_info to contain per insn information.

* compile.c (add_insn_info): added to add new insn_info entry.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-09 06:57:24 +00:00
ko1 4049ffb58e use GET_EC() directly
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-07 05:08:09 +00:00
ko1 85fcaf025d * node.h (ast_t): renamed to `rb_ast_t`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29 15:51:23 +00:00
ktsj a184500be2 iseq.c: remove obsolete comment
You can see ARGS_SIMPLE flag as follows:

 $ ruby --dump=insns -e itself

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28 15:37:00 +00:00
ktsj e6f133b66a iseq.c: fix a typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28 09:22:45 +00:00
ktsj 0b8842ca8a iseq.c: show all call flags
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28 09:22:44 +00:00
mame e35fe8d11b Revert "Revert "Manage AST NODEs out of GC""
This re-introduces r60485.
This reverts commit 5a176b75b1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 16:44:57 +00:00
mame 5a176b75b1 Revert "Manage AST NODEs out of GC"
This reverts commit 620ba74778.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 16:02:34 +00:00
mame 620ba74778 Manage AST NODEs out of GC
NODEs in AST are no longer objects managed by GC.  This change will
remove the restriction imposed by the GC.  For example, a NODE can use
more than five words (this is my primary purpose; we want to store the
position data for each NODE, for coverage library), or even a NODE can
have variable length (some kinds of NODEs have unused fields).
To do this, however, we need more work, since Ripper still uses T_NODE
objects managed by the GC.

The life time of NODEs is more obvious than other kinds of objects; they
are created at parsing, and they become disused immediately after
compilation.  This change releases all NODEs by a few `xfree`s after
compilation, so performance will be improved a bit.  In extreme example,
`eval("x=1;" * 10000000)` runs much faster (40 sec. -> 7.8 sec. on my
machine).

The most important part of this change is `ast_t` struct, which has
three contents: (1) NODE buffer (malloc'ed memory), (2) a reference to
the root NODE, and (3) an array that contains objects that must be
marked during parsing (such as literal objects).  Some functions that
had received `NODE*` arguments, must now receive `ast_t*`.

* node.c, node.h: defines `ast_t` struct and related operations.
* gc.c, internal.h: defines `imemo_ast`.
* parse.y: makes `parser_params` struct have a reference to `ast_t`.
  Instead of `rb_node_newnode`, use `rb_ast_newnode` to create a NODE.
* iseq.c, load.c, ruby.c, template/prelude.c.tmpl: modifies some
  functions to handle `ast_t*` instead of `NODE*`.
* test/ruby/test_gc.rb: ad-hoc fix for a failed test.  The test assumes
  GC eden is increased at startup by NODE object creation.  However,
  this change now create no NODE object, so GC eden is not necessarily
  increased.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 15:59:02 +00:00
nobu fd14454688 compile.c, iseq.c: consitfied NODE pointers
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 12:00:38 +00:00
ko1 f56288d7a8 replace `GET_THREAD()->ec` to `GET_EC()`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26 14:44:09 +00:00
ko1 837fd5e494 Use rb_execution_context_t instead of rb_thread_t
to represent execution context [Feature #14038]

* vm_core.h (rb_thread_t): rb_thread_t::ec is now a pointer.
  There are many code using `th` to represent execution context
  (such as cfp, VM stack and so on). To access `ec`, they need to
  use `th->ec->...` (adding one indirection) so that we need to
  replace them by passing `ec` instead of `th`.

* vm_core.h (GET_EC()): introduced to access current ec. Also
  remove `ruby_current_thread` global variable.

* cont.c (rb_context_t): introduce rb_context_t::thread_ptr instead of
  rb_context_t::thread_value.

* cont.c (ec_set_vm_stack): added to update vm_stack explicitly.

* cont.c (ec_switch): added to switch ec explicitly.

* cont.c (rb_fiber_close): added to terminate fibers explicitly.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26 08:32:49 +00:00
nobu 6b818dd961 common conversion functions
* array.c (rb_to_array_type): make public to share common code
  internally.

* hash.c (rb_to_hash_type): make public to share common code
  internally.

* symbol.c (rb_to_symbol_type): make public to share common code
  internally.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-26 07:23:23 +00:00
yui-knk 29fa7a9f91 Remove a meaningless local variable assignment
* iseq.c (rb_iseq_disasm_insn): Remove a meaningless
  local variable assignment. `insn` is never changed
  in this function, so a result of `insn_op_types(insn)`
  is also never changed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-21 13:38:35 +00:00
ko1 8dd9c12c58 move fields to ec.
* vm_core.h (rb_thread.h): move errinfo and trace_arg to
  rb_execution_context_t.

* cont.c (fiber_switch, rb_cont_call): do not restore "trace_arg" here.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-28 14:27:49 +00:00
nobu a57d295e36 iseq.c: preserve encoding
* iseq.c (iseqw_inspect): preserve path encoding in the result.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-12 04:35:53 +00:00
ko1 478003f6df rename absolute_path to realpath internally and introduce pathobj.
* 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
2017-06-01 00:05:33 +00:00
watson1978 d0015e4ac6 Improve performance of implicit type conversion
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
2017-05-31 12:30:57 +00:00
nobu 14a730e91e immediate message mode of compile error
* compile.c (append_compile_error): set Qtrue for erred state with
  showing the message immediately.

* iseq.c (prepare_iseq_build): make immediate message mode if main
  or top level context, not to show the failed path twice in the
  first line.

* iseq.c (cleanup_iseq_build): raise default message exception if
  immediate message mode.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-12 07:41:35 +00:00
nobu a38b2f84f4 iseq.c: syntax error in compile_file
* iseq.c (iseqw_s_compile_file): deal with syntax error as well as
  compile, and should not abort when rescued.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-27 08:35:31 +00:00
nobu b15f76556f iseq.c: kwarg to compile
* iseq.c (iseqw_s_compile, iseqw_s_compile_file): allow keyword
  arguments as the options.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-27 06:23:36 +00:00
nobu 802e5677a4 iseq.c: file name encoding
* iseq.c (iseqw_s_compile): keep the encoding of file name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-27 05:34:41 +00:00
rhe 2f551849c4 Use PRIuSIZE format specifier for size_t values
Use PRIuSIZE instead of PRIdSIZE. This fixes the exception message shown
on too large xmalloc2. This commit also fixes other incorrect use of
PRIdSIZE in other functions; though most of them are debug print.

* gc.c (heap_extend_pages, get_envparam_size, ruby_malloc_size_overflow,
  gc_profile_dump_on): Use PRIuSIZE instead of PRIdSIZE as the passed
  value is size_t, not ssize_t.

* iseq.c (get_line_info, rb_iseq_disasm_insn): Ditto.

* sprintf.c (rb_str_format): Ditto.

* thread_win32.c (native_thread_create): Ditto.

* vm.c (get_param): Ditto.

* ext/objspace/objspace_dump.c (dump_append_string_content,
  dump_object): Ditto.

* ext/socket/raddrinfo.c (host_str, port_str): Ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-13 12:33:13 +00:00
nobu 36b9a37a80 iseq.c: undef allocator
* iseq.c (Init_ISeq): undefine allocator of InstructionSequence,
  to get rid of segfaults at method call on uninitialized object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-22 00:02:59 +00:00
ko1 03cad83593 * vm_core.h: introduce VM_FRAME_RUBYFRAME_P()
and VM_FRAME_CFRAME_P().
  Most of case, RUBY_VM_NORMAL_ISEQ_P() is no
  longer needed.

* vm_core.h: introduce rb_obj_is_iseq().

* cont.c, vm.c: VM_FRAME_MAGIC_DUMMY with
  VM_FRAME_FLAG_CFRAME.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-03 01:50:50 +00:00
nobu c463366dfd rb_funcallv
* *.c: rename rb_funcall2 to rb_funcallv, except for extensions
  which are/will be/may be gems.  [Fix GH-1406]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-29 11:57:14 +00:00
ko1 9f60791a04 * vm_core.h: revisit the structure of frame, block and env.
[Bug #12628]

  This patch introduce many changes.

  * Introduce concept of "Block Handler (BH)" to represent
    passed blocks.

  * move rb_control_frame_t::flag to ep[0] (as a special local
    variable). This flags represents not only frame type, but also
    env flags such as escaped.

  * rename `rb_block_t` to `struct rb_block`.

  * Make Proc, Binding and RubyVM::Env objects wb-protected.

  Check [Bug #12628] for more details.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-28 11:02:30 +00:00
ko1 d8c3672b01 * iseq.c (Init_ISeq): undef ISeq.translate and ISeq.load_iseq
to prevent calling super classes' methods.

  Without this patch, you can write workaround like:

    class << RubyVM::InstructionSequence
      def translate; end
      undef translate
    end

* test/ruby/test_iseq.rb: add a test.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-13 05:26:00 +00:00
naruse 3b4e68cfab * iseq.h (struct iseq_compile_data): use struct rb_id_table
instead of st_table.

* iseq.c (prepare_iseq_build): don't allocate ivar_cache_table
  until it has at least one element.

* iseq.c (compile_data_free): free ivar_cache_table only if it
  is allocated.

* compile.c (get_ivar_ic_value): allocate if the table is not
  allocated yet.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-14 18:43:11 +00:00
tarui 44916ec448 * compile.c (iseq_compile_each): share InlineCache during same
instance variable accesses. Reducing memory consumption,
	  rasing cache hit rate and rasing branch prediction hit rate
	  are expected. A part of [Bug #12274].

	* iseq.h (struct iseq_compile_data): introduce instance
	  variable IC table for sharing.

	* iseq.c (prepare_iseq_build, compile_data_free):
	  construct/destruct above table.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-05-11 12:50:38 +00:00
nobu 7504be10ef remove rb_thread_t::base_block
* error.c (rb_compile_err_append): rb_thread_t::base_block is no
  longer used.
* iseq.c (rb_iseq_compile_with_option): ditto, no protection is
  needed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-28 21:40:55 +00:00
nobu d7935475fc remove rb_thread_t::parse_in_eval
* parse.y (struct parser_params): move parse_in_eval flag from
  rb_thread_t.
* parse.y (rb_parser_set_context): set parsing context, not only
  mild error flag.
* iseq.c (rb_iseq_compile_with_option): the parser now refers no
  thread local states to be restored.
* vm_eval.c (eval_string_with_cref): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-28 21:39:24 +00:00
nobu 3176a634ca suppress warning
* iseq.c (rb_iseq_compile_with_option): suppress
  maybe-uninitialized warning by gcc 4.8.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21 13:53:25 +00:00
nobu bc343b851d SyntaxError message at iseq compile
* iseq.c (rb_iseq_compile_with_option): make the parser in mild
  error.
* load.c (rb_load_internal0): ditto.
* parse.y (yycompile0): return the error message within the error
  to be raised.  [Feature #11951]
* parse.y (parser_compile_error): accumulate error messages in the
  error_buffer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-19 05:46:20 +00:00
nobu cf09c0c351 iseq.h: coverage_enabled flag
* iseq.c (prepare_iseq_build): enable coverage by coverage_enabled
  option, not by parse_in_eval flag in the thread context.
* iseq.h (rb_compile_option_struct): add coverage_enabled flag.
* parse.y (yycompile0): set coverage_enabled flag if coverage
  array is made.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-10 08:34:18 +00:00
nobu 9871d88ee4 iseq.c: set coverage at once
* iseq.c (prepare_iseq_build): set coverage at once, not
  repeatedly resetting.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-10 05:32:49 +00:00
normal 1282a4a895 fstring early for internal iseq
All of the strings created here eventually get converted to
fstrings when they are frozen into the iseq.  Prepare the
fstring early so we may reduce a one or two objects.

This is a very minor change, mainly for the '<main>' dedupe.

* compile.c (caller_location): use rb_fstring_cstr for "<compiled>"
  (it is converted to fstring anyways inside rb_iseq_new_with_opt)
* iseq.c (iseqw_s_compile): ditto
* iseq.c (rb_iseq_new_main): use rb_fstring_cstr for "<main>"
* vm.c (Init_VM): ditto, share with with above
* iseq.c (iseqw_s_compile_file): rb_fstring before rb_io_t->pathv
  share "<main>" with above
* vm.c (rb_binding_add_dynavars): fstring "<temp>" immediately

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-26 06:23:47 +00:00
nobu 22121544e1 iseq.c: mark parent iseq
* iseq.c (rb_iseq_mark): mark parent iseq to prevent dynamically
  generated iseq by eval from GC.  [ruby-core:72620] [Bug #11928]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-13 07:56:51 +00:00
nobu 1b39a6e539 iseq.c: mark parents of wrapped iseq
* iseq.c (iseqw_mark): as wrapped iseq is isolated from the call
  stack, it needs to take care of its parent and ancestors, so
  that they do not become orphans.  [ruby-core:72620] [Bug #11928]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-12 15:17:19 +00:00
nobu 92f33ef216 iseq.c: volatile only on gcc4.8
* iseq.c (rb_iseq_compile_with_option): no volatile on gcc other
  than 4.8.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-08 10:52:24 +00:00
nobu 0455a25541 iseq.c: make local variables volatile
* iseq.c (rb_iseq_compile_with_option): prepare arguments outside
  EXEC_TAG, and make local variables volatile not to be clobbered
  by longjmp.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-08 07:47:49 +00:00
shugo 115163421a * iseq.c (rb_iseq_compile_with_option): move variable initialization
code to avoid maybe-uninitialized warnings by gcc 4.8.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-08 00:38:40 +00:00
nobu f84ba30af5 iseq.c: suppress warnings
* iseq.c (rb_iseq_compile_with_option): suppress "clobbered"
  warnings by old gcc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-28 06:42:18 +00:00
nobu 89b3281668 iseq.c: narrow down protected region
* iseq.c (rb_iseq_compile_with_option): narrow down protected
  region, and check/convert/prepare arguments before setting
  base_block which needs to roll back.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-24 14:15:14 +00:00
hsbt 52cd994814 * enum.c: fix a typo in documentation.
[ci skip][fix GH-1140] Patch by @jutaz
* io.c: ditto.
* iseq.c: ditto.
* numeric.c: ditto.
* process.c: ditto.
* string.c: ditto.
* vm_trace.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-14 02:52:14 +00:00
nobu a2fcdb4fbe iseq.c: use rb_check_funcall
* iseq.c (rb_iseq_load_iseq): use rb_check_funcall instead of
  repeating method search.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-12 07:07:42 +00:00
ko1 4b8da4b9c8 * iseq.c: rename methods
RubyVM::InstructionSequence#to_binary_format -> #to_binary
  RubyVM::InstructionSequence.from_binary_format -> .load_from_binary
  RubyVM::InstructionSequence.from_binary_format_extra_data ->
                             .load_from_binary_extra_data

* iseq.c: fix document of iseq.to_binary.
  [Fix GH-1134]

* sample/iseq_loader.rb: catch up this change.

* test/lib/iseq_loader_checker.rb: ditto.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09 15:10:57 +00:00
ko1 eef8beb695 add documentation for RubyVM::InstructionSequence#to_binary_format and RubyVM::InstructionSequence.from_binary_format
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-09 02:41:14 +00:00
nobu bb4d72c51f make local symbols static
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 15:07:41 +00:00
ko1 23124ffbe8 * iseq.c (iseq_s_load): fix mysterious bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 14:05:44 +00:00
svn c49cb7fed4 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 13:59:15 +00:00
ko1 3dbb390180 * introduce new ISeq binary format serializer/de-serializer
and a pre-compilation/runtime loader sample.
  [Feature #11788]

* iseq.c: add new methods:
  * RubyVM::InstructionSequence#to_binary_format(extra_data = nil)
  * RubyVM::InstructionSequence.from_binary_format(binary)
  * RubyVM::InstructionSequence.from_binary_format_extra_data(binary)

* compile.c: implement body of this new feature.

* load.c (rb_load_internal0), iseq.c (rb_iseq_load_iseq):
  call RubyVM::InstructionSequence.load_iseq(fname) with
  loading script name if this method is defined.

  We can return any ISeq object as a result value.
  Otherwise loading will be continue as usual.

  This interface is not matured and is not extensible.
  So that we don't guarantee the future compatibility of this method.
  Basically, you should'nt use this method.

* iseq.h: move ISEQ_MAJOR/MINOR_VERSION (and some definitions)
  from iseq.c.

* encoding.c (rb_data_is_encoding), internal.h: added.

* vm_core.h: add several supports for lazy load.
  * add USE_LAZY_LOAD macro to specify enable or disable of
    this feature.
  * add several fields to rb_iseq_t.
  * introduce new macro rb_iseq_check().

* insns.def: some check for lazy loading feature.

* vm_insnhelper.c: ditto.

* proc.c: ditto.

* vm.c: ditto.

* test/lib/iseq_loader_checker.rb: enabled iff suitable
  environment variables are provided.

* test/runner.rb: enable lib/iseq_loader_checker.rb.

* sample/iseq_loader.rb: add sample compiler and loader.

    $ ruby sample/iseq_loader.rb [dir]

  will compile all ruby scripts in [dir].
  With default setting, this compile creates *.rb.yarb files
  in same directory of target .rb scripts.

    $ ruby -r sample/iseq_loader.rb [app]

  will run with enable to load compiled binary data.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08 13:58:50 +00:00