[前][次][番号順一覧][スレッド一覧]

ruby-changes:68957

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:19:27 +0900 (JST)
Subject: [ruby-changes:68957] 60496b6666 (master): Pass self type through method calls

https://git.ruby-lang.org/ruby.git/commit/?id=60496b6666

From 60496b6666765ab8cb63816ca1d525fcfbcf7abc Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@s...>
Date: Tue, 20 Apr 2021 16:14:35 -0400
Subject: Pass self type through method calls

---
 README.md      | 5 ++---
 yjit_codegen.c | 8 +++++---
 yjit_core.c    | 3 +--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index f0590a8c24..312191c85e 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ YJIT - Yet Another Ruby JIT https://github.com/ruby/ruby/blob/trunk/README.md#L5
 
 YJIT is a lightweight, minimalistic Ruby JIT built inside the CRuby/MRI binary.
 It lazily compiles code using a Basic Block Versioning (BBV) architecture. The target use case is that of servers running
-Ruby on Rails, an area where CRuby's MJIT has not yet managed to deliver speedups. 
+Ruby on Rails, an area where CRuby's MJIT has not yet managed to deliver speedups.
 To simplify development, we currently support only MacOS and Linux on x86-64, but an ARM64 backend
 is part of future plans.
 This project is open source and falls under the same license as CRuby.
@@ -35,13 +35,12 @@ Start by cloning the `yjit` branch of the `Shopify/ruby` repository: https://github.com/ruby/ruby/blob/trunk/README.md#L35
 ```
 git clone https://github.com/Shopify/ruby.git yjit
 cd yjit
-git checkout yjit
 ```
 
 The YJIT `ruby` binary can be built with either GCC or Clang. We recommend enabling debug symbols so that assertions are enabled during development as this makes debugging easier. More detailed build instructions are provided in the [Ruby README](https://github.com/ruby/ruby#how-to-compile-and-install).
 
 ```
-autoconf
+./autogen.sh
 ./configure cppflags=-DRUBY_DEBUG --prefix=$HOME/.rubies/ruby-yjit
 make -j16 install
 ```
diff --git a/yjit_codegen.c b/yjit_codegen.c
index 8cc3d5c8c8..9f5b0dde1d 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -525,11 +525,11 @@ static codegen_status_t https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L525
 gen_putself(jitstate_t* jit, ctx_t* ctx)
 {
     // Load self from CFP
-    mov(cb, RAX, member_opnd(REG_CFP, rb_control_frame_t, self));
+    mov(cb, REG0, member_opnd(REG_CFP, rb_control_frame_t, self));
 
     // Write it on the stack
     x86opnd_t stack_top = ctx_stack_push_self(ctx);
-    mov(cb, stack_top, RAX);
+    mov(cb, stack_top, REG0);
 
     return YJIT_KEEP_COMPILING;
 }
@@ -1792,11 +1792,13 @@ gen_oswb_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1792
     // Create a context for the callee
     ctx_t callee_ctx = DEFAULT_CTX;
 
-    // Set the argument type in the callee's context
+    // Set the argument types in the callee's context
     for (int32_t arg_idx = 0; arg_idx < argc; ++arg_idx) {
         val_type_t arg_type = ctx_get_opnd_type(ctx, OPND_STACK(argc - arg_idx - 1));
         ctx_set_local_type(&callee_ctx, arg_idx, arg_type);
     }
+    val_type_t recv_type = ctx_get_opnd_type(ctx, OPND_STACK(argc));
+    ctx_set_opnd_type(&callee_ctx, OPND_SELF, recv_type);
 
     // Pop arguments and receiver in return context, push the return value
     // After the return, the JIT and interpreter SP will match up
diff --git a/yjit_core.c b/yjit_core.c
index 56450840cd..31ee57baf4 100644
--- a/yjit_core.c
+++ b/yjit_core.c
@@ -160,8 +160,6 @@ Set the type of an instruction operand https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L160
 */
 void ctx_set_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type)
 {
-    RUBY_ASSERT(opnd.idx < ctx->stack_size);
-
     if (opnd.is_self) {
         ctx->self_type = type;
         return;
@@ -170,6 +168,7 @@ void ctx_set_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type) https://github.com/ruby/ruby/blob/trunk/yjit_core.c#L168
     if (ctx->stack_size > MAX_TEMP_TYPES)
         return;
 
+    RUBY_ASSERT(opnd.idx < ctx->stack_size);
     temp_mapping_t mapping = ctx->temp_mapping[ctx->stack_size - 1 - opnd.idx];
 
     switch (mapping.kind)
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]