8000 Port OP_OPT_MOD, OP_OPT_STR_FREEZE and OP_OPT_STR_UMINUS (#165) · kddnewton/ruby@bb32584 · GitHub
[go: up one dir, main page]

Skip to content

Commit bb32584

Browse files
authored
Port OP_OPT_MOD, OP_OPT_STR_FREEZE and OP_OPT_STR_UMINUS (ruby#165)
* Implement OP_OPT_MOD * Implement OP_OPT_STR_FREEZE and OP_OPT_STR_UMINUS
1 parent bd1435a commit bb32584

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

yjit/src/codegen.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,16 +2872,15 @@ fn gen_opt_div(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &
28722872
// Delegate to send, call the method on the recv
28732873
return gen_opt_send_without_block(jit, ctx, cb);
28742874
}
2875-
2876-
VALUE rb_vm_opt_mod(VALUE recv, VALUE obj);
2875+
*/
28772876

28782877
fn gen_opt_mod(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &mut OutlinedCb) -> CodegenStatus
28792878
{
28802879
// Save the PC and SP because the callee may allocate bignums
28812880
// Note that this modifies REG_SP, which is why we do it first
2882-
jit_prepare_routine_call(jit, ctx, REG0);
2881+
jit_prepare_routine_call(jit, ctx, cb, REG0);
28832882

2884-
uint8_t *side_exit = get_side_exit(jit, ocb, ctx);
2883+
let side_exit = get_side_exit(jit, ocb, ctx);
28852884

28862885
// Get the operands from the stack
28872886
let arg1 = ctx.stack_pop(1);
@@ -2890,10 +2889,11 @@ fn gen_opt_mod(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &
28902889
// Call rb_vm_opt_mod(VALUE recv, VALUE obj)
28912890
mov(cb, C_ARG_REGS[0], arg0);
28922891
mov(cb, C_ARG_REGS[1], arg1);
2893-
call_ptr(cb, REG0, (void *)rb_vm_opt_mod);
2892+
let vm_mod = CodePtr::from(rb_vm_opt_mod as *mut u8);
2893+
call_ptr(cb, REG0, vm_mod);
28942894

28952895
// If val == Qundef, bail to do a method call
2896-
cmp(cb, RAX, imm_opnd(Qundef));
2896+
cmp(cb, RAX, imm_opnd(Qundef.as_i64()));
28972897
je_ptr(cb, side_exit);
28982898

28992899
// Push the return value onto the stack
@@ -2903,6 +2903,7 @@ fn gen_opt_mod(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &
29032903
KeepCompiling
29042904
}
29052905

2906+
/*
29062907
fn gen_opt_ltlt(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &mut OutlinedCb) -> CodegenStatus
29072908
{
29082909
// Delegate to send, call the method on the recv
@@ -2920,14 +2921,17 @@ fn gen_opt_empty_p(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, oc
29202921
// Delegate to send, call the method on the recv
29212922
return gen_opt_send_without_block(jit, ctx, cb);
29222923
}
2924+
*/
29232925

29242926
fn gen_opt_str_freeze(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &mut OutlinedCb) -> CodegenStatus
29252927
{
2928+
/*
29262929
if (!assume_bop_not_redefined(jit, STRING_REDEFINED_OP_FLAG, BOP_FREEZE)) {
29272930
return CantCompile;
29282931
}
2932+
*/
29292933

2930-
VALUE str = jit_get_arg(jit, 0);
2934+
let str = jit_get_arg(jit, 0);
29312935
jit_mov_gc_ptr(jit, cb, REG0, str);
29322936

29332937
// Push the return value onto the stack
@@ -2939,11 +2943,13 @@ fn gen_opt_str_freeze(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock,
29392943

29402944
fn gen_opt_str_uminus(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &mut OutlinedCb) -> CodegenStatus
29412945
{
2946+
/*
29422947
if (!assume_bop_not_redefined(jit, STRING_REDEFINED_OP_FLAG, BOP_UMINUS)) {
29432948
return CantCompile;
29442949
}
2950+
*/
29452951

2946-
VALUE str = jit_get_arg(jit, 0);
2952+
let str = jit_get_arg(jit, 0);
29472953
jit_mov_gc_ptr(jit, cb, REG0, str);
29482954

29492955
// Push the return value onto the stack
@@ -2953,6 +2959,7 @@ fn gen_opt_str_uminus(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock,
29532959
KeepCompiling
29542960
}
29552961

2962+
/*
29562963
fn gen_opt_not(jit: &mut JITState, ctx: &mut Context, cb: &mut CodeBlock, ocb: &mut OutlinedCb) -> CodegenStatus
29572964
{
29582965
return gen_opt_send_without_block(jit, ctx, cb);
@@ -5238,6 +5245,9 @@ fn get_gen_fn(opcode: VALUE) -> Option<CodeGenFn>
52385245
OP_OPT_LE => Some(gen_opt_le),
52395246
OP_OPT_GT => Some(gen_opt_gt),
52405247
OP_OPT_GE => Some(gen_opt_ge),
5248+
OP_OPT_MOD => Some(gen_opt_mod),
5249+
OP_OPT_STR_FREEZE => Some(gen_opt_str_freeze),
5250+
OP_OPT_STR_UMINUS => Some(gen_opt_str_uminus),
52415251

52425252
/*
52435253
yjit_reg_op(BIN(newarray), gen_newarray);
@@ -5258,12 +5268,9 @@ fn get_gen_fn(opcode: VALUE) -> Option<CodeGenFn>
52585268
yjit_reg_op(BIN(opt_aset), gen_opt_aset);
52595269
yjit_reg_op(BIN(opt_mult), gen_opt_mult);
52605270
yjit_reg_op(BIN(opt_div), gen_opt_div);
5261-
yjit_reg_op(BIN(opt_mod), gen_opt_mod);
52625271
yjit_reg_op(BIN(opt_ltlt), gen_opt_ltlt);
52635272
yjit_reg_op(BIN(opt_nil_p), gen_opt_nil_p);
52645273
yjit_reg_op(BIN(opt_empty_p), gen_opt_empty_p);
5265-
yjit_reg_op(BIN(opt_str_freeze), gen_opt_str_freeze);
5266-
yjit_reg_op(BIN(opt_str_uminus), gen_opt_str_uminus);
52675274
yjit_reg_op(BIN(opt_not), gen_opt_not);
52685275
yjit_reg_op(BIN(opt_size), gen_opt_size);
52695276
yjit_reg_op(BIN(opt_length), gen_opt_length);

yjit/src/cruby.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ extern "C" {
126126

127127
pub fn rb_hash_new_with_size(sz:usize) -> VALUE;
128128
pub fn rb_hash_bulk_insert(argc:c_long, argv: *mut u8, hash:VALUE);
129+
130+
pub fn rb_vm_opt_mod(recv:VALUE, obj:VALUE) -> VALUE;
129131
}
130132

131133
pub fn insn_len(opcode:usize) -> u32

0 commit comments

Comments
 (0)
0