summaryrefslogtreecommitdiff
path: root/iseq.c
AgeCommit message (Collapse)Author
2019-08-19Update moved objects in original_iseqAlan Wu
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] Notes: Merged: https://github.com/ruby/ruby/pull/2391
2019-08-19Make it as clear as possible that RubyVM is MRI-specific and only exists on ↵Benoit Daloze
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
2019-08-12Rename rb_gc_mark_no_pin -> rb_gc_mark_movableAaron Patterson
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.
2019-08-13* expand tabs.git
2019-08-12Unpin default value objectsAaron Patterson
We're already updating the location of default values, so we may as well unpin them.
2019-08-05Document that RubyVM::InstructionSequence methods are implementation and ↵Jeremy Evans
version dependent Fixes [Bug #6785]
2019-07-23check iseq is executableKoichi Sasada
2019-07-23Let memory sizes of the various IMEMO object types be reflected correctlyLourens Naudé
[Feature #15805] Closes: https://github.com/ruby/ruby/pull/2140
2019-05-31Use UNALIGNED_MEMBER_PTRNobuyoshi Nakada
* 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`.
2019-05-29Fix Possible Control flow issues (DEADCODE)Kazuhiro NISHIYAMA
Coverity Scan says `Execution cannot reach this statement: "poison_object(v);"`, so do nothing when `ptr` is always 0 without address_sanitizer.
2019-05-23prefix ASAN related inline functions asan_Urabe, Shyouhei
requested by Ko1.
2019-05-18Rename rb_gc_new_location to rb_gc_locationAaron Patterson
The function will return new or existing locations depending on whether or not the object actually moved, so give it a more appropriate name.
2019-04-29iseq.c: removed unnecessary zero-fillsNobuyoshi Nakada
2019-04-25Lazy allocate the compile data catch table arrayLourens Naudé
Closes: https://github.com/ruby/ruby/pull/2119
2019-04-23* expand tabs.git
2019-04-22Symbols can move, so don't cache in static pointerAaron Patterson
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.
2019-04-20Update MJIT referencestenderlove
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
2019-04-20Add `GC.compact` again.tenderlove
🙏 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17Reverting compaction for nowtenderlove
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
2019-04-17Adding `GC.compact` and compacting GC support.tenderlove
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
2019-04-11Share the exception local ID tablenobu
[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
2019-04-10* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10Reverting all commits from r67479 to r67496 because of CI failureskazu
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
2019-04-10Adjusted stylesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-09Adding `GC.compact` and compacting GC support.tenderlove
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
2019-04-01* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-01unpoison / poison objects while walking the heaptenderlove
This fixes some ASAN errors git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-09Fix styles [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-23iseq.c: avoid Null pointer dereferencek0kubun
detected by coverity scan git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-20iseq.c: resurrect literal hash operandsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06Return same ISeq object for one src.ko1
* 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
2018-12-06Prefer rb_check_arity when 0 or 1 argumentsnobu
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
2018-11-27Add rb_typeddata_is_instance_ofnobu
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
2018-11-27fix for ISeq.of(method).ko1
* 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
2018-11-27* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-27`RubyVM::ISeq.of` accept ISeq.ko1
* 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
2018-11-26`TracePoint#enable(target_line:)` is supported. [Feature #15289]ko1
* 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
2018-11-26fix for ansi-pedantic compile option.ko1
* iseq.c (iseq_add_local_tracepoint_i): extract aggregate initialization. See https://travis-ci.org/ruby/ruby/jobs/459881277 * iseq.c (iseq_remove_local_tracepoint_i): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26fix type error.ko1
* iseq.c (iseq_iterate_children): should use cast to `int`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-26Support targetting TracePoint [Feature #15289]ko1
* 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
2018-11-05* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-05Implement `RubyVM::AST.of` [Feature #14836]yui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20Remove tracecoverage instructionsmame
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
2018-10-20iseq.c (rb_iseq_trace_flag_cleared): Accept size_t for type consistencymame
It caused "implicit conversion loses integer precision" on clang. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-20ext/coverage/: add the oneshot modemame
This patch introduces "oneshot_lines" mode for `Coverage.start`, which checks "whether each line was executed at least once or not", instead of "how many times each line was executed". A hook for each line is fired at most once, and after it is fired, the hook flag was removed; it runs with zero overhead. See [Feature #15022] in detail. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-13Prefer `rb_fstring_lit` over `rb_fstring_cstr`nobu
The former states explicitly that the argument must be a literal, and can optimize away `strlen` on all compilers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-04check argument type.ko1
* iseq.c (iseqw_s_compile): check argument type (T_STRING) to avoid SEGV. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e