summaryrefslogtreecommitdiff
path: root/iseq.c
Commit message (Collapse)AuthorAgeFilesLines
* need to mark script_linesKoichi Sasada2021-10-291-0/+1
|
* freeze (make shareable) script_linesKoichi Sasada2021-10-211-2/+7
|
* `RubyVM.keep_script_lines`Koichi Sasada2021-10-211-4/+40
| | | | | | | | | | | | | | `RubyVM.keep_script_lines` enables to keep script lines for each ISeq and AST. This feature is for debugger/REPL support. ```ruby RubyVM.keep_script_lines = true RubyVM::keep_script_lines = true eval("def foo = nil\ndef bar = nil") pp RubyVM::InstructionSequence.of(method(:foo)).script_lines ```
* Cleanup iseq.c minimize diff with upstreamAlan Wu2021-10-201-21/+8
| | | | | Most of these are vestiges of our old setup where we hack into the interpreter loop.
* TracePoint supportAlan Wu2021-10-201-16/+0
| | | | | | | | | | | | | | | | | | | | | | This change fixes some cases where YJIT fails to fire tracing events. Most of the situations YJIT did not handle correctly involves enabling tracing while running inside generated code. A new operation to invalidate all generated code is added, which uses patching to make generated code exit at the next VM instruction boundary. A new routine called `jit_prepare_routine_call()` is introduced to facilitate this and should be used when generating code that could allocate, or could otherwise use `RB_VM_LOCK_ENTER()`. The `c_return` event is fired in the middle of an instruction as opposed to at an instruction boundary, so it requires special handling. C method call return points are patched to go to a fucntion which does everything the interpreter does, including firing the `c_return` event. The generated code for C method calls normally does not fire the event. Invalided code should not change after patching so the exits are not clobbered. A new variable is introduced to track the region of code that should not change.
* Clear JIT code when tracepoints get enabledAaron Patterson2021-10-201-0/+11
| | | | | Clear out any JIT code on iseqs when tracepoints get enabled. We can't handle tracepoints right now, so we'll just try to recompile later.
* Yet Another Ruby JIT!Jose Narvaez2021-10-201-6/+6
| | | | Renaming uJIT to YJIT. AKA s/ujit/yjit/g.
* Should fix builds without mjit supportAlan Wu2021-10-201-0/+1
|
* Tie lifetime of uJIT blocks to iseqsAlan Wu2021-10-201-0/+3
| | | | | | | | | | | | | | | | | | | | * Tie lifetime of uJIT blocks to iseqs Blocks weren't being freed when iseqs are collected. * Add rb_dary. Use it for method dependency table * Keep track of blocks per iseq Remove global version_tbl * Block version bookkeeping fix * dary -> darray * free ujit_blocks * comment about size of ujit_blocks
* Restore interpreter regs in ujit hook. Implement leave bytecode.Maxime Chevalier-Boisvert2021-10-201-11/+2
|
* Add to the MicroJIT scraper an example that passes ecAlan Wu2021-10-201-0/+7
|
* MicroJIT: Don't compile trace instructionsAlan Wu2021-10-201-0/+19
|
* Small build fixesAlan Wu2021-10-201-0/+2
|
* Try to fix Windows buildAlan Wu2021-10-201-1/+0
|
* Avoid triggering GC while translating threaded codeAlan Wu2021-10-201-0/+1
|
* Remove PC argument from ujit instructionsMaxime Chevalier-Boisvert2021-10-201-1/+1
|
* Removed native_pop_code, ported call with labelMaxime Chevalier-Boisvert2021-10-201-61/+0
|
* Generate multiple copies of native code for `pop`Alan Wu2021-10-201-6/+6
| | | | | | Insert generated addresses into st_table for mapping native code addresses back to info about VM instructions. Export `encoded_insn_data` to do this. Also some style fixes.
* Reimplement Alan's pop instruction with the new assemblerMaxime Chevalier-Boisvert2021-10-201-0/+26
|
* Added sub instruction, 32-bit registers, more testsMaxime Chevalier-Boisvert2021-10-201-0/+12
|
* Yeah, this actually works!Alan Wu2021-10-201-1/+33
|
* Add example handler for ujit and scrape it from vm.oAlan Wu2021-10-201-1/+10
|
* Using NIL_P macro instead of `== Qnil`S.H2021-10-031-4/+4
|
* Replace RBOOL macroS-H-GAMELINKS2021-09-051-1/+1
|
* Support tracing of attr_reader and attr_writerJeremy Evans2021-08-291-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | In vm_call_method_each_type, check for c_call and c_return events before dispatching to vm_call_ivar and vm_call_attrset. With this approach, the call cache will still dispatch directly to those functions, so this change will only decrease performance for the first (uncached) call, and even then, the performance decrease is very minimal. This approach requires that we clear the call caches when tracing is enabled or disabled. The approach currently switches all vm_call_ivar and vm_call_attrset call caches to vm_call_general any time tracing is enabled or disabled. So it could theoretically result in a slowdown for code that constantly enables or disables tracing. This approach does not handle targeted tracepoints, but from my testing, c_call and c_return events are not supported for targeted tracepoints, so that shouldn't matter. This includes a benchmark showing the performance decrease is minimal if detectable at all. Fixes [Bug #16383] Fixes [Bug #10470] Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
* Add keyrest to ruby2_keywords parameters [Bug #18011]Nobuyoshi Nakada2021-08-031-2/+11
|
* Make RubyVM::AbstractSyntaxTree.of raise for method/proc created in evalJeremy Evans2021-07-291-0/+6
| | | | | | | | | | | This changes Thread::Location::Backtrace#absolute_path to return nil for methods/procs defined in eval. If the realpath of an iseq is nil, that indicates it was defined in eval, in which case you cannot use RubyVM::AbstractSyntaxTree.of. Fixes [Bug #16983] Co-authored-by: Koichi Sasada <ko1@atdot.net>
* iseq.c: Make ast_line_count return 0 when syntax error occurredYusuke Endoh2021-06-261-0/+4
| | | | | | | | | | | | This broke coverage CI ``` 1) Failure: TestRequire#test_load_syntax_error [/home/runner/work/actions/actions/ruby/test/ruby/test_require.rb:228]: Exception(SyntaxError) with message matches to /unexpected/. [SyntaxError] exception expected, not #<TypeError: no implicit conversion of false into Integer>. ``` https://github.com/ruby/actions/runs/2914743968?check_suite_focus=true
* Enable USE_ISEQ_NODE_ID by defaultYusuke Endoh2021-06-181-4/+4
| | | | | | | | ... which is formally called EXPERIMENTAL_ISEQ_NODE_ID. See also ff69ef27b06eed1ba750e7d9cab8322f351ed245. https://bugs.ruby-lang.org/issues/17930
* Make it possible to get AST::Node from Thread::Backtrace::LocationYusuke Endoh2021-06-181-1/+1
| | | | | | | | | RubyVM::AST.of(Thread::Backtrace::Location) returns a node that corresponds to the location. Typically, the node is a method call, but not always. This change also includes iseq's dump/load support of node_ids for each instructions.
* node.h: Reduce struct size to fit with Ruby object size (five VALUEs)Yusuke Endoh2021-06-181-2/+12
| | | | | | | | by merging `rb_ast_body_t#line_count` and `#script_lines`. Fortunately `line_count == RARRAY_LEN(script_lines)` was always satisfied. When script_lines is saved, it has an array of lines, and when not saved, it has a Fixnum that represents the old line_count.
* Refactor rb_vm_insn_addr2insn callsTakashi Kokubun2021-06-021-0/+12
| | | | It's been a way too much amount of ifdefs.
* compile.c: Pass node instead of nd_line(node) to ADD_INSN* functionsYusuke Endoh2021-05-071-0/+24
| | | | | | | | | | | | | | | ... then, new_insn_core extracts nd_line(node). Also, if a macro "EXPERIMENTAL_ISEQ_NODE_ID" is defined, this changeset keeps nd_node_id(node) for each instruction. This is intended for TypeProf to identify what AST::Node corresponds to each instruction. This patch is originally authored by @yui-knk for showing which column a NoMethodError occurred. https://github.com/ruby/ruby/compare/master...yui-knk:feature/node_id Co-Authored-By: Yuichiro Kaneko <yui-knk@ruby-lang.org>
* Use rb_fstring for "defined" strings.Aaron Patterson2021-03-171-15/+1
| | | | | | We can take advantage of fstrings to de-duplicate the defined strings. This means we don't need to keep the list of defined strings on the VM (or register them as mark objects)
* Store strings for `defined` in the iseqsAaron Patterson2021-03-171-1/+1
| | | | | We can know the string used for "defined" calls at compile time, then store the string in the instruction sequences
* remove invalidated ccKoichi Sasada2021-01-061-2/+6
| | | | if cc is invalidated, cc should be released from iseq.
* enable constant cache on ractorsKoichi Sasada2021-01-051-0/+11
| | | | | | | | | | | | | | | | constant cache `IC` is accessed by non-atomic manner and there are thread-safety issues, so Ruby 3.0 disables to use const cache on non-main ractors. This patch enables it by introducing `imemo_constcache` and allocates it by every re-fill of const cache like `imemo_callcache`. [Bug #17510] Now `IC` only has one entry `IC::entry` and it points to `iseq_inline_constant_cache_entry`, managed by T_IMEMO object. `IC` is atomic data structure so `rb_mjit_before_vm_ic_update()` and `rb_mjit_after_vm_ic_update()` is not needed.
* Make RubyVM::InstructionSequence.compile_file use same encoding as loadJeremy Evans2020-11-191-1/+1
| | | | | | | | This switches the internal function from rb_parser_compile_file_path to rb_parser_load_file, which is the same internal method that Kernel#load uses. Fixes [Bug #17308]
* remain enabled and line specified trace pointsKoichi Sasada2020-11-171-5/+8
| | | | | | | If two or more tracepoints enabled with the same target and with different target lines, the only last line is activated. This patch fixes this issue by remaining existing trace instructions. [Bug #17302]
* strip trailing spaces [ci skip]Nobuyoshi Nakada2020-10-301-1/+1
|
* check isolated Proc more strictlyKoichi Sasada2020-10-291-16/+23
| | | | | Isolated Proc prohibit to access outer local variables, but it was violated by binding and so on, so they should be error.
* Dump FrozenCore speciallyNobuyoshi Nakada2020-10-201-1/+2
|
* sync RClass::ext::iv_index_tblKoichi Sasada2020-10-171-0/+15
| | | | | | | | | | | | iv_index_tbl manages instance variable indexes (ID -> index). This data structure should be synchronized with other ractors so introduce some VM locks. This patch also introduced atomic ivar cache used by set/getinlinecache instructions. To make updating ivar cache (IVC), we changed iv_index_tbl data structure to manage (ID -> entry) and an entry points serial and index. IVC points to this entry so that cache update becomes atomically.
* Remove unused field in rb_iseq_constant_bodyAlan Wu2020-07-231-3/+0
| | | | | This was introduced in 191ce5344ec42c91571f8f47c85be9138262b1c7 and has been unused since beae6cbf0fd8b6619e5212552de98022d4c4d4d4
* Use ID instead of GENTRY for gvars. (#3278)Koichi Sasada2020-07-031-12/+0
| | | | | | | | | | | | Use ID instead of GENTRY for gvars. Global variables are compiled into GENTRY (a pointer to struct rb_global_entry). This patch replace this GENTRY to ID and make the code simple. We need to search GENTRY from ID every time (st_lookup), so additional overhead will be introduced. However, the performance of accessing global variables is not important now a day and this simplicity helps Ractor development.
* fix return event and opt_invokebuiltin_delegate_leave (#3256)Koichi Sasada2020-06-261-7/+10
| | | | | | | | | If :return event is specified for a opt_invokebuiltin_delegate_leave and leave combination, the instructions should be opt_invokebuiltin_delegate trace_return instructions. To make it, opt_invokebuiltin_delegate_leave instruction will be changed to opt_invokebuiltin_delegate even if it is not an event target instruction.
* Add another missing castTakashi Kokubun2020-06-231-1/+1
|
* Add missing castTakashi Kokubun2020-06-231-1/+1
|
* Trace :return of builtin methodsTakashi Kokubun2020-06-231-1/+5
| | | | | | using opt_invokebuiltin_delegate_leave insn. Since Ruby 2.7, :return of methods using builtin have not been traced properly.
* ISeq created with callback is special, translation cannot be appliedKoichi Sasada2020-06-171-1/+1
|