Commit graph

831 commits

Author SHA1 Message Date
Nobuyoshi Nakada
c843afbf6f Chomp last punctuations from descriptions for -h
The following parts will not be shown for `-h` option.  And not to
reach 80 columns.  Some terminal emulators (Windows command prompt at
least) wrap the cursor to the next line when reaching the rightmost
column, before exceeding.
2024-03-14 01:19:57 +09:00
Nobuyoshi Nakada
dec2a8191c
--dump=prism_parsetree is no longer provided
Since it did not make sense without `--parser=prism` option, just a
duplication.  Now it is `--parser=prism --dump=parsetree`.
2024-03-13 11:28:50 +09:00
Takashi Kokubun
22708be0d7 Revisions for #10198
This fixes some inconsistencies introduced by that PR.
2024-03-12 13:44:48 -07:00
Burdette Lamar
19da3b4ecf
Revisions for help text (#10198) 2024-03-12 15:14:56 -04:00
Kevin Newton
a6dac9bb4f [PRISM] Parse stdin on CLI with prism 2024-03-11 12:51:32 -04:00
Jean Boussier
d4f3dcf4df Refactor VM root modules
This `st_table` is used to both mark and pin classes
defined from the C API. But `vm->mark_object_ary` already
does both much more efficiently.

Currently a Ruby process starts with 252 rooted classes,
which uses `7224B` in an `st_table` or `2016B` in an `RArray`.

So a baseline of 5kB saved, but since `mark_object_ary` is
preallocated with `1024` slots but only use `405` of them,
it's a net `7kB` save.

`vm->mark_object_ary` is also being refactored.

Prior to this changes, `mark_object_ary` was a regular `RArray`, but
since this allows for references to be moved, it was marked a second
time from `rb_vm_mark()` to pin these objects.

This has the detrimental effect of marking these references on every
minors even though it's a mostly append only list.

But using a custom TypedData we can save from having to mark
all the references on minor GC runs.

Addtionally, immediate values are now ignored and not appended
to `vm->mark_object_ary` as it's just wasted space.
2024-03-06 15:33:43 -05:00
Kevin Newton
f9d5c604c8 [PRISM] Use new command line option flags 2024-02-29 12:05:19 -05:00
Kevin Newton
f8355e88d6 [PRISM] Do not load -r until we check if main script can be read 2024-02-28 12:42:57 -05:00
Kevin Newton
1cef366319 [PRISM] Factor in CLI options for prism 2024-02-28 11:09:43 -05:00
Nobuyoshi Nakada
835fa98a62 Update warning flags before dump 2024-02-20 23:56:07 +09:00
Kevin Newton
8414c26f0d [PRISM] Make prism compiler warning experimental 2024-02-16 11:56:48 -05:00
Nobuyoshi Nakada
81752d2097
Abort when streaming code from stdin with Prism
Do not read STDIN as a String instance.
2024-02-16 15:26:10 +09:00
Nobuyoshi Nakada
a64e93a896
Use ID without cache and fix conversion of offset 2024-02-16 15:26:10 +09:00
Nobuyoshi Nakada
e0d068aa9c
Extract process_options_global_setup 2024-02-16 15:26:10 +09:00
Nobuyoshi Nakada
839ccad20b
Extract functions depending on --parser option 2024-02-16 15:26:09 +09:00
Nobuyoshi Nakada
574312dead Extract show_help function 2024-02-16 11:20:29 +09:00
Nobuyoshi Nakada
7ac8d3d6ee Dispose AST before exit by yydebug 2024-02-16 11:20:29 +09:00
Yusuke Endoh
25d74b9527 Do not include a backtick in error messages and backtraces
[Feature #16495]
2024-02-15 18:42:31 +09:00
Kevin Newton
9933377c34 [PRISM] Correctly hook up line numbers for eval 2024-02-14 15:29:26 -05:00
Nobuyoshi Nakada
84d8dbe7a5 Enable redefinition check for rbinc methods 2024-02-12 11:51:06 -08:00
Kevin Newton
4a40364c62 [PRISM] Run opt init before parsing 2024-02-08 14:36:39 -05:00
Kevin Newton
3ecfc3e33e [PRISM] Support the DATA constant 2024-02-08 14:36:29 -05:00
Kevin Newton
71f16d498d Raise errors for dumping prism parse tree 2024-01-31 14:54:39 -05:00
Kevin Newton
610636fd6b [PRISM] Mirror iseq APIs
Before this commit, we were mixing a lot of concerns with the prism
compile between RubyVM::InstructionSequence and the general entry
points to the prism parser/compiler.

This commit makes all of the various prism-related APIs mirror
their corresponding APIs in the existing parser/compiler. This means
we now have the correct frame naming, and it's much easier to follow
where the logic actually flows. Furthermore this consolidates a lot
of the prism initialization, making it easier to see where we could
potentially be raising errors.
2024-01-31 13:41:36 -05:00
Matt Valentine-House
4592fdc545 [Prism] path and script name are not the same
When loading Ruby from a file, or parsing using
RubyVM::InstructionSequence.
2024-01-22 15:15:32 -08:00
Kevin Newton
6bcbb9a02b Make prism respect dump_without_opt 2024-01-22 10:18:41 -05:00
Nobuyoshi Nakada
6215b5ba98 Fix off-by-one error of argc
Fix ruby/ruby#9562
2024-01-17 18:26:39 +09:00
Nobuyoshi Nakada
9ba2558b76 Fix possible out-of-bounds access 2024-01-13 23:20:05 +09:00
Takashi Kokubun
64c52cd1c2 RJIT: Add --rjit-trace to allow TracePoint during JIT 2023-12-21 21:05:13 -08:00
HParker
7ef90b3978 Correct free_on_exit env var to free_at_exit 2023-12-20 14:36:32 +09:00
Aaron Patterson
df0bfde2b2 We need to load builtins so that they work
Before this commit no methods defined in Ruby were being loaded. For
example `class` or `tap` methods would not exist.

[ruby-core:115793] [Bug #20073]
2023-12-19 08:53:52 -08:00
Matt Valentine-House
893fe30ef2 [PRISM] Fix crash when --parser=prism called with stdin
[Bug #20071]

Currently Ruby crashes when the --parser=prism flag is used either with
no input, or with input that is being redirected from stdin. So all of
the following will crash

ruby --parser=prism
ruby --parser=prism < test_code.rb
cat test_code.rb | ruby --parser=prism

This commit checks whether the input is assumed to be from stdin, and
then processes that as a file.

This will fix the second and third case above, but will cause a slight
behavioural changes for the first case - Ruby will treat stdin as an
empty file in this case and exit, rather than waiting for data to be
piped into stdin.
2023-12-18 19:44:44 +00:00
Nobuyoshi Nakada
2f595c744e
Adjust styles [ci skip] 2023-12-17 00:21:00 +09:00
Adam Hess
a604fe4262 update message to clarify compiler, not parser
Co-authored-by: Ufuk Kayserilioglu <ufuk@paralaus.com>
2023-12-15 13:42:19 -05:00
HParker
55326a915f Introduce --parser runtime flag
Introduce runtime flag for specifying the parser,

```
ruby --parser=prism
```

also update the description:

```
$ ruby --parser=prism --version
ruby 3.3.0dev (2023-12-08T04:47:14Z add-parser-runtime.. 0616384c9f) +PRISM [x86_64-darwin23]
```

[Bug #20044]
2023-12-15 13:42:19 -05:00
Takashi Kokubun
e282d7b880 Avoid warning --jit when only YJIT is enabled 2023-12-13 00:05:12 -08:00
Adam Hess
6816e8efcf Free everything at shutdown
when the RUBY_FREE_ON_SHUTDOWN environment variable is set, manually free memory at shutdown.

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
2023-12-07 15:52:35 -05:00
HParker
b8b319dd1a Revert "allow enabling Prism via flag or env var"
This reverts commit 9b76c7fc89.
2023-12-06 10:21:12 +09:00
Nobuyoshi Nakada
c146da50bd
Adjust styles [ci skip] 2023-12-06 09:43:10 +09:00
HParker
9b76c7fc89 allow enabling Prism via flag or env var
Enable Prism using either --prism

    ruby --prism test.rb

or via env var

    RUBY_PRISM=1 ruby test.rb
2023-12-05 12:17:14 -05:00
Nobuyoshi Nakada
2e8a4470ae
Remove rb_libruby_selfpath for MJIT 2023-12-04 10:32:21 +09:00
Kevin Newton
ec86b2eb39
[prism] Update to use new options APIs 2023-11-03 10:13:50 -04:00
Takashi Kokubun
ad4f973ecd
YJIT: Always define method codegen table at boot (#8807) 2023-11-02 09:15:48 -07:00
Kevin Newton
55b81e419f
Use new prism prettyprint APIs 2023-10-26 15:23:46 -04:00
Jemma Issroff
2573d56884 [PRISM] Change --dump keyword to prism_parsetree 2023-10-26 13:29:04 -03:00
Jemma Issroff
8f71a5c530 [PRISM] Move scope_node itself to CRuby, create prism_compile.h 2023-10-25 18:18:35 -03:00
Takashi Kokubun
6beb09c2c9
YJIT: Add RubyVM::YJIT.enable (#8705) 2023-10-19 10:54:35 -07:00
Koichi Sasada
c9990c8d0f "+MN" in description
If `RUBY_MN_THREADS=1` is given, this patch shows `+MN` in
`RUBY_DESCRIPTION` like:

```
$ RUBY_MN_THREADS=1 ./miniruby  --yjit -v
ruby 3.3.0dev (2023-10-17T04:10:14Z master 908f8fffa2) +YJIT +MN [x86_64-linux]
```

Before this patch, a warning is displayed if `$VERBOSE` is given.
However it can make troubles with tests (with `$VERBOSE`), do not
show any warning with a MN threads configuration.
2023-10-17 17:43:52 +09:00
Jemma Issroff
d705885286
[PRISM] Add --dump=prism mode (#8643) 2023-10-13 12:24:40 -07:00
Koichi Sasada
be1bbd5b7d M:N thread scheduler for Ractors
This patch introduce M:N thread scheduler for Ractor system.

In general, M:N thread scheduler employs N native threads (OS threads)
to manage M user-level threads (Ruby threads in this case).
On the Ruby interpreter, 1 native thread is provided for 1 Ractor
and all Ruby threads are managed by the native thread.

From Ruby 1.9, the interpreter uses 1:1 thread scheduler which means
1 Ruby thread has 1 native thread. M:N scheduler change this strategy.

Because of compatibility issue (and stableness issue of the implementation)
main Ractor doesn't use M:N scheduler on default. On the other words,
threads on the main Ractor will be managed with 1:1 thread scheduler.

There are additional settings by environment variables:

`RUBY_MN_THREADS=1` enables M:N thread scheduler on the main ractor.
Note that non-main ractors use the M:N scheduler without this
configuration. With this configuration, single ractor applications
run threads on M:1 thread scheduler (green threads, user-level threads).

`RUBY_MAX_CPU=n` specifies maximum number of native threads for
M:N scheduler (default: 8).

This patch will be reverted soon if non-easy issues are found.

[Bug #19842]
2023-10-12 14:47:01 +09:00