8000 Merge pull request #4 from Shopify/pass-self-type · github/ruby@d1eade0 · GitHub
[go: up one dir, main page]

Skip to content

Commit d1eade0

Browse files
authored
Merge pull request #4 from Shopify/pass-self-type
Pass self type through method calls
2 parents c66460a + 3c04d6d commit d1eade0

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ YJIT - Yet Another Ruby JIT
55

66
YJIT is a lightweight, minimalistic Ruby JIT built inside the CRuby/MRI binary.
77
It lazily compiles code using a Basic Block Versioning (BBV) architecture. The target use case is that of servers running
8-
Ruby on Rails, an area where CRuby's MJIT has not yet managed to deliver speedups.
8+
Ruby on Rails, an area where CRuby's MJIT has not yet managed to deliver speedups.
99
To simplify development, we currently support only MacOS and Linux on x86-64, but an ARM64 backend
1010
is part of future plans.
1111
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:
3535
```
3636
git clone https://github.com/Shopify/ruby.git yjit
3737
cd yjit
38-
git checkout yjit
3938
```
4039

4140
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).
4241

4342
```
44-
autoconf
43+
./autogen.sh
4544
./configure cppflags=-DRUBY_DEBUG --prefix=$HOME/.rubies/ruby-yjit
4645
make -j16 install
4746
```

yjit_codegen.c

Lines changed: 5 additions & 3 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -524,11 +524,11 @@ static codegen_status_t
524524
gen_putself(jitstate_t* jit, ctx_t* ctx)
525525
{
526526
// Load self from CFP
527-
mov(cb, RAX, member_opnd(REG_CFP, rb_control_frame_t, self));
527+
mov(cb, REG0, member_opnd(REG_CFP, rb_control_frame_t, self));
528528

529529
// Write it on the stack
530530
x86opnd_t stack_top = ctx_stack_push_self(ctx);
531-
mov(cb, stack_top, RAX);
531+
mov(cb, stack_top, REG0);
532532

533533
return YJIT_KEEP_COMPILING;
534534
}
@@ -1792,11 +1792,13 @@ gen_oswb_iseq(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const r
17921792
// Create a context for the callee
17931793
ctx_t callee_ctx = DEFAULT_CTX;
17941794

1795-
// Set the argument type in the callee's context
1795+
// Set the argument types in the callee's context
17961796
for (int32_t arg_idx = 0; arg_idx < argc; ++arg_idx) {
17971797
val_type_t arg_type = ctx_get_opnd_type(ctx, OPND_STACK(argc - arg_idx - 1));
17981798
ctx_set_local_type(&callee_ctx, arg_idx, arg_type);
17991799
}
1800+
val_type_t recv_type = ctx_get_opnd_type(ctx, OPND_STACK(argc));
1801+
ctx_set_opnd_type(&callee_ctx, OPND_SELF, recv_type);
18001802

18011803
// Pop arguments and receiver in return context, push the return value
18021804
// After the return, the JIT and interpreter SP will match up

yjit_core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ Set the type of an instruction operand
160160
*/
161161
void ctx_set_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type)
162162
{
163-
RUBY_ASSERT(opnd.idx < ctx->stack_size);
164-
165163
if (opnd.is_self) {
166164
ctx->self_type = type;
167165
return;
@@ -170,6 +168,7 @@ void ctx_set_opnd_type(ctx_t* ctx, insn_opnd_t opnd, val_type_t type)
170168
if (ctx->stack_size > MAX_TEMP_TYPES)
171169
return;
172170

171+
RUBY_ASSERT(opnd.idx < ctx->stack_size);
173172
temp_mapping_t mapping = ctx->temp_mapping[ctx->stack_size - 1 - opnd.idx];
174173

175174
switch (mapping.kind)

0 commit comments

Comments
 (0)
0