Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync mmtk branch with Ruby master #65

Closed
wants to merge 693 commits into from

Conversation

eileencodes
Copy link
Collaborator

I'm not sure what this project's preference is for syncing with master, but I had already fixed the conflicts on my copy of CRuby + mmtk so I figured I'd send a PR.

kddnewton and others added 30 commits April 1, 2024 18:13
In the past, it was imemo. However a075c55 changed it.
Therefore no need to use `VALUE` for the first field.
…nd when clause duplication

This commit simplifies warnings for hash keys duplication and when clause duplication,
based on the discussion of https://bugs.ruby-lang.org/issues/20331.
Warnings are reported only when strings are same to ohters.
Introduce a new mkmf option `--target-rbconfig` to specify the RbConfig
file for the deployment target platform. This option is useful for
cross-compiling Ruby extensions without faking the global top-level
`RbConfig` constant.
No parser semantic value types are `VALUE` then no need to
use imemo for managing semantic value stack anymore.
* YJIT: A64: Use ADDS/SUBS/CMP (immediate) when possible

We were loading 1 into a register and then doing ADDS/SUBS previously.
That was particularly bad since those come up in fixnum operations.

```diff
   # integer left shift with rhs=1
-  mov x11, ruby#1
-  subs x11, x1, x11
+  subs x11, x1, ruby#1
   lsl x12, x11, ruby#1
   asr x13, x12, ruby#1
   cmp x13, x11
-  b.ne #0x106ab60f8
-  mov x11, ruby#1
-  adds x12, x12, x11
+  b.ne #0x10903a0f8
+  adds x12, x12, ruby#1
   mov x1, x12
```

Note that it's fine to cast between i64 and u64 since the bit pattern is
preserved, and the add/sub themselves don't care about the signedness of
the operands.

CMP is just another mnemonic for SUBS.

* YJIT: A64: Split asm.mul() with immediates properly

There is in fact no MUL on A64 that takes an immediate, so this
instruction was using the wrong split method. No current usages of this
form in YJIT.

---------

Co-authored-by: Maxime Chevalier-Boisvert <[email protected]>
tompng and others added 27 commits April 10, 2024 16:52
(ruby/irb#824)

* Command is not a method

* Fix command test

* Implement non-method command name completion

* Add test for ExtendCommandBundle.def_extend_command

* Add helper method install test

* Remove spaces in command input parse

* Remove command arg unquote in help command

* Simplify Statement and handle execution in IRB::Irb

* Tweak require, const name

* Always install CommandBundle module to main object

* Remove considering local variable in command or expression check

* Remove unused method, tweak

* Remove outdated comment for help command arg

Co-authored-by: Stan Lo <[email protected]>

---------

ruby/irb@8fb776e379

Co-authored-by: Stan Lo <[email protected]>
turbo_tests 2.1.1 adds json to its dependency and the current bundler
does not take the standard library json and fails to build as a gem
before the installation.
89cfc15 made this event dispatch to pass `Qundef`
to user defined callback method by mistake.
This commit fix it to be `nil`.
and declare it will be removed soon.

ddtrace is still referes the API and build was failed.
See DataDog/dd-trace-rb#3578

Maybe threre are only few users of this C-API now so we can remove
it soon.
`st_init_table_with_size` is already defined in universal_parser.c.
The `rb_fstring(rb_enc_str_new())` pattern is inneficient because:

- It passes a mutable string to `rb_fstring` so if it has to be interned
  it will first be duped.
- It an equivalent interned string already exists, we allocated the string
  for nothing.

With `rb_enc_interned_str` we either directly get the pre-existing string
with 0 allocations, or efficiently directly intern the one we create
without first duping it.
Although glibc `ptsname_r` man page mentions Tru64 and HP-UX, this
function appears to be declared obsolete on both.
The backtick method recieves a frozen string unless it is interpolated.

Otherwise the string held in the ISeq could be mutated by a custom
backtick method.
The `rb_fstring(rb_enc_str_new())` pattern is inefficient because:

- It passes a mutable string to `rb_fstring` so if it has to be interned it will first be duped.
- It an equivalent interned string already exists, we allocated the string for nothing.

With `rb_enc_interned_str` we either directly get the pre-existing string with 0 allocations,
or efficiently directly intern the one we create without first duping it.
…0498)

This is best understood by looking at the change to the output:

```diff
  # Insn: 0002 opt_and (stack_size: 2)
  - mov rax, rsi
  - and rax, rdi
  - mov rsi, rax
  + and rsi, rdi
```

It's a bit awkward to match against due to how stack operands are
lowered, but hey, it's nice to save the 2 unnecessary MOVs.
ptr is already of the VALUE type, so we don't need to cast it.
@wks
Copy link

wks commented Apr 12, 2024

I synchronise this branch with master from time to time. I usually do it once a week, but I think I forgot to do it recently.

Thank you for fixing the conflicts. But since I have already merged several other PRs, I manually merged with the master branch of https://github.com/ruby/ruby/, using this PR as a reference for resolving conflicts. The end result only differs from this PR in one important place:

diff --git a/gc.c b/gc.c
index 1ddfb654fa..33384625d9 100644
--- a/gc.c
+++ b/gc.c
@@ -7641,8 +7641,8 @@ show_mark_ticks(void)
 static void
 gc_mark_roots(rb_objspace_t *objspace, const char **categoryp)
 {
-    rb_execution_context_t *ec = GET_EC();
-    rb_vm_t *vm = rb_ec_vm_ptr(ec);
+    rb_execution_context_t *ec;
+    rb_vm_t *vm;
 
 #if USE_MMTK
     const bool mmtk_enabled_local = rb_mmtk_enabled_p(); // Allows control-flow sensitive analysis of ec etc

When using MMTk, it is the GC thread that calls gc_mark_roots. In my current implementation, GC threads are directly created using Rust's standard library, and do not have execution contexts. Therefore, calling GET_EC() in a GC thread will crash. You can see similar patterns in other places, too, such as commenting out assertions that may use GET_EC().

@wks wks closed this Apr 12, 2024
@eileencodes eileencodes deleted the mmtk-with-master branch April 12, 2024 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.