aboutsummaryrefslogtreecommitdiffstats
path: root/iseq.c
Commit message (Collapse)AuthorAgeFilesLines
* avoid overflow in integer multiplication卜部昌平2019-10-091-2/+5
| | | | | | | 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.
* iseq.c (rb_iseq_compile_on_base): RemovedYusuke Endoh2019-10-041-20/+7
| | | | | | | ko1 cannot remember why he introduced the function. And it is not used. After it is removed, the argument "base_block" of rb_iseq_compile_with_option is always zero.
* iseq.c (rb_iseq_compile_with_option): dummy parent_iseq for the parserYusuke Endoh2019-10-041-1/+8
| | | | | | | | | | | | | | | | The parsing of `RubyVM::InstructionSequence.compile` does not support an outer scope currently. So it specified NULL as parent_iseq for the parser. However, it resulted in the following false-positive warning. ``` RubyVM::InstructionSequence.compile(<<END) o = Object.new o #=> <compiled>:2: warning: possibly useless use of a variable in void context END ``` This change specifies a dummy empty parent_iseq instead of NULL, which suppresses the false positive.
* Make parser_params have parent_iseq instead of base_blockYusuke Endoh2019-10-041-1/+1
| | | | | | | | | | | | The parser needs to determine whether a local varaiable is defined or not in outer scope. For the sake, "base_block" field has kept the outer block. However, the whole block was actually unneeded; the parser used only base_block->iseq. So, this change lets parser_params have the iseq directly, instead of the whole block.
* Adjusted spaces [ci skip]Nobuyoshi Nakada2019-09-271-2/+2
|
* Remove mark arrayAaron Patterson2019-09-261-4/+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/+3
| | | | | 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-3/+5
| | | | | | We'll scan the secondary arena during GC mark. So, we should only allocate "markable" instruction linked list nodes out of the secondary arena.
* Extract allocation and free functionsAaron Patterson2019-09-261-17/+30
| | | | Now we can allocate and free a secondary arena.
* Make Method/Proc#parameters handle **nil syntaxJeremy Evans2019-08-301-0/+6
| | | | Use a [:nokey] entry in this case.
* Constified local variable `translator`Nobuyoshi Nakada2019-08-301-12/+5
|
* Adjust indent [ci skip]Nobuyoshi Nakada2019-08-301-26/+26
|
* decouple compile.c usage of imemo_ifunc卜部昌平2019-08-271-4/+6
| | | | | | | 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.
* Update moved objects in original_iseqAlan Wu2019-08-191-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without doing this, enabling a TracePoint on a method could lead to use of moved objects. This was found by running `env RUBY_ISEQ_DUMP_DEBUG=to_binary make test-all`, which sets orignal_iseq then runs the compaction tests and the tracepoint tests. Please excuse the lack of tests. I was not able to figure out how to reliably trigger a move on a specific iseq imemo to make a good regression test. To manually confirm the problem and this fix, you can run: ``` env RUBY_ISEQ_DUMP_DEBUG=to_binary make test-all \ TESTOPTS="test/ruby/test_gc_compact.rb \ test/gdbm/test_gdbm.rb \ test/ruby/test_settracefunc.rb" ``` Or the following script: ```ruby tp = TracePoint.new(:line) {} 1.times do # put it in a block to not keep these objects alive objects = 10_000.times.map { Object.new } objects.hash end 1.times do # this allocation pattern can realistically happen in an app # at load time beek = 10_000.times.map do eval(<<-RUBY) def foo a + b 1.times { 4 + 234234 } nil + 234 end RUBY Object.new Object.new end beek.hash end tp.enable(target: self.:foo) { 234 } # allocate original iseq GC.verify_compaction_references(toward: :empty) GC.compact tp.enable(target: self.:foo) { 234234 } # crash ``` [Bug #16098]
* Make it as clear as possible that RubyVM is MRI-specific and only exists on ↵Benoit Daloze2019-08-191-2/+4
| | | | | | | | | | | | | MRI (#2113) [ci skip] * Make it clear as possible that RubyVM is MRI-specific and only exists on MRI * See [Bug #15743]. * Use "CRuby VM" instead of "Ruby VM" for clarity. * Use YARV rather than "CRuby VM" for documenting RubyVM::InstructionSequence * Avoid introducing a new "CRuby VM" term in documentation
* Rename rb_gc_mark_no_pin -> rb_gc_mark_movableAaron Patterson2019-08-121-8/+8
| | | | | | Renaming this function. "No pin" leaks some implementation details. We just want users to know that if they mark this object, the reference may move and they'll need to update the reference accordingly.
* * expand tabs.git2019-08-131-1/+1
|
* Unpin default value objectsAaron Patterson2019-08-121-1/+1
| | | | | We're already updating the location of default values, so we may as well unpin them.
* Document that RubyVM::InstructionSequence methods are implementation and ↵Jeremy Evans2019-08-051-1/+3
| | | | | | version dependent Fixes [Bug #6785]
* check iseq is executableKoichi Sasada2019-07-231-28/+28
|
* Let memory sizes of the various IMEMO object types be reflected correctlyLourens Naudé2019-07-231-3/+3
| | | | | | [Feature #15805] Closes: https://github.com/ruby/ruby/pull/2140
* Use UNALIGNED_MEMBER_PTRNobuyoshi Nakada2019-05-311-5/+8
| | | | | | | | | | | * internal.h (UNALIGNED_MEMBER_ACCESS, UNALIGNED_MEMBER_PTR): moved from eval_intern.h. * compile.c iseq.c, vm.c: use UNALIGNED_MEMBER_PTR for `entries` in `struct iseq_catch_table`. * vm_eval.c, vm_insnhelper.c: use UNALIGNED_MEMBER_PTR for `body` in `rb_method_definition_t`.
* Fix Possible Control flow issues (DEADCODE)Kazuhiro NISHIYAMA2019-05-291-6/+2
| | | | | Coverity Scan says `Execution cannot reach this statement: "poison_object(v);"`, so do nothing when `ptr` is always 0 without address_sanitizer.
* prefix ASAN related inline functions asan_Urabe, Shyouhei2019-05-231-6/+6
| | | | requested by Ko1.
* Rename rb_gc_new_location to rb_gc_locationAaron Patterson2019-05-181-10/+10
| | | | | The function will return new or existing locations depending on whether or not the object actually moved, so give it a more appropriate name.
* iseq.c: removed unnecessary zero-fillsNobuyoshi Nakada2019-04-291-2/+3
|
* Lazy allocate the compile data catch table arrayLourens Naudé2019-04-251-1/+1
| | | | Closes: https://github.com/ruby/ruby/pull/2119
* * expand tabs.git2019-04-231-2/+2
|
* Symbols can move, so don't cache in static pointerAaron Patterson2019-04-221-7/+7
| | | | | | This changes the static pointers to use IDs then look up the symbols with the ID. Symbols can move, so we don't want to keep static references to them.
* Update MJIT referencestenderlove2019-04-201-0/+3
| | | | | | ISeq can move, so we need to tell MJIT where the new location is. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add `GC.compact` again.tenderlove2019-04-201-18/+82
| | | | | | 🙏 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting compaction for nowtenderlove2019-04-171-82/+18
| | | | | | 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-18/+82
| | | | | | | | | | | 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-1/+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
* * expand tabs.svn2019-04-101-8/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting all commits from r67479 to r67496 because of CI failureskazu2019-04-101-84/+18
| | | | | | | | 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
* Adjusted stylesnobu2019-04-101-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-091-18/+84
| | | | | | | | | | | 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
* * expand tabs.svn2019-04-011-10/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* unpoison / poison objects while walking the heaptenderlove2019-04-011-0/+14
| | | | | | This fixes some ASAN errors git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix styles [ci skip]nobu2019-01-091-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: avoid Null pointer dereferencek0kubun2018-12-231-1/+1
| | | | | | detected by coverity scan git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* iseq.c: resurrect literal hash operandsnobu2018-12-201-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Return same ISeq object for one src.ko12018-12-061-35/+51
| | | | | | | | | | | | | | | | | | | | | * 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
* Prefer rb_check_arity when 0 or 1 argumentsnobu2018-12-061-2/+1
| | | | | | | Especially over checking argc then calling rb_scan_args just to raise an ArgumentError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add rb_typeddata_is_instance_ofnobu2018-11-271-3/+1
| | | | | | | Similar to rb_typeddata_is_kind_of, except for that inherited type is not an instance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix for ISeq.of(method).ko12018-11-271-9/+5
| | | | | | | * iseq.c (iseqw_s_of): `rb_method_iseq(method)` can return NULL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * expand tabs.svn2018-11-271-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* `RubyVM::ISeq.of` accept ISeq.ko12018-11-271-7/+16
| | | | | | | | | * iseq.c (iseqw_s_of): return given object if the given object is a `RubyVM::InstructionSequence`. We can specify ISeq for `TracePoint#enable(target:)`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* `TracePoint#enable(target_line:)` is supported. [Feature #15289]ko12018-11-261-7/+20
| | | | | | | | | * 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