Pass self type through method calls

This commit is contained in:
Maxime Chevalier-Boisvert 2021-04-20 16:14:35 -04:00 коммит произвёл Alan Wu
Родитель ef5cfcae0d
Коммит 60496b6666
3 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -5,7 +5,7 @@ YJIT - Yet Another Ruby JIT
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:
```
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
```

Просмотреть файл

@ -525,11 +525,11 @@ static codegen_status_t
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
// 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

Просмотреть файл

@ -160,8 +160,6 @@ Set the type of an instruction operand
*/
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)
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)