summaryrefslogtreecommitdiff
path: root/ruby.c
AgeCommit message (Collapse)Author
2025-12-24Remove extra helpNARUSE, Yui
2025-12-24Reapply "Extract `ruby_api_version_name`"NARUSE, Yui
This reverts commit ba2f6972193cdbd7c1e77e26212513e47926b115. Box already used ruby_api_version_name.
2025-12-24Revert "Add link to Ruby options doc in help text"NARUSE, Yui
This reverts commit 31ff07ed1eb05d01f7da3c017d542137a3db1e94. * Don't add a test which only runs on production release * https://github.com/ruby/actions/actions/runs/20486784889/job/58870959976 * Don't add a new line to `ruby --help` * https://github.com/ruby/ruby/pull/14142#issuecomment-3689829564
2025-12-24Revert "Extract `ruby_api_version_name`"NARUSE, Yui
This reverts commit 9b576cd6255aba97e5e2f55f4b09f00c7dd0e839.
2025-11-27Update man and help: -d option set $VERBOSE to trueKouhei Yanagita
2025-11-18ZJIT: add support for lazy `RubyVM::ZJIT.enable`Godfrey Chan
This implements Shopify#854: - Splits boot-time and enable-time initialization, tracks progress with `InitializationState` enum - Introduces `RubyVM::ZJIT.enable` Ruby method for enabling the JIT lazily, if not already enabled - Introduces `--zjit-disable` flag, which can be used alongside the other `--zjit-*` flags but prevents enabling the JIT at boot time - Adds ZJIT infra to support JIT hooks, but this is not currently exercised (Shopify/ruby#667) Left for future enhancements: - Support kwargs for overriding the CLI flags in `RubyVM::ZJIT.enable` Closes Shopify#854
2025-11-10Allow --jit to mean zjit if yjit isn't definedRandy Stauner
The --help output suggests this should work as ZJIT is labeled as the default if YJIT isn't enabled.
2025-11-07renaming internal data structures and functions from namespace to boxSatoshi Tagomori
2025-10-22Fix memory leak when RUBYOPT is invalidPeter Zhu
When RUBYOPT is invalid, it raises an error which causes moreswitches to leak memory. It can be seen when building with LSAN enabled: $ RUBY_FREE_AT_EXIT=1 RUBYOPT=f ruby ruby: invalid option -f (-h will show valid options) (RuntimeError) Direct leak of 16 byte(s) in 1 object(s) allocated from: #0 0x618cef8efa23 in malloc (miniruby+0x64a23) #1 0x618cefa0e8d8 in rb_gc_impl_malloc gc/default/default.c:8182:5 #2 0x618cef9f7f01 in ruby_xmalloc2_body gc.c:5182:12 #3 0x618cef9f7eac in ruby_xmalloc2 gc.c:5176:34 #4 0x618cefb547b2 in moreswitches ruby.c:919:18 #5 0x618cefb526fe in process_options ruby.c:2350:9 #6 0x618cefb524ac in ruby_process_options ruby.c:3202:12 #7 0x618cef9dc11f in ruby_options eval.c:119:16 #8 0x618cef8f2fb5 in rb_main main.c:42:26 #9 0x618cef8f2f59 in main main.c:62:12
2025-10-07Initialize the main namespace after loading builtin librariesSatoshi Tagomori
* For having the common set of loaded libraries between root and main namespaces * To have the consistent $LOADED_FEATURES in the main namespace
2025-09-29Update current namespace management by using control frames and lexical contextsSatoshi Tagomori
to fix inconsistent and wrong current namespace detections. This includes: * Moving load_path and related things from rb_vm_t to rb_namespace_t to simplify accessing those values via namespace (instead of accessing either vm or ns) * Initializing root_namespace earlier and consolidate builtin_namespace into root_namespace * Adding VM_FRAME_FLAG_NS_REQUIRE for checkpoints to detect a namespace to load/require files * Removing implicit refinements in the root namespace which was used to determine the namespace to be loaded (replaced by VM_FRAME_FLAG_NS_REQUIRE) * Removing namespaces from rb_proc_t because its namespace can be identified by lexical context * Starting to use ep[VM_ENV_DATA_INDEX_SPECVAL] to store the current namespace when the frame type is MAGIC_TOP or MAGIC_CLASS (block handlers don't exist in this case)
2025-09-05ruby.c: Fallback FEATURE_BIT(jit) to FEATURE_BIT(zjit)Takashi Kokubun
if it's the only JIT enabled in the build
2025-08-14ZJIT: Look for RUBY_ZJIT_ENABLE in combo build with YJITAlan Wu
2025-08-14Extract `ruby_api_version_name`Nobuyoshi Nakada
2025-08-13Add link to Ruby options doc in help textPeter Zhu
Adds link to https://docs.ruby-lang.org/en/master/ruby/options_md.html in Ruby help text (-h and --help).
2025-08-11YJIT, ZJIT: Fix JITs compiling prelude (#14171)Takashi Kokubun
2025-07-30ZJIT: Prepare for sharing JIT hooks with ZJIT (#14044)Takashi Kokubun
2025-07-28YJIT: Call YJIT hooks before enabling YJIT (#14032)Takashi Kokubun
2025-06-28Stop setting TMP_RUBY_PREFIX during preludeÉtienne Barrié
It's unnecessary now that builtin-loader supports sub-libraries: 9faa9ced9640d23fc5dc1efd635f6b8ebc1a3ceb
2025-06-23Mark RClass instance that may be namespaced with RCLASS_NAMESPACEABLEJean Boussier
2025-05-11namespace on readSatoshi Tagomori
2025-04-29ZJIT: Handle ZJIT options properly (#13197)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2025-04-18Resurrect yjit_hookTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Implement Options as part of ZJITStateTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Fix the handling of flagsTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Disable yjit_hook builtin for nowTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Hook zjit_initTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Call libzjit from CRubyTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
2025-04-18Add --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 <jean.boussier@gmail.com> 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 <maximecb@ruby-lang.org>
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