summaryrefslogtreecommitdiff
path: root/iseq.c
AgeCommit message (Collapse)Author
2021-03-20merge revision(s) 737da8d383e116c83fb356386322626f039deb06:nagachika
Add another missing cast --- iseq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
2020-09-06merge revision(s) 3e02cd518fbe4d91c2aca7fbc3c5aafa387d3cb7: [Backport #17149]nagachika
Trace :return of builtin methods using opt_invokebuiltin_delegate_leave insn. Since Ruby 2.7, :return of methods using builtin have not been traced properly.
2019-12-20Fixed misspellingsNobuyoshi Nakada
Fixed misspellings reported at [Bug #16437], only in ruby and rubyspec.
2019-12-10vm_core.h (iseq_unique_id): prefer uintptr_t instead of unsigned longYusuke Endoh
It produced a warning about type cast in LLP64 (i.e., windows).
2019-12-09vm_args.c (rb_warn_check): Use iseq_unique_id instead of its pointerYusuke Endoh
(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.
2019-12-09Revert "vm_args.c (rb_warn_check): Use iseq_unique_id instead of its pointer"Yusuke Endoh
This reverts commit 036bc1da6c6c9b0fa9b7f5968d897a9554dd770e. This caused a failure on iseq_binary mode. http://ci.rvm.jp/results/trunk-iseq_binary@silicon-docker/2474587 Numbering iseqs is not trivial due to dump/load.
2019-12-09vm_args.c (rb_warn_check): Use iseq_unique_id instead of its pointerYusuke Endoh
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.
2019-12-05Introduce an "Inline IVAR cache" structAaron Patterson
This commit introduces an "inline ivar cache" struct. The reason we need this is so compaction can differentiate from an ivar cache and a regular inline cache. Regular inline caches contain references to `VALUE` and ivar caches just contain references to the ivar index. With this new struct we can easily update references for inline caches (but not inline var caches as they just contain an int)
2019-11-19make functions static卜部昌平
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. Notes: Merged: https://github.com/ruby/ruby/pull/2682
2019-11-19Clarify documentation for `InstructionSequence#compile`.Samuel Williams
We incorrectly assumed that the `file` argument should be the file name and caused https://github.com/scoutapp/scout_apm_ruby/issues/307 because exception backtrace did not contain correct path. This documentation clarifies the role of the different arguments and provides extra examples.
2019-11-18Warn on access/modify of $SAFE, and remove effects of modifying $SAFEJeremy Evans
This removes the security features added by $SAFE = 1, and warns for access or modification of $SAFE from Ruby-level, as well as warning when calling all public C functions related to $SAFE. This modifies some internal functions that took a safe level argument to no longer take the argument. rb_require_safe now warns, rb_require_string has been added as a version that takes a VALUE and does not warn. One public C function that still takes a safe level argument and that this doesn't warn for is rb_eval_cmd. We may want to consider adding an alternative method that does not take a safe level argument, and warn for rb_eval_cmd. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-11-14delete unused functions卜部昌平
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. Notes: Merged: https://github.com/ruby/ruby/pull/2677
2019-11-13Avoid top-level search for nested constant reference from nil in defined?Dylan Thacker-Smith
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. Notes: Merged: https://github.com/ruby/ruby/pull/2657
2019-11-09Support RB_BUILTIN in ISeq#to_aTakashi Kokubun
2019-11-08builtin.h must be included *AFTER* vm_core.hNobuyoshi Nakada
2019-11-08support builtin features with Ruby and C.Koichi Sasada
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. Notes: Merged: https://github.com/ruby/ruby/pull/2655
2019-10-29Right size the compile option hashLourens Naudé
Notes: Merged: https://github.com/ruby/ruby/pull/2590
2019-10-28Pin labels during disassemblyAaron Patterson
We need to ensure that labels are pinned while disassembling. If the compactor runs during disassembly, references to these labels could go bad, so this commit just ensures that the labels can't move until we're done. Notes: Merged: https://github.com/ruby/ruby/pull/2625
2019-10-24Combine call info and cache to speed up method invocationAlan Wu
To perform a regular method call, the VM needs two structs, `rb_call_info` and `rb_call_cache`. At the moment, we allocate these two structures in separate buffers. In the worst case, the CPU needs to read 4 cache lines to complete a method call. Putting the two structures together reduces the maximum number of cache line reads to 2. Combining the structures also saves 8 bytes per call site as the current layout uses separate two pointers for the call info and the call cache. This saves about 2 MiB on Discourse. This change improves the Optcarrot benchmark at least 3%. For more details, see attached bugs.ruby-lang.org ticket. Complications: - A new instruction attribute `comptime_sp_inc` is introduced to calculate SP increase at compile time without using call caches. At compile time, a `TS_CALLDATA` operand points to a call info struct, but at runtime, the same operand points to a call data struct. Instruction that explicitly define `sp_inc` also need to define `comptime_sp_inc`. - MJIT code for copying call cache becomes slightly more complicated. - This changes the bytecode format, which might break existing tools. [Misc #16258] Notes: Merged: https://github.com/ruby/ruby/pull/2564
2019-10-09avoid overflow in integer multiplication卜部昌平
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. Notes: Merged: https://github.com/ruby/ruby/pull/2540
2019-10-04iseq.c (rb_iseq_compile_on_base): RemovedYusuke Endoh
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.
2019-10-04iseq.c (rb_iseq_compile_with_option): dummy parent_iseq for the parserYusuke Endoh
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.
2019-10-04Make parser_params have parent_iseq instead of base_blockYusuke Endoh
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. Notes: Merged: https://github.com/ruby/ruby/pull/2519
2019-09-27Adjusted spaces [ci skip]Nobuyoshi Nakada
2019-09-26Remove mark arrayAaron Patterson
We don't use this array anymore so we can remove it
2019-09-26Scan the ISEQ arena for markables and mark themAaron Patterson
This commit scans the ISEQ arena for objects that can be marked and marks them. This should make the mark array unnecessary.
2019-09-26Introduce a secondary arenaAaron Patterson
We'll scan the secondary arena during GC mark. So, we should only allocate "markable" instruction linked list nodes out of the secondary arena.
2019-09-26Extract allocation and free functionsAaron Patterson
Now we can allocate and free a secondary arena.
2019-08-30Make Method/Proc#parameters handle **nil syntaxJeremy Evans
Use a [:nokey] entry in this case. Notes: Merged: https://github.com/ruby/ruby/pull/2395
2019-08-30Constified local variable `translator`Nobuyoshi Nakada
2019-08-30Adjust indent [ci skip]Nobuyoshi Nakada
2019-08-27decouple compile.c usage of imemo_ifunc卜部昌平
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.
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