aboutsummaryrefslogtreecommitdiffstats
path: root/iseq.h
Commit message (Collapse)AuthorAgeFilesLines
* vm_args.c (rb_warn_check): Use iseq_unique_id instead of its pointerYusuke Endoh2019-12-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | (This is the second try of 036bc1da6c6c9b0fa9b7f5968d897a9554dd770e.) If iseq is GC'ed, the pointer of iseq may be reused, which may hide a deprecation warning of keyword argument change. http://ci.rvm.jp/results/trunk-test1@phosphorus-docker/2474221 ``` 1) Failure: TestKeywordArguments#test_explicit_super_kwsplat [/tmp/ruby/v2/src/trunk-test1/test/ruby/test_keyword.rb:549]: --- expected +++ actual @@ -1 +1 @@ -/The keyword argument is passed as the last hash parameter.* for `m'/m +"" ``` This change ad-hocly adds iseq_unique_id for each iseq, and use it instead of iseq pointer. This covers the case where caller is GC'ed. Still, the case where callee is GC'ed, is not covered. But anyway, it is very rare that iseq is GC'ed. Even when it occurs, it just hides some warnings. It's no big deal.
* make functions static卜部昌平2019-11-191-2/+0
| | | | | | | These functions are used from within a compilation unit so we can make them static, for better binary size. This changeset reduces the size of generated ruby binary from 26,590,128 bytes to 26,584,472 bytes on my macihne.
* delete unused functions卜部昌平2019-11-141-2/+0
| | | | | | | | | | | | Looking at the list of symbols inside of libruby-static.a, I found hundreds of functions that are defined, but used from nowhere. There can be reasons for each of them (e.g. some functions are specific to some platform, some are useful when debugging, etc). However it seems the functions deleted here exist for no reason. This changeset reduces the size of ruby binary from 26,671,456 bytes to 26,592,864 bytes on my machine.
* Avoid top-level search for nested constant reference from nil in defined?Dylan Thacker-Smith2019-11-131-1/+2
| | | | | | | | | | | | Fixes [Bug #16332] Constant access was changed to no longer allow top-level constant access through `nil`, but `defined?` wasn't changed at the same time to stay consistent. Use a separate defined type to distinguish between a constant referenced from the current lexical scope and one referenced from another namespace.
* cstr -> bytesKoichi Sasada2019-11-081-1/+1
| | | | | rb_iseq_ibf_load_cstr() accepts bytes, but not NUL-terminate C string. To make it clear, rename it to _bytes.
* support builtin features with Ruby and C.Koichi Sasada2019-11-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support loading builtin features written in Ruby, which implement with C builtin functions. [Feature #16254] Several features: (1) Load .rb file at boottime with native binary. Now, prelude.rb is loaded at boottime. However, this file is contained into the interpreter as a text format and we need to compile it. This patch contains a feature to load from binary format. (2) __builtin_func() in Ruby call func() written in C. In Ruby file, we can write `__builtin_func()` like method call. However this is not a method call, but special syntax to call a function `func()` written in C. C functions should be defined in a file (same compile unit) which load this .rb file. Functions (`func` in above example) should be defined with (a) 1st parameter: rb_execution_context_t *ec (b) rest parameters (0 to 15). (c) VALUE return type. This is very similar requirements for functions used by rb_define_method(), however `rb_execution_context_t *ec` is new requirement. (3) automatic C code generation from .rb files. tool/mk_builtin_loader.rb creates a C code to load .rb files needed by miniruby and ruby command. This script is run by BASERUBY, so *.rb should be written in BASERUBY compatbile syntax. This script load a .rb file and find all of __builtin_ prefix method calls, and generate a part of C code to export functions. tool/mk_builtin_binary.rb creates a C code which contains binary compiled Ruby files needed by ruby command.
* avoid overflow in integer multiplication卜部昌平2019-10-091-2/+4
| | | | | | | This changeset basically replaces `ruby_xmalloc(x * y)` into `ruby_xmalloc2(x, y)`. Some convenient functions are also provided for instance `rb_xmalloc_mul_add(x, y, z)` which allocates x * y + z byes.
* Remove mark arrayAaron Patterson2019-09-261-1/+0
| | | | We don't use this array anymore so we can remove it
* Scan the ISEQ arena for markables and mark themAaron Patterson2019-09-261-0/+1
| | | | | This commit scans the ISEQ arena for objects that can be marked and marks them. This should make the mark array unnecessary.
* Introduce a secondary arenaAaron Patterson2019-09-261-2/+8
| | | | | | We'll scan the secondary arena during GC mark. So, we should only allocate "markable" instruction linked list nodes out of the secondary arena.
* Unify SUPPORT_JOKE and OPT_SUPPORT_JOKETakashi Kokubun2019-09-031-1/+1
| | | | | | | | | | for simplicity and consistency. Now SUPPORT_JOKE needs to be prefixed with OPT_ to make the config visible in `RubyVM::VmOptsH`, and the inconsistency was introduced. As it has never been available for override in configure (no #ifndef guard), it should be fine to rename the config.
* decouple compile.c usage of imemo_ifunc卜部昌平2019-08-271-1/+1
| | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from struct vm_ifunc, but in doing so we also have to decouple the usage of this struct in compile.c, which (I think) is an abuse of ANYARGS.
* Add `GC.compact` again.tenderlove2019-04-201-1/+1
| | | | | | 🙏 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting compaction for nowtenderlove2019-04-171-1/+1
| | | | | | For some reason symbols (or classes) are being overridden in trunk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-171-1/+1
| | | | | | | | | | | This commit adds the new method `GC.compact` and compacting GC support. Please see this issue for caveats: https://bugs.ruby-lang.org/issues/15626 [Feature #15626] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Share the exception local ID tablenobu2019-04-111-0/+2
| | | | | | | | [Fix GH-2115] From: Lourens Naudé <lourens@bearmetal.eu> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting all commits from r67479 to r67496 because of CI failureskazu2019-04-101-1/+1
| | | | | | | | Because hard to specify commits related to r67479 only. So please commit again. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-091-1/+1
| | | | | | | | | | | This commit adds the new method `GC.compact` and compacting GC support. Please see this issue for caveats: https://bugs.ruby-lang.org/issues/15626 [Feature #15626] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.h: Remove dead membersnobu2019-04-041-2/+0
| | | | | | | | | | | * iseq.h (struct iseq_compile_data): Remove the dead ensure_node and for_iseq members. [Fix GH-2108] From: Lourens Naudé <lourens@bearmetal.eu> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* `script_compiled` TracePoint event [Feature #15287]ko12018-12-061-0/+1
| | | | | | | | | | | | | | | | | * vm_trace.c: add `script_compiled` event. This event invoked after script compiling and before evaluating compiled script. Also the following methods are added: `TracePoint#compiled_instruction_sequence` method to get compiled `RubyVM::InstructionSequence` instance. `TracePoint#compiled_eval_script` method to get compiled script (String) by *eval methods (return nil if compiling by file). * vm_trace.c (tracepoint_attr_raised_exception): git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Return same ISeq object for one src.ko12018-12-061-1/+3
| | | | | | | | | | | | | | | | | | | | | * iseq.c: before this patch, RubyVM::InstructionSequence.of(src) (ISeq in short) returns different ISeq (wrapper) objects point to one ISeq internal object. This patch changes this behavior to cache created ISeq (wrapper) objects and return same ISeq object for an internal ISeq object. * iseq.h (ISEQ_EXECUTABLE_P): introduced to check executable ISeq objects. * iseq.h (ISEQ_COMPILE_DATA_ALLOC): reordr setting flag line to avoid ISEQ_USE_COMPILE_DATA but compiled_data == NULL case. * vm_core.h (rb_iseq_t): introduce `rb_iseq_t::wrapper` and `rb_iseq_t::aux::exec`. Move `rb_iseq_t::local_hooks` to `rb_iseq_t::aux::exec::local_hooks`. * test/ruby/test_iseq.rb: add ISeq.of() tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* `TracePoint#enable(target_line:)` is supported. [Feature #15289]ko12018-11-261-1/+1
| | | | | | | | | * vm_trace.c: `TracePoint#enable(target_line:)` is supported. This option enables a hook only at specified target_line. target_line should be combination with target and :line event. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Support targetting TracePoint [Feature #15289]ko12018-11-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * vm_trace.c (rb_tracepoint_enable_for_target): support targetting TracePoint. [Feature #15289] Tragetting TracePoint is only enabled on specified method, proc and so on, example: `tp.enable(target: code)`. `code` should be consisted of InstructionSeuqnece (iseq) (RubyVM::InstructionSeuqnece.of(code) should not return nil) If code is a tree of iseq, TracePoint is enabled on all of iseqs in a tree. Enabled tragetting TracePoints can not enabled again with and without target. * vm_core.h (rb_iseq_t): introduce `rb_iseq_t::local_hooks` to store local hooks. `rb_iseq_t::aux::trace_events` is renamed to `global_trace_events` to contrast with `local_hooks`. * vm_core.h (rb_hook_list_t): add `rb_hook_list_t::running` to represent how many Threads/Fibers are used this list. If this field is 0, nobody using this hooks and we can delete it. This is why we can remove code from cont.c. * vm_core.h (rb_vm_t): because of above change, we can eliminate `rb_vm_t::trace_running` field. Also renamed from `rb_vm_t::event_hooks` to `global_hooks`. * vm_core.h, vm.c (ruby_vm_event_enabled_global_flags): renamed from `ruby_vm_event_enabled_flags. * vm_core.h, vm.c (ruby_vm_event_local_num): added to count enabled targetting TracePoints. * vm_core.h, vm_trace.c (rb_exec_event_hooks): accepts hook list. * vm_core.h (rb_vm_global_hooks): added for convinience. * method.h (rb_method_bmethod_t): added to maintain Proc and `rb_hook_list_t` for bmethod (defined by define_method). * prelude.rb (TracePoint#enable): extracet a keyword parameter (because it is easy than writing in C). It calls `TracePoint#__enable` internal method written in C. * vm_insnhelper.c (vm_trace): check also iseq->local_hooks. * vm.c (invoke_bmethod): check def->body.bmethod.hooks. * vm.c (hook_before_rewind): check iseq->local_hooks and def->body.bmethod.hooks before rewind by exception. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-10-201-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove tracecoverage instructionsmame2018-10-201-1/+5
| | | | | | | The instructions were used only for branch coverage. Instead, it now uses a trace framework [Feature #14104]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove compile-time dependencies on ruby/version.hnobu2018-10-131-4/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: prefix rb_ to non-static iseq functionsk0kubun2018-09-131-5/+5
| | | | | | | | | | I assume we always prefix rb_ to non-static functions to avoid conflict. These functions are not exported and safe to be renamed. iseq.h: ditto compile.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* check trace flags at loading [Bug #14702]ko12018-08-231-0/+2
| | | | | | | | | | | | * iseq.c (iseq_init_trace): at ISeq loading time, we need to check `ruby_vm_event_enabled_flags` to turn on trace instructions. Seprate this checking code from `finish_iseq_build()` and make new function. `iseq_ibf_load()` calls this funcation after loading. * test/ruby/test_iseq.rb: add a test for this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: remove tracecoverage instruction for line coveragemame2018-08-221-1/+2
| | | | | | | 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
* prototizednobu2018-08-221-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* thread.c (rb_reset_coverages): remove coverage counters from all ISeqsmame2018-08-221-0/+2
| | | | | | | | | | | | | When coverage measurement is enabled, the compiler makes each iseq have a reference to the counter array of coverage. Even after coverage measurement is disabled, the reference is kept. And, if coverage measurement is restarted, a coverage hook will increase the counter. This is completely meaningless; it brings just overhead. To remove this meaninglessness, this change removes all the reference when coverage measuement is stopped. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* repack structsnobu2018-07-291-1/+1
| | | | | | | | | | | | | | | | Repack rb_thread_struct, rb_execution_context_struct, args_info and iseq_compile_data to save 1 word per struct. re_pattern_buffer remains unpacked due to the possible binary compatibility. [Fix GH-1907] Based on the patch From: Lourens Naudé <lourens@bearmetal.eu> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Make VM_INSN_INFO_TABLE_IMPL=1 workmame2018-06-131-0/+2
| | | | | | | rb_iseq_insns_info_decode_positions is used only when VM_INSN_INFO_TABLE_IMPL=2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.h (struct iseq_compile_data): remove cached_const fieldnormal2018-06-071-1/+0
| | | | | | | Nobody uses it, and "git log -p -Scached_const" shows it's ever been used in public history. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.h: fix argument ordernobu2018-05-091-1/+1
| | | | | | | * iseq.h (ISEQ_ORIGINAL_ISEQ_ALLOC): the order of ruby_xmalloc2 arguments is `count` and `element size`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RSTRING_PTR is not guaranteed to be VALUE-aligned (retry)shyouhei2018-05-091-7/+8
| | | | | | | | 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
* revert r63362 due to test failure. Sorry!shyouhei2018-05-091-7/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RSTRING_PTR is not guaranteed to be VALUE-alignedshyouhei2018-05-091-5/+7
| | | | | | | | Don't abuse struct RString to hold arbitrary memory region. use rb_alloc_tmp_buffer for that purpose. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* compile.c: do not dump pointersnobu2018-04-051-1/+1
| | | | | | | | * 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
* Reverting r62775, this should fix i686 buildstenderlove2018-03-191-29/+11
| | | | | | | | 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
* Revert "Add direct marking on iseq operands"naruse2018-03-161-10/+28
| | | | | | | | | | This reverts commit r62706. It causes SEGV on i686-linux (debian) and armv7l-linux-eabihf: http://www.rubyist.net/~akr/chkbuild/debian/ruby-trunk/log/20180309T204300Z.diff.html.gz http://rubyci.s3.amazonaws.com/scw-9d6766/ruby-trunk/log/20180309T211706Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Fix error: implicit conversion loses integer precision"naruse2018-03-161-2/+2
| | | | | | This reverts commit r62708. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix error: implicit conversion loses integer precisionkazu2018-03-101-2/+2
| | | | | | | | | | | http://ci.rvm.jp/results/trunk_clang_50@silicon-docker/627906 ``` iseq.h:41:36: error: implicit conversion loses integer precision: 'rb_num_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32] int cnt = iseq->body->variable.flip_count; ~~~ ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add direct marking on iseq operandstenderlove2018-03-091-28/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Directly marking iseq operands allows us to eliminate the "mark array" stored on ISEQ objects, which will reduce the amount of memory ISEQ objects consume. This patch changes the iseq mark function to: * Directly marks ISEQ operands * Iterate over and mark child ISEQs It also introduces two flags on the ISEQ object. In order to mark instruction operands, we have to disassemble the instructions and find the instruction parameters and types. Instructions may also be translated to jump addresses. Instruction sequences may get marked by the GC *while* they're mid flight (being compiled). The `ISEQ_TRANSLATED` flag is used to indicate whether or not the instructions have been translated to jump addresses so that when we decode the instructions we know whether or not we need to go from jump location back to original instruction or not. Not all ISEQ objects have any markable objects embedded in their instructions. We can detect whether or not an ISEQ has markable objects in the instructions at compile time. If the instructions contain markable objects, we set a flag `ISEQ_MARKABLE_ISEQ` on the ISEQ object. This means that during the mark phase, we can skip decompilation if the flag is *not* set. In other words, we can avoid decompilation of we know in advance there is nothing to mark. `once` instructions have an operand that contains the result of a one-time compilation of a regex. Before this patch, that operand was called an "inline cache", even though the struct was actually an "inline storage". This patch changes the operand to be an "inline storage" so that we can differentiate between caches that need marking (the inline storage) and caches that don't need marking (inline cache). [ruby-core:84909] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62706 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* there is no such thing like 0 in enum defined_typeshyouhei2018-01-191-0/+1
| | | | | | introduce new enum for it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* exclude flexible array size with old compilersnobu2018-01-141-3/+4
| | | | 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-7/+3
| | | | | | FLEX_ARY_LEN git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: Add a succinct bitvector implementation for insn_info_tablemame2018-01-091-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Rename code_range to code_locationmame2018-01-091-1/+1
| | | | | | | | | | | 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
* iseq.c: Refactor out rb_iseq_new_ifunc from rb_iseq_new_with_optmame2018-01-041-0/+1
| | | | | | 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