summaryrefslogtreecommitdiff
path: root/ruby.c
AgeCommit message (Collapse)Author
18 hoursZJIT: Handle ZJIT options properly (#13197)Takashi Kokubun
Notes: Merged-By: k0kubun <[email protected]>
12 daysResurrect yjit_hookTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysImplement Options as part of ZJITStateTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysFix the handling of flagsTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysDisable yjit_hook builtin for nowTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysHook zjit_initTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysCall libzjit from CRubyTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysAdd --zjit optionTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-03-27Freeze $/ and make it ractor safeÉtienne Barrié
[Feature #21109] By always freezing when setting the global rb_rs variable, we can ensure it is not modified and can be accessed from a ractor. We're also making sure it's an instance of String and does not have any instance variables. Of course, if $/ is changed at runtime, it may cause surprising behavior but doing so is deprecated already anyway. Co-authored-by: Jean Boussier <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/12975
2025-03-16Make ASAN default option string built-in librubyNobuyoshi Nakada
The content depends on ruby internal, not responsibility of the caller. Revive `RUBY_GLOBAL_SETUP` macro to define the hook function. Notes: Merged: https://github.com/ruby/ruby/pull/12933
2025-03-06RUBY_FREE_AT_EXIT does not work when error in -rPeter Zhu
[Bug #21173] When loading a file using the command line -r, it is processed before RUBY_FREE_AT_EXIT is checked. So if the loaded file raises an error, it will cause memory to not be freed with RUBY_FREE_AT_EXIT. For example `ruby -rtest.rb -e ""` will report a large amount of memory leaks if `test.rb` raises. Notes: Merged: https://github.com/ruby/ruby/pull/12859
2025-02-13[Feature #21116] Extract RJIT as a third-party gemNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12740
2025-01-24Improve docs of -I ruby optionXavier Noria
Notes: Merged: https://github.com/ruby/ruby/pull/12627
2025-01-09[Bug #21018] Show invalid command line option more properlyNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12538
2024-12-24[Bug #20979] [DOC] Add a proviso to `+comment` optionNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12450
2024-11-22Free parse result under -cJohn Hawthorn
Notes: Merged: https://github.com/ruby/ruby/pull/12148
2024-11-08Fix memory leak in prism when syntax error in iseq compilationPeter Zhu
If there's a syntax error during iseq compilation then prism would leak memory because it would not free the pm_parse_result_t. This commit changes pm_iseq_new_with_opt to have a rb_protect to catch when an error is raised, and return NULL and set error_state to a value that can be raised by calling rb_jump_tag after memory has been freed. For example: 10.times do 10_000.times do eval("/[/=~s") rescue SyntaxError end puts `ps -o rss= -p #{$$}` end Before: 39280 68736 99232 128864 158896 188208 217344 246304 275376 304592 After: 12192 13200 14256 14848 16000 16000 16000 16064 17232 17952 Notes: Merged: https://github.com/ruby/ruby/pull/12036
2024-11-06`Warning[:strict_unused_block]`Koichi Sasada
to show unused block warning strictly. ```ruby class C def f = nil end class D def f = yield end [C.new, D.new].each{|obj| obj.f{}} ``` In this case, `D#f` accepts a block. However `C#f` doesn't accept a block. There are some cases passing a block with `obj.f{}` where `obj` is `C` or `D`. To avoid warnings on such cases, "unused block warning" will be warned only if there is not same name which accepts a block. On the above example, `C.new.f{}` doesn't show any warnings because there is a same name `D#f` which accepts a block. We call this default behavior as "relax mode". `strict_unused_block` new warning category changes from "relax mode" to "strict mode", we don't check same name methods and `C.new.f{}` will be warned. [Feature #15554] Notes: Merged: https://github.com/ruby/ruby/pull/12005
2024-11-04YJIT: Replace Array#each only when YJIT is enabled (#11955)Takashi Kokubun
* YJIT: Replace Array#each only when YJIT is enabled * Add comments about BUILTIN_ATTR_C_TRACE * Make Ruby Array#each available with --yjit as well * Fix all paths that expect a C location * Use method_basic_definition_p to detect patches * Copy a comment about C_TRACE flag to compilers * Rephrase a comment about add_yjit_hook * Give METHOD_ENTRY_BASIC flag to Array#each * Add --yjit-c-builtin option * Allow inconsistent source_location in test-spec * Refactor a check of BUILTIN_ATTR_C_TRACE * Set METHOD_ENTRY_BASIC without touching vm->running Notes: Merged-By: maximecb <[email protected]>
2024-10-02Make default parser enum and define getter/setterNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/11761
2024-09-29Fix loading of nonascii script name on WindowsLars Kanis
Since the prism parser was enabled by default, loading scripts with nonascii characters somewhere in the script path is no longer working. It only works when the codepage was switched to 65001 (UTF-8). This patch doesn't change the encoding of __FILE__. It is still in locale encoding. That's why pm_load_file() is called with UTF-8 script name and pm_parse_file() with locale encoding. The loading of nonascii script names is part of the test-all, but it doesn't trigger the failure on GHA, since it is using cp 65001. On other codepages it fails with: [53/71] TestRubyOptions#test_command_line_progname_nonascii = 0.04 s 1) Failure: TestRubyOptions#test_command_line_progname_nonascii [C:/Users/Administrator/ruby/test/ruby/test_rubyoptions.rb:1086]: [ruby-dev:48752] [Bug #10555] pid 1736 exit 1 | C:\Users\Administrator\ruby\ruby.exe: No such file or directory -- �.rb (LoadError) . 1. [1/2] Assertion for "stdout" | <["\xFF.rb"]> expected but was | <[]>. 2. [2/2] Assertion for "stderr" | <[]> expected but was | <["C:\\Users\\Administrator\\ruby\\ruby.exe: No such file or directory -- \xFF.rb (LoadError)"]>.
2024-09-13[PRISM] Only parse shebang on main scriptKevin Newton
Fixes [Bug #20730] Notes: Merged: https://github.com/ruby/ruby/pull/11617
2024-08-29[PRISM] Handle RubyVM.keep_script_linesKevin Newton
Notes: Merged: https://github.com/ruby/ruby/pull/11501
2024-08-29[PRISM] For stdin scripts, use locale encodingAlan Wu
For example: $ echo 'p __ENCODING__' | LANG=C ruby #<Encoding:US-ASCII> But, allow -K to override the source encoding. Found by running spec/ruby/language/magic_comment_spec.rb with LANG=C. Notes: Merged: https://github.com/ruby/ruby/pull/11505
2024-08-29[Bug #20704] Win32: Fix chdir to non-ASCII pathNobuyoshi Nakada
On Windows, `chdir` in compilers' runtime libraries uses the active code page, but command line arguments in ruby are always UTF-8, since commit:33ea2646b98adb49ae2e1781753bf22d33729ac0. Notes: Merged: https://github.com/ruby/ruby/pull/11493
2024-08-28Set encoding index correctlyAlexander Momchilov
Notes: Merged: https://github.com/ruby/ruby/pull/11445
2024-08-27Add RB_DEFAULT_PARSER preprocessor macroAlan Wu
This way there is one place to change for switching the default. This also allows for building the same commit with different cppflags. Notes: Merged: https://github.com/ruby/ruby/pull/11473 Merged-By: XrXr
2024-08-21[PRISM] Potentially enable coverage on the main scriptKevin Newton
Notes: Merged: https://github.com/ruby/ruby/pull/11424
2024-08-15[PRISM] Use src encoding not ext encodingKevin Newton
Notes: Merged: https://github.com/ruby/ruby/pull/11386
2024-08-14[PRISM] Trigger moreswitches off shebangKevin Newton
Notes: Merged: https://github.com/ruby/ruby/pull/11378
2024-07-24Move RUBY_FREE_AT_EXIT check earlierPeter Zhu
Things that exit early, like `ruby -v`, could not use RUBY_FREE_AT_EXIT because the check for RUBY_FREE_AT_EXIT was not executed. Notes: Merged: https://github.com/ruby/ruby/pull/11230
2024-07-19[PRISM] Define DATA constant when parsing stdin and __END__Kevin Newton
Notes: Merged: https://github.com/ruby/ruby/pull/11207
2024-07-18[PRISM] Do not respect xflag when eflag is setKevin Newton
Notes: Merged: https://github.com/ruby/ruby/pull/11197
2024-07-05Revert "Load external GC using command line argument"Peter Zhu
This reverts commit 8ddb1110c283c5cb59b6582383f36fdbcc43ab19.
2024-06-24Fix `--debug-frozen-string-literal` to not apply ↵Jean Boussier
`--disable-frozen-string-literal` [Feature #20205] This was an undesired side effect. Now that this value is a triplet, we can't assume it's disabled by default.
2024-06-21Load external GC using command line argumentPeter Zhu
This commit changes the external GC to be loaded with the `--gc-library` command line argument instead of the RUBY_GC_LIBRARY_PATH environment variable because @nobu pointed out that loading binaries using environment variables can pose a security risk.
2024-06-12[Bug #20562] Categorize `RUBY_FREE_AT_EXIT` warning as experimentalNobuyoshi Nakada
2024-06-07Remove prism compiler warningKevin Newton
2024-06-05Don't add `+YJIT` to `RUBY_DESCRIPTION` until it's actually enabledJean Boussier
If you start Ruby with `--yjit-disable`, the `+YJIT` shouldn't be added until `RubyVM::YJIT.enable` is actually called. Otherwise it's confusing in crash reports etc.
2024-05-20[PRISM] Respect eval coverage settingKevin Newton
2024-05-03Rename `vast` to `ast_value`yui-knk
There is an English word "vast". This commit changes the name to be more clear name to avoid confusion.
2024-04-26[Universal parser] Decouple IMEMO from rb_ast_tHASUMI Hitoshi
This patch removes the `VALUE flags` member from the `rb_ast_t` structure making `rb_ast_t` no longer an IMEMO object. ## Background We are trying to make the Ruby parser generated from parse.y a universal parser that can be used by other implementations such as mruby. To achieve this, it is necessary to exclude VALUE and IMEMO from parse.y, AST, and NODE. ## Summary (file by file) - `rubyparser.h` - Remove the `VALUE flags` member from `rb_ast_t` - `ruby_parser.c` and `internal/ruby_parser.h` - Use TypedData_Make_Struct VALUE which wraps `rb_ast_t` `in ast_alloc()` so that GC can manage it - You can retrieve `rb_ast_t` from the VALUE by `rb_ruby_ast_data_get()` - Change the return type of `rb_parser_compile_XXXX()` functions from `rb_ast_t *` to `VALUE` - rb_ruby_ast_new() which internally `calls ast_alloc()` is to create VALUE vast outside ruby_parser.c - `iseq.c` and `vm_core.h` - Amend the first parameter of `rb_iseq_new_XXXX()` functions from `rb_ast_body_t *` to `VALUE` - This keeps the VALUE of AST on the machine stack to prevent being removed by GC - `ast.c` - Almost all change is replacement `rb_ast_t *ast` with `VALUE vast` (sorry for the big diff) - Fix `node_memsize()` - Now it includes `rb_ast_local_table_link`, `tokens` and script_lines - `compile.c`, `load.c`, `node.c`, `parse.y`, `proc.c`, `ruby.c`, `template/prelude.c.tmpl`, `vm.c` and `vm_eval.c` - Follow-up due to the above changes - `imemo.{c|h}` - If an object with `imemo_ast` appears, considers it a bug Co-authored-by: Nobuyoshi Nakada <[email protected]>
2024-04-25[PRISM] Raise LoadError when file cannot be readKevin Newton
2024-04-16Eliminate usage of OBJ_FREEZE_RAWJean Boussier
Previously it would bypass the `FL_ABLE` check, but since shapes introduction, it started having a different behavior than `OBJ_FREEZE`, as it would onyl set the `FL_FREEZE` flag, but not update the shape. I have no indication of this causing a bug yet, but it seems like a trap waiting to happen.
2024-04-15[Universal parser] DeVALUE of p->debug_lines and ast->body.script_linesHASUMI Hitoshi
This patch is part of universal parser work. ## Summary - Decouple VALUE from members below: - `(struct parser_params *)->debug_lines` - `(rb_ast_t *)->body.script_lines` - Instead, they are now `rb_parser_ary_t *` - They can also be a `(VALUE)FIXNUM` as before to hold line count - `ISEQ_BODY(iseq)->variable.script_lines` remains VALUE - In order to do this, - Add `VALUE script_lines` param to `rb_iseq_new_with_opt()` - Introduce `rb_parser_build_script_lines_from()` to convert `rb_parser_ary_t *` into `VALUE` ## Other details - Extend `rb_parser_ary_t *`. It previously could only store `rb_parser_ast_token *`, now can store script_lines, too - Change tactics of building the top-level `SCRIPT_LINES__` in `yycompile0()` - Before: While parsing, each line of the script is added to `SCRIPT_LINES__[path]` - After: After `yyparse(p)`, `SCRIPT_LINES__[path]` will be built from `p->debug_lines` - Remove the second parameter of `rb_parser_set_script_lines()` to make it simple - Introduce `script_lines_free()` to be called from `rb_ast_free()` because the GC no longer takes care of the script_lines - Introduce `rb_parser_string_deep_copy()` in parse.y to maintain script_lines when `rb_ruby_parser_free()` called - With regard to this, please see *Future tasks* below ## Future tasks - Decouple IMEMO from `rb_ast_t *` - This lifts the five-members-restriction of Ruby object, - So we will be able to move the ownership of the `lex.string_buffer` from parser to AST - Then we remove `rb_parser_string_deep_copy()` to make the whole thing simple
2024-04-07Merge `push_include` and `ruby_push_include`Nobuyoshi Nakada
2024-04-07Merge `push_include_cygwin` into `push_include`Nobuyoshi Nakada
2024-04-07Remove `translit_char`Nobuyoshi Nakada
It has been used only for DOSISH other than Windows.
2024-04-06[Feature #20329] Separate additional flags from main dump optionsNobuyoshi Nakada
Additional flags are comma separated list preceeded by `-` or `+`. Before: ```sh $ ruby --dump=insns+without_opt ``` After: ```sh $ ruby --dump=insns-opt,-optimize ``` At the same time, `parsetree_with_comment` is split to `parsetree` option and additional `comment` flag. Before: ```sh $ ruby --dump=parsetree_with_comment ``` After: ```sh $ ruby --dump=parsetree,+comment ``` Also flags can be separate `--dump`. ```sh $ ruby --dump=parsetree --dump=+comment --dump=+error_tolerant ``` Ineffective flags are ignored silently. ```sh $ ruby --dump=parsetree --dump=+comment --dump=+error_tolerant ```
2024-04-06[Feature #20329] Clean up dump sub-optionsNobuyoshi Nakada
Restructure `insns_without_opt` and `parsetree_with_comment` as `insns+without_opt` and `parsetree+with_comment` respectively, like `+error-tolerant`.