summaryrefslogtreecommitdiff
path: root/vm.c
AgeCommit message (Collapse)Author
2019-09-03Merge pull request #2422 from jeremyevans/rb_keyword_given_pJeremy Evans
Add rb_keyword_given_p to the C-API Notes: Merged-By: jeremyevans <code@jeremyevans.net>
2019-08-30Allow ** syntax to be used for calling methods that do not accept keywordsJeremy Evans
Treat the ** syntax as passing a copy of the hash as the last positional argument. If the hash being double splatted is empty, do not add a positional argument. Remove rb_no_keyword_hash, no longer needed. Notes: Merged: https://github.com/ruby/ruby/pull/2395
2019-08-30Separate keyword arguments from positional argumentsYusuke Endoh
And, allow non-symbol keys as a keyword arugment Notes: Merged: https://github.com/ruby/ruby/pull/2395
2019-08-29drop-in type check for rb_define_singleton_method卜部昌平
We can check the function pointer passed to rb_define_singleton_method like how we do so in rb_define_method. Doing so revealed many arity mismatches.
2019-08-29drop-in type check for rb_define_method_id卜部昌平
We can check the function pointer passed to rb_define_method_id like how we do so in rb_define_method. This method is relatively rarely used so there are less problems found than the other APIs.
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-08solve "duplicate :raise event" [Bug #15877]Koichi Sasada
Without this patch, "raise" event invoked twice when raise an exception in "load"ed script. This patch by danielwaterworth (Daniel Waterworth). [Bug #15877]
2019-08-08Add *_clear methods to VM_COLLECT_USAGE_DETAILS APIGannon McGibbon
Add RubyVM::USAGE_ANALYSIS_INSN_CLEAR, RubyVM::USAGE_ANALYSIS_OPERAND_CLEAR, and RubyVM::USAGE_ANALYSIS_REGISTER_CLEAR to clear VM instruction hash constants. Closes: https://github.com/ruby/ruby/pull/2258
2019-08-08Add *_start and *_running methods to VM_COLLECT_USAGE_DETAILS APIGannon McGibbon
Add RubyVM::USAGE_ANALYSIS_INSN_START, RubyVM::USAGE_ANALYSIS_OPERAND_START, and RubyVM::USAGE_ANALYSIS_REGISTER_START to begin collecting VM instructions. Add RubyVM::USAGE_ANALYSIS_INSN_RUNNING, RubyVM::USAGE_ANALYSIS_OPERAND_RUNNING, and RubyVM::USAGE_ANALYSIS_REGISTER_RUNNING to check if VM instructions are being collected. Closes: https://github.com/ruby/ruby/pull/2258
2019-08-07Add a way to print debug counters without exitingAaron Patterson
I am trying to study debug counters inside a Rails application. Accessing debug counters by killing the process is hard because child processes don't get the same TRAP as the parent, and Rails seems to intercept calls to `exit`. Adding this method lets me print the debug counters when I want (at the end of requests for example)
2019-08-02Revert "Revert "Add a specialized instruction for `.nil?` calls""Yusuke Endoh
This reverts commit a0980f2446c0db735b8ffeb37e241370c458a626. Retry for macOS Mojave.
2019-08-02Revert "Add a specialized instruction for `.nil?` calls"Yusuke Endoh
This reverts commit 9faef3113fb4331524b81ba73005ba13fa0ef6c6. It seemed to cause a failure on macOS Mojave, though I'm unsure how. https://rubyci.org/logs/rubyci.s3.amazonaws.com/osx1014/ruby-master/log/20190802T034503Z.fail.html.gz This tentative revert is to check if the issue is actually caused by the change or not.
2019-08-01Make attr* methods define public methods if self in caller is not same as ↵Jeremy Evans
receiver Previously, attr* methods could be private even if not in the private section of a class/module block. This uses the same approach that ruby started using for define_method in 1fc33199736f316dd71d0c551edbf514528ddde6. Fixes [Bug #4537]
2019-08-01calc_lineno(): add assertions卜部昌平
This function has a lot of assumptions. Should make them sure.
2019-07-31Add a specialized instruction for `.nil?` callsAaron Patterson
This commit adds a specialized instruction for called to `.nil?`. It is about 27% faster than master in the case where the object is nil or not nil. In the case where an object implements `nil?`, I think it may be slightly slower. Here is a benchmark: ```ruby require "benchmark/ips" class Niller def nil?; true; end end not_nil = Object.new xnil = nil niller = Niller.new Benchmark.ips do |x| x.report("nil?") { xnil.nil? } x.report("not nil") { not_nil.nil? } x.report("niller") { niller.nil? } end ``` On Ruby master: ``` [aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 429.195k i/100ms not nil 437.889k i/100ms niller 437.935k i/100ms Calculating ------------------------------------- nil? 20.166M (± 8.1%) i/s - 100.002M in 5.002794s not nil 20.046M (± 7.6%) i/s - 99.839M in 5.020086s niller 22.467M (± 6.1%) i/s - 112.111M in 5.013817s [aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 449.660k i/100ms not nil 433.836k i/100ms niller 443.073k i/100ms Calculating ------------------------------------- nil? 19.997M (± 8.8%) i/s - 99.375M in 5.020458s not nil 20.529M (± 7.0%) i/s - 102.385M in 5.020689s niller 21.796M (± 8.0%) i/s - 108.110M in 5.002300s [aaron@TC ~/g/ruby (master)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 402.119k i/100ms not nil 438.968k i/100ms niller 398.226k i/100ms Calculating ------------------------------------- nil? 20.050M (±12.2%) i/s - 98.519M in 5.008817s not nil 20.614M (± 8.0%) i/s - 102.280M in 5.004531s niller 22.223M (± 8.8%) i/s - 110.309M in 5.013106s ``` On this branch: ``` [aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 468.371k i/100ms not nil 456.517k i/100ms niller 454.981k i/100ms Calculating ------------------------------------- nil? 27.849M (± 7.8%) i/s - 138.169M in 5.001730s not nil 26.417M (± 8.7%) i/s - 131.020M in 5.011674s niller 21.561M (± 7.5%) i/s - 107.376M in 5.018113s [aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 477.259k i/100ms not nil 428.712k i/100ms niller 446.109k i/100ms Calculating ------------------------------------- nil? 28.071M (± 7.3%) i/s - 139.837M in 5.016590s not nil 25.789M (±12.9%) i/s - 126.470M in 5.011144s niller 20.002M (±12.2%) i/s - 98.144M in 5.001737s [aaron@TC ~/g/ruby (specialized-nilp)]$ ./ruby compil.rb Warming up -------------------------------------- nil? 467.676k i/100ms not nil 445.791k i/100ms niller 415.024k i/100ms Calculating ------------------------------------- nil? 26.907M (± 8.0%) i/s - 133.755M in 5.013915s not nil 25.319M (± 7.9%) i/s - 125.713M in 5.007758s niller 19.569M (±11.8%) i/s - 96.286M in 5.008533s ``` Co-Authored-By: Ashe Connor <kivikakk@github.com>
2019-07-24Clarify Thread exception handling documentation [ci skip]Jeremy Evans
From djellemah (John Anderson). Fixes [Bug #12252]
2019-07-19In some situations, `vm_stack` can be NULL, but `cfp` is valid.Samuel Williams
2019-07-19Better usage of `rb_ec_clear_vm_stack` to maintain invariants.Samuel Williams
2019-07-19Improve ec assertions.Samuel Williams
2019-07-19Remove `rb_vm_push_frame` as it is no longer used.Samuel Williams
2019-07-18Remove unused vm_stack recycling.Samuel Williams
2019-07-14MJIT Support for getblockparamproxyTakashi Kokubun
2019-07-13Document $LOAD_PATH.resolve_feature_path in globals.rdocBenoit Daloze
* RDoc does not seem to support documenting singleton object methods, and making $LOAD_PATH a class as a workaround is too weird.
2019-07-11$LOAD_PATH.resolve_feature_pathNobuyoshi Nakada
Moved from RubyVM. [Feature #15903]
2019-06-20Ensure that vm_stack is cleared in `thread_cleanup_func_before_exec`.Samuel Williams
If `vm_stack` is left dangling in a forked process, the gc attempts to scan it, but it is invalid and will cause a segfault. Therefore, we clear it before forking. In order to simplify this, `rb_ec_clear_vm_stack` was introduced.
2019-06-20Revert failed attempt at fixing invalid usage of vm_stack.Samuel Williams
2019-06-20Don't clear cfp, it causes problems.Samuel Williams
2019-06-20Ensure `vm_stack` is cleared after fork.Samuel Williams
2019-06-20Don't try to dereference NULL cfp.Samuel Williams
2019-06-19Adjust indentNobuyoshi Nakada
2019-06-19Remove IA64 support.Samuel Williams
2019-06-19Use shared implementation of `rb_ec_initialize_vm_stack`.Samuel Williams
2019-06-19Basic assertions for thread initialization.Samuel Williams
2019-06-19Ensure execution context is cleared after thread is finished.Samuel Williams
2019-06-19Better handling of root fiber.Samuel Williams
2019-06-19Fix handling of vm_stack_size and avoid trying to deallocate it.Samuel Williams
2019-06-19Move vm stack init into thread.Samuel Williams
2019-06-12* expand tabs.git
2019-06-11Add compaction support for more types.Aaron Patterson
This commit adds compaction support for: * Fibers * Continuations * Autoload Constants
2019-06-01Make opt_aref instruction support Integer#[]Yusuke Endoh
only when its receiver and the argument are both Integers. Since 6bedbf4625, Integer#[] has supported a range extraction. This means that Integer#[] now accepts multiple arguments, which made the method very slow unfortunately. This change fixes the performance issue by adding a special handling for its traditional use case: `num[idx]` where both `num` and `idx` are Integers.
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-31Keep vm->orig_progname aliveAlan Wu
`vm->orig_progname` can be different from `vm->progname` when user code assigns to `$0`. While `vm->progname` is kept alive by the global table, nothing marked `vm->orig_progname`. [Bug #15887]
2019-05-22Eagerly name modules and classesAlan Wu
* variable.c: make the hidden ivars `classpath` and `tmp_classpath` the source of truth for module and constant names. Assign to them when modules are bind to constants. * variable.c: remove references to module name cache, as what used to be the cache is now the source of truth. Remove rb_class_path_no_cache(). * variable.c: remove the hidden ivar `classid`. This existed for the purposes of module name search, which is now replaced. Also, remove the associated rb_name_class(). * class.c: use rb_set_class_path_string to set the name of Object during boot. Must use a fstring as this runs before rb_cString is initialized and creating a normal string leads to a VALUE without a class. * spec/ruby/core/module/name_spec.rb: add a few specs to specify what happens to Module#name across multiple operations. These specs pass without other code changes in this commit. [Feature #15765]
2019-05-14Fixing function nameAaron Patterson
This function is used for marking / pinning vm stack values, so it should have "vm" in the function name to be more clear.
2019-04-22Prevent rb_define_(class|module) classes from movingAaron Patterson
Before this commit, classes and modules would be registered with the VM's `defined_module_hash`. The key was the ID of the class, but that meant that it was possible for hash collisions to occur. The compactor doesn't allow classes in the `defined_module_hash` to move, but if there is a conflict, then it's possible a class would be removed from the hash and not get pined. This commit changes the key / value of the hash just to be the class itself, thus preventing movement.
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-17Introduce pattern matching [EXPERIMENTAL]ktsj
[ruby-core:87945] [Feature #14912] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 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